List of usage examples for javax.swing.tree TreeNode getChildCount
int getChildCount();
TreeNode
s the receiver contains. From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java
/** * Expands or collapses the specified tree according to the * <code>expand</code>-parameter. *///from w ww.ja v a 2 s . com private void expandTree(JTree currentTree, TreePath parent, boolean expand) { TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration<TreeNode> e = node.children(); e.hasMoreElements();) { TreePath path = parent.pathByAddingChild(e.nextElement()); expandTree(currentTree, path, expand); } } if (expand) { currentTree.expandPath(parent); } else { currentTree.collapsePath(parent); } }
From source file:de.tor.tribes.ui.views.DSWorkbenchSelectionFrame.java
private TreePath find2(JTree tree, TreePath parent, Village pNode, int depth) { TreeNode node = (TreeNode) parent.getLastPathComponent(); DefaultMutableTreeNode o = (DefaultMutableTreeNode) node; // If equal, go down the branch if (o.getUserObject().equals(pNode)) { // If at end, return match return parent; } else {/*from w ww.java2 s .c o m*/ // Traverse children if (node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements();) { TreeNode n = (TreeNode) e.nextElement(); TreePath path = parent.pathByAddingChild(n); TreePath result = find2(tree, path, pNode, depth + 1); // Found a match if (result != null) { return result; } } } } // No match at this branch return null; }
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); }/* ww w. j av a 2 s . co 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 */// w w w . java 2 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.artifactory.webapp.wicket.actionable.tree.ActionableItemsTree.java
public TreeNode getPrevTreeNode(TreeNode node) { DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); if (parent == null) { return null; }/* ww w.ja v a 2 s . c o m*/ TreeNode prevNode = parent.getChildBefore(node); if (prevNode != null) { ITreeState state = getTreeState(); node = prevNode; while (!node.isLeaf() && node.getAllowsChildren() && state.isNodeExpanded(node)) { node = node.getChildAt(node.getChildCount() - 1); } return node; } DefaultTreeModel treeModel = getTreeModel(); if (parent == treeModel.getRoot()) { return null; } return parent; }
From source file:org.carewebframework.help.javahelp.HelpView.java
/** * Duplicates JavaHelp topic tree into HelpTopicNode-based tree. * //from w w w . j av a2 s.com * @param htnParent Current parent for HelpTopicNode-based tree. * @param ttnParent Current parent for JavaHelp TreeNode-based tree. */ private void initTopicTree(HelpTopicNode htnParent, TreeNode ttnParent) { for (int i = 0; i < ttnParent.getChildCount(); i++) { TreeNode ttnChild = ttnParent.getChildAt(i); HelpTopic ht = getTopic(ttnChild); HelpTopicNode htnChild = new HelpTopicNode(ht); htnParent.addChild(htnChild); initTopicTree(htnChild, ttnChild); } }
From source file:org.eclipse.wb.internal.swing.model.property.editor.models.tree.TreeModelPropertyEditor.java
/** * Appends given {@link TreeNode} and its children to the {@link StringBuffer}. */// www . j ava 2s. co m private static void getText_appendNodes(StringBuffer buffer, TreeNode node, String prefix) { // append separator if (buffer.length() != 0) { buffer.append(", "); } // append current node buffer.append(prefix); if (node instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode mutableTreeNode = (DefaultMutableTreeNode) node; buffer.append(mutableTreeNode.getUserObject()); } // append children String newPrefix = prefix + "+"; for (int i = 0; i < node.getChildCount(); i++) { getText_appendNodes(buffer, node.getChildAt(i), newPrefix); } }
From source file:org.eclipse.wb.internal.swing.model.property.editor.models.tree.TreeModelPropertyEditor.java
/** * Appends given {@link TreeNode} and its children to the {@link StringBuffer}. *//* ww w . j a va 2s.c o m*/ private static void getTooltip_appendNodes(StringBuffer buffer, TreeNode node, String prefix) { // append separator if (buffer.length() != 0) { buffer.append("\n"); } // append current node buffer.append(prefix); if (node instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode mutableTreeNode = (DefaultMutableTreeNode) node; buffer.append(mutableTreeNode.getUserObject()); } // append children String newPrefix = prefix + " "; for (int i = 0; i < node.getChildCount(); i++) { getTooltip_appendNodes(buffer, node.getChildAt(i), newPrefix); } }
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 w ww. ja va 2 s . co m*/ } // Expansion or collapse must be done bottom-up if (expand) { tree.expandPath(parent); } else { tree.collapsePath(parent); } }
From source file:org.olivier.ihm.FramePUMLCleanerControler.java
/** * Analyse une ligne et dtermine si elle est imprimable ou pas * * @param line La ligne analyser/*from w ww.ja v a 2s . co m*/ * @param nodeToDelete Liste des noeuds supprimer * @return True si la ligne doit etre imprime, false sinon */ private boolean isLinePrintable(String line, DefaultMutableTreeNode nodeToDelete) { boolean isPrintable = true; // parcours des catgories for (int i = 0; i < nodeToDelete.getChildCount(); i++) { final TreeNode categ = nodeToDelete.getChildAt(i); // parcours des noeuds supprimer for (int j = 0; j < categ.getChildCount(); j++) { final DefaultMutableTreeNode noeudToDelete = (DefaultMutableTreeNode) categ.getChildAt(j); final String nomNoeudToDelete = noeudToDelete.toString(); if (line.contains(nomNoeudToDelete)) { isPrintable = false; break; } } if (!isPrintable) { break; } } return isPrintable; }