Package javax.swing.tree

Examples of javax.swing.tree.TreePath


   
    private void expandAll(DefaultMutableTreeNode node) {
        if (top == null) return;
       
        try {
            tree.expandPath(new TreePath(top.getPath()));
        } catch (Exception e) {
            logger.error(e, e);
        }
    }
View Full Code Here


        createTree();
    }
   
    protected void setSelected(DefaultMutableTreeNode node) {
        DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
        TreePath treePath = new TreePath(model.getPathToRoot(node));
        tree.setSelectionPath(treePath);
        tree.expandPath(treePath);
        tree.scrollPathToVisible(treePath);
       
        currentUserObject = node.getUserObject();
View Full Code Here

        Collections.sort(elements);
        int idx = elements.indexOf(ne.getComparableKey());
       
        model.insertNodeInto(node, parent, parent.getChildCount() == 0 ? 0 : idx);
       
        tree.expandPath(new TreePath(model.getPathToRoot(node)));
        tree.revalidate();
    }
View Full Code Here

        mainTable.addKeyListener(new KeyAdapter() {

                public void keyPressed(KeyEvent e) {
                    final int keyCode = e.getKeyCode();
                    final TreePath path = frame.groupSelector.getSelectionPath();
                    final GroupTreeNode node = path == null ? null : (GroupTreeNode) path.getLastPathComponent();

                    if (e.isControlDown()) {
                        switch (keyCode) {
                        // The up/down/left/rightkeystrokes are displayed in the
                        // GroupSelector's popup menu, so if they are to be changed,
View Full Code Here

    MouseListener ml = new MouseAdapter() {
      public void mousePressed(MouseEvent e) {
        JComponent c = (JComponent)e.getSource();
        if (c != SourceTree.this) return;
        TreePath path = getPathForLocation(e.getX(), e.getY());
        if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) == MouseEvent.BUTTON3_MASK) {
          if (path!=null) setSelectionPath(path);
          boolean locked = false;
          if (getSelectionPath()!=null) {
            Object node = getSelectionPath().getLastPathComponent();
            if (node instanceof SourceNode) {
              if (((SourceNode)node).isLocked()) {
                locked = true;
              }
            }
          }
          if (!locked) doPopup(e.getX(), e.getY());
          return;
        }
      }

      public void mouseExited(MouseEvent e) {
        setCursor(Cursor.getDefaultCursor());
      }
    };
   
    addMouseListener(ml);

    MouseMotionListener mml = new MouseMotionAdapter() {
      public void mouseMoved(MouseEvent e) {
        JComponent c = (JComponent)e.getSource();
        if (c != SourceTree.this) return;
        TreePath path = getPathForLocation(e.getX(), e.getY());
        if (path!=null) {
          Object node = path.getLastPathComponent();
          if (node instanceof SourceNode) {
            if (((SourceNode)node).isLocked()) {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
              return;
            }
View Full Code Here

      Object elt = e.nextElement();
      if (!(elt instanceof DefaultMutableTreeNode)) continue;
      DefaultMutableTreeNode node = (DefaultMutableTreeNode)elt;
      Object u = node.getUserObject();
      if ((u!=null) && (u.equals(o))) {
        TreePath path = new TreePath(node.getPath());
        scrollPathToVisible(path);
        setSelectionPath(path);
        return;
      }
    }
View Full Code Here

    for (Enumeration e = rootNode.depthFirstEnumeration(); e.hasMoreElements();) {
      Object elt = e.nextElement();
      if (!(elt instanceof DefaultMutableTreeNode)) continue;
      DefaultMutableTreeNode node = (DefaultMutableTreeNode)elt;
      if (id.equals(DataInfo.getId(node.getUserObject()))) {
        TreePath path = new TreePath(node.getPath());
        scrollPathToVisible(path);
        setSelectionPath(path);
        return;
      }
    }
View Full Code Here

   * @param reloadAllNodes - if true all tree node visibility are updated, otherwise update only
   * the visibility of visible nodes
   */
  public void reload(boolean reloadAllNodes) {
      // Keep selection
      TreePath sel = this.getSelectionPath();

      // Update all node visibility
      if (reloadAllNodes){
          setTreeNodeVisibility(rootNode, true);
      }
View Full Code Here

   
    /**
     *  All nodes are expanded
     */
    public void expandAll(){
        expandAll(new TreePath(rootNode));
    }
View Full Code Here

        boolean hasAuxiliaryDsNodes = node instanceof DataSourceNode && ((DataSource)((DataSourceNode) node).getUserObject()).isCompound();

        if ((node.getChildCount() >= 0) && !hasAuxiliaryDsNodes) {
            for (Enumeration e=node.children(); e.hasMoreElements(); ) {
                TreeNode n = (TreeNode)e.nextElement();
                TreePath path = parent.pathByAddingChild(n);
                expandAll(path);
            }
        }

        // Do not expand auxiliary sources
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.