List of usage examples for javax.swing.tree TreeNode children
Enumeration<? extends TreeNode> children();
Enumeration
. From source file:gdt.jgui.entity.index.JIndexPanel.java
private void expandAll(JTree tree, TreePath parent, boolean expand) { TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements();) { TreeNode n = (TreeNode) e.nextElement(); TreePath path = parent.pathByAddingChild(n); expandAll(tree, path, expand); }//w w w. java 2 s. c o m } if (expand) { tree.expandPath(parent); } else { tree.collapsePath(parent); } }
From source file:com.pironet.tda.TDA.java
/** * expand or collapse all nodes of the specified tree * * @param catTree the tree to expand all/collapse all * @param parent the parent to start with * @param expand expand=true, collapse=false *//*from w w w . jav a2 s.c om*/ private void expandAll(JTree catTree, TreePath parent, boolean expand) { // Traverse children TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements();) { TreeNode n = (TreeNode) e.nextElement(); TreePath path = parent.pathByAddingChild(n); expandAll(catTree, path, expand); } } if (parent.getPathCount() > 1) { // Expansion or collapse must be done bottom-up if (expand) { catTree.expandPath(parent); } else { catTree.collapsePath(parent); } } }
From source file:org.geopublishing.atlasViewer.GpCoreUtil.java
private final static void expandAll(final JTree tree, final TreePath parent, final boolean expand) { // Traverse children final TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (final Enumeration<TreeNode> e = node.children(); e.hasMoreElements();) { final TreeNode n = e.nextElement(); final TreePath path = parent.pathByAddingChild(n); expandAll(tree, path, expand); }/*from ww w . j a va2 s . c o m*/ } // Expansion or collapse must be done bottom-up if (expand) { tree.expandPath(parent); } else { tree.collapsePath(parent); } }
From source file:org.languagetool.gui.ConfigurationDialog.java
@NotNull private JPanel getTreeButtonPanel(int num) { GridBagConstraints cons;/*w w w .ja va 2 s . com*/ JPanel treeButtonPanel = new JPanel(); cons = new GridBagConstraints(); cons.gridx = 0; cons.gridy = 0; JButton expandAllButton = new JButton(messages.getString("guiExpandAll")); treeButtonPanel.add(expandAllButton, cons); expandAllButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TreeNode root = (TreeNode) configTree[num].getModel().getRoot(); TreePath parent = new TreePath(root); for (Enumeration cat = root.children(); cat.hasMoreElements();) { TreeNode n = (TreeNode) cat.nextElement(); TreePath child = parent.pathByAddingChild(n); configTree[num].expandPath(child); } } }); cons.gridx = 1; cons.gridy = 0; JButton collapseAllButton = new JButton(messages.getString("guiCollapseAll")); treeButtonPanel.add(collapseAllButton, cons); collapseAllButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TreeNode root = (TreeNode) configTree[num].getModel().getRoot(); TreePath parent = new TreePath(root); for (Enumeration categ = root.children(); categ.hasMoreElements();) { TreeNode n = (TreeNode) categ.nextElement(); TreePath child = parent.pathByAddingChild(n); configTree[num].collapsePath(child); } } }); return treeButtonPanel; }
From source file:tvbrowser.extras.favoritesplugin.dlgs.FavoriteTreeModel.java
public void reload(TreeNode node) { super.reload(node); @SuppressWarnings("unchecked") Enumeration<FavoriteNode> e = node.children(); while (e.hasMoreElements()) { FavoriteNode child = e.nextElement(); if (child.isDirectoryNode()) { reload(child);/*w ww .j ava 2 s . c o m*/ } } }
From source file:tvbrowser.extras.favoritesplugin.dlgs.FavoriteTreeModel.java
public void reload(FavoriteTree tree, TreeNode node) { super.reload(node); @SuppressWarnings("unchecked") Enumeration<FavoriteNode> e = node.children(); while (e.hasMoreElements()) { FavoriteNode child = e.nextElement(); if (child.isDirectoryNode()) { reload(tree, child);/*w w w.j a v a 2 s.c o m*/ } } FavoriteNode parent = (FavoriteNode) node; if (parent.wasExpanded()) { tree.expandPath(new TreePath((tree.getModel()).getPathToRoot(node))); } else { tree.collapsePath(new TreePath((tree.getModel()).getPathToRoot(node))); } }
From source file:tvbrowser.ui.filter.dlgs.FilterTreeModel.java
public void reload(FilterTree tree, TreeNode node) { super.reload(node); @SuppressWarnings("unchecked") Enumeration<FilterNode> e = node.children(); while (e.hasMoreElements()) { FilterNode child = e.nextElement(); if (child.isDirectoryNode()) { reload(tree, child);// w w w . j a v a 2s .c o m } } FilterNode parent = (FilterNode) node; if (parent.wasExpanded()) { tree.expandPath(new TreePath((tree.getModel()).getPathToRoot(node))); } else { tree.collapsePath(new TreePath((tree.getModel()).getPathToRoot(node))); } }
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 ww w . ja v a 2s. c o m*/ } } tree.expandPath(path); }