Package javax.swing.tree

Examples of javax.swing.tree.TreePath


        // Avoid infinite recursion loop with highlightChanged notification
        boolean highlightSave = autoHighlight;
        autoHighlight = false;

        SceneGraphModel model = (SceneGraphModel)getModel();
        TreePath path = new TreePath(model.getPathToRoot(node));
        if (on) addSelectionPath(path);
        else this.removeSelectionPath(path);
       
        autoHighlight = highlightSave;
    }
View Full Code Here


          // Keep the expanded state of all children that are expanded
          ArrayList expPaths = null;
          if (action!=NODE_CHANGED) {
              expPaths = new ArrayList();
              recursiveExpandedPathFinder(new TreePath(nodePath), expPaths);
          }

          // change model to add or remove the new child to the parent node
            model.fireTreeChanged(target, nodePath, null, null);

            // Universes have their own listeners. nodePath[0] is root, 1 is universe
            // Notify only the universe concerned by the changes, not the other universes
            if ((nodePath.length>=2) && (nodePath[1] instanceof SceneNode)) {
                ((SceneNode)nodePath[1]).notifyListeners();
            }
         
          // restore expanded state
          if (action!=NODE_CHANGED) for (Iterator it = expPaths.iterator(); it.hasNext();) {
              TreePath path = (TreePath)it.next();
              expandPath(path);
          }

          // Set selection on the new element
          if (action==NODE_ADDED) setSelectionPath(new TreePath(model.getPathToRoot(node)));
          else if (action==NODE_REMOVED) setSelectionPath(new TreePath(model.getPathToRoot(target)));
        }
View Full Code Here

  public void mouseClicked(MouseEvent e) {
   
    if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) == MouseEvent.BUTTON3_MASK) {
       
      Object dest = null;
      TreePath path = sceneTree.getPathForLocation(e.getX(), e.getY());

      if (path != null) sceneTree.setSelectionPath(path);
     
      if (sceneTree.getSelectionPath() != null) {
        dest = sceneTree.getSelectionPath().getLastPathComponent();
      }
     
      if (dest==null) dest = ((SceneGraphModel)sceneTree.getModel()).getRoot();
     
      if (!(dest instanceof ActiveNode)) return;
      ActiveNode node = (ActiveNode)dest;
     
      JPopupMenu menu = pluginManager.getChildMenu(node, this);
      List actions = node.getActions();
      if ((menu==null) && ((actions==null) || (actions.size()==0)))
          return; // this component does not have any declared potential children, and no actions
      // If there are actions, but no children, new menu
      if (menu==null) menu = new JPopupMenu();
      // Otherwise, add separator if needed
      else if ((actions!=null) && (actions.size()>0)) menu.add(new JPopupMenu.Separator(), 0);
      // Now add actions on top of menu, keeping order
      if (actions!=null)
          for (int i=actions.size()-1; i>=0; --i) {
              Object a = actions.get(i);
              if (a!=null) menu.add(new ActionMenuItem(node, a), 0);
          }
      // Finally popup the result
      menu.show((JComponent)e.getSource(), e.getX(), e.getY());
     
    } else if (e.getClickCount()==2 && (e.getModifiers()&MouseEvent.BUTTON1_MASK)==MouseEvent.BUTTON1_MASK){
     
      Object dest = null;
      TreePath path = sceneTree.getPathForLocation(e.getX(), e.getY());
     
      if (path != null) sceneTree.setSelectionPath(path);
     
      if (sceneTree.getSelectionPath() != null) {
        dest = sceneTree.getSelectionPath().getLastPathComponent();
View Full Code Here

            currentPage = page;
           
            // Get page tree path
            DefaultMutableTreeNode node = (DefaultMutableTreeNode)targetToNodeTable.get(page);
            if (node != null){
                TreePath path = new TreePath(node.getPath());

                // If page path has changed, update help tree and back stack
                if (!path.equals(helpTree.getSelectionPath())){
                    helpTree.scrollPathToVisible(path);
                    helpTree.setSelectionPath(path);
                }
            }
        }
View Full Code Here

        addTreeSelectionListener(new TreeSelectionListener(){

            @Override
            public void valueChanged(TreeSelectionEvent e) {
                TreePath tp=e.getPath();
                if(tp.getPathCount()>1){
                    AbstractNode an=(AbstractNode)tp.getPathComponent(1);
                    if(an.getGraphObject()instanceof Universe){
                        UniversePool.getGlobal().setCurrentUniverse((Universe)an.getGraphObject());
                    }
                } 
            }
           
        });
        MouseListener ml = new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                if (e.getButton() == MouseEvent.BUTTON3) {
                    // show popup menu
                    TreePath selPath = getPathForLocation(e.getX(), e.getY());
                    AbstractNode n;
                    if (selPath != null) {
                        n = (AbstractNode) selPath.getLastPathComponent();
                    } else {
                        n = _rootNode;
                    }
                    doPopup(n, e.getX(), e.getY());
                }
View Full Code Here

        if(cmd.equals("y")){
            if(_undoHandler.getRedoAction().isEnabled())
                _undoHandler.getRedoAction().actionPerformed(e);
            return;
        }
        TreePath tp=Tree.this.getSelectionPath();
        AbstractNode s = (AbstractNode)tp.getLastPathComponent();
        if(s==null || !(s instanceof SceneGraphTreeNode)){
            return;
        }
        SceneGraphTreeNode n=(SceneGraphTreeNode)s;
        if(cmd.equals("c")){
View Full Code Here

        Stack<SceneGraphObject> st=new Stack<SceneGraphObject>();
        st.addAll(sgos);
        _createChildren(tpn,st);
       
        // 2 expand the path
        TreePath tp=new TreePath(tpn.toArray());
        expandPath(tp);
        return tp;
    }
View Full Code Here

        clearSelection();
        for(Node n : nodes){
            ArrayList<SceneGraphObject> sgos=new ArrayList<SceneGraphObject>();
            Universe u = Universe.getGraphPath(n, null,
                    sgos);
            TreePath tp=expand(sgos, u);
            addSelectionPath(tp);
        }
       
    }
View Full Code Here

        }
    }

    protected class ShapeTransferable implements Transferable {
        public DataFlavor[] getTransferDataFlavors() {
            TreePath tp=Tree.this.getSelectionPath();
            AbstractNode s = (AbstractNode)tp.getLastPathComponent();
            if (s == null || !(s instanceof UniverseNode)) {
                return new DataFlavor[0];
            }
            DataFlavor[] ret = new DataFlavor[1];
            ret[0] = ShapesContainer.SHAPE_FLAVOR;
View Full Code Here

            ret[0] = ShapesContainer.SHAPE_FLAVOR;
            return ret;
        }

        public boolean isDataFlavorSupported(DataFlavor flavor) {
            TreePath tp=Tree.this.getSelectionPath();
            Object s = (AbstractNode)tp.getLastPathComponent();
            if (s == null) {
                return false;
            }
            if (s instanceof UniverseNode) {
                return ShapeCreator.class.equals(flavor.getRepresentationClass());
View Full Code Here

TOP

Related Classes of javax.swing.tree.TreePath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.