List of usage examples for javax.swing JTree expandPath
public void expandPath(TreePath path)
From source file:org.openehealth.coms.cc.consent_applet.applet.ConsentApplet.java
/** * Listener which handles the expansion of TreeNodes * // w w w.j av a 2 s .c o m * @return */ private TreeExpansionListener getMyTreeExpansionListener() { return new TreeExpansionListener() { public void treeCollapsed(TreeExpansionEvent arg0) { } public void treeExpanded(TreeExpansionEvent arg0) { //Normal Tree, load child Nodes from the server if (arg0.getPath().getLastPathComponent() instanceof LazyOIDTreeNode) { LazyOIDTreeNode node = (LazyOIDTreeNode) arg0.getPath().getLastPathComponent(); if (!node.isLeaf() && !node.hasBeenExpanded()) { node.setHasBeenExpanded(true); requestTreeNode(node); } } //Search Tree, expand as usual else if (arg0.getPath().getLastPathComponent() instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) arg0.getPath().getLastPathComponent(); JTree tree = (JTree) arg0.getSource(); tree.expandPath(new TreePath(node.getPath())); } }; }; }
From source file:org.openmicroscopy.shoola.agents.util.SelectionWizardUI.java
/** * Updates the specified tree./* ww w. j a v a 2 s . com*/ * * @param tree The tree to update. * @param nodes The collection of nodes to handle. */ private void populateTreeItems(JTree tree, List<TreeImageDisplay> nodes) { DefaultTreeModel dtm = (DefaultTreeModel) tree.getModel(); TreeImageDisplay parent = (TreeImageDisplay) dtm.getRoot(); parent.removeAllChildrenDisplay(); parent.removeAllChildren(); Iterator<TreeImageDisplay> i = nodes.iterator(); TreeImageDisplay node, child; Iterator<TreeImageDisplay> j; Set<TreeImageDisplay> toExpand = new HashSet<TreeImageDisplay>(); while (i.hasNext()) { node = i.next(); node.setDisplayItems(false); Object ho = node.getUserObject(); if (ho instanceof TagAnnotationData) { TagAnnotationData tag = (TagAnnotationData) ho; if (!TagAnnotationData.INSIGHT_TAGSET_NS.equals(tag.getNameSpace()) || node.hasChildrenDisplay()) { dtm.insertNodeInto(node, parent, parent.getChildCount()); } } else { dtm.insertNodeInto(node, parent, parent.getChildCount()); } if (node.hasChildrenDisplay()) { node.removeAllChildren(); tree.expandPath(new TreePath(node.getPath())); Collection<TreeImageDisplay> l = node.getChildrenDisplay(); l = sorter.sort(l); j = l.iterator(); while (j.hasNext()) { child = j.next(); child.setDisplayItems(false); if (!isSelected(child) && !isFiltered(child)) { dtm.insertNodeInto(child, node, node.getChildCount()); toExpand.add(node); tree.expandPath(new TreePath(node.getPath())); } } } } dtm.reload(); i = toExpand.iterator(); while (i.hasNext()) { tree.expandPath(new TreePath(i.next().getPath())); } }
From source file:view.CertificatePropertiesDialog.java
private void expandAll(JTree tree, TreePath path) { TreeNode node = (TreeNode) path.getLastPathComponent(); if (node.getChildCount() >= 0) { Enumeration enumeration = node.children(); while (enumeration.hasMoreElements()) { TreeNode n = (TreeNode) enumeration.nextElement(); TreePath p = path.pathByAddingChild(n); expandAll(tree, p);/*from w w w. ja v a2 s.com*/ } } tree.expandPath(path); }