/** * Returns a copy of the tree starting at the given node. * * @param tree The tree to copy (may be {@code null}). * @return A mutable copy of the given tree, or {@code null} if the tree was null. * @todo Use {@code getUserObject} when we can. * @since 2.5 */ public static MutableTreeNode copy(final TreeNode node) { if (node == null) { return null; } final DefaultMutableTreeNode target = new DefaultMutableTreeNode(node.toString(), node.getAllowsChildren()); final Enumeration children = node.children(); if (children != null) { while (children.hasMoreElements()) { final TreeNode child = (TreeNode) children.nextElement(); target.add(copy(child)); } } return target; }
public boolean getAllowsChildren() { if (bean != null && bean instanceof TreeNode) { return ((TreeNode)bean).getAllowsChildren(); } return false; }
public Iterator<Entry<Object, javax.swing.tree.TreeNode>> getChildren( final javax.swing.tree.TreeNode node) { if (node.getAllowsChildren()) { return new Iterator<Entry<Object,javax.swing.tree.TreeNode>>() { private final Enumeration<?> e = node.children(); private int counter = 0; public boolean hasNext() { return e.hasMoreElements(); } public Entry<Object, javax.swing.tree.TreeNode> next() { javax.swing.tree.TreeNode child = (javax.swing.tree.TreeNode) e.nextElement(); SwingNodeMapEntry entry = new SwingNodeMapEntry(counter++, child); return entry; } public void remove() { throw new UnsupportedOperationException(); } }; } return null; }
public boolean isLeaf(javax.swing.tree.TreeNode node) { return !node.getAllowsChildren() || node.isLeaf(); } };
/** * Returns whether the specified node is a leaf node. The way the test is * performed depends on the. * * @param node * the node to check * @return true if the node is a leaf node */ public boolean isLeaf(Object node) { if (asksAllowsChildren && node instanceof TreeNode) return !((TreeNode) node).getAllowsChildren(); return ((TreeNode) node).isLeaf(); }
/** * Returns a copy of the tree starting at the given node. * * @param tree The tree to copy (may be {@code null}). * @return A mutable copy of the given tree, or {@code null} if the tree was null. * @todo Use {@code getUserObject} when we can. * * @since 2.5 */ public static MutableTreeNode copy(final TreeNode node) { if (node == null) { return null; } final DefaultMutableTreeNode target = new DefaultMutableTreeNode( node.toString(), node.getAllowsChildren()); final Enumeration children = node.children(); if (children != null) { while (children.hasMoreElements()) { final TreeNode child = (TreeNode) children.nextElement(); target.add(copy(child)); } } return target; }
public boolean isLeaf() { if (!asksAllowsChildren) { return getData().isLeaf(); } else { return !getData().getAllowsChildren(); } }
public boolean isLeaf() { if (!asksAllowsChildren) { return getData().isLeaf(); } else { return !getData().getAllowsChildren(); } }
public boolean isLeaf() { if (!asksAllowsChildren) { return getData().isLeaf(); } else { return !getData().getAllowsChildren(); } }
private DefaultMutableTreeNode recursivelyCopyNodes( DefaultTreeModel aModel, TreeNode aNode) { DefaultMutableTreeNode copy = new DefaultMutableTreeNode(aNode .toString()); copy.setAllowsChildren(aNode.getAllowsChildren()); if (aNode.getChildCount() != 0) { Enumeration children = aNode.children(); while (children.hasMoreElements()) { TreeNode child = (TreeNode) children.nextElement(); DefaultMutableTreeNode childCopy = this .recursivelyCopyNodes(aModel, child); aModel .insertNodeInto(childCopy, copy, copy .getChildCount()); childCopy.setParent(copy); } } return copy; }
userObject = filter.convertUserObject(node, userObject); final boolean allowsChildren = node.getAllowsChildren(); final DefaultMutableTreeNode target; if (userObject == null || userObject == label) {
isSource = node.getAllowsChildren(); node = node.getParent(); if (node instanceof TreeNode) { for (int n=-1,i=0; i<count; i++) { final javax.swing.tree.TreeNode leaf=node.getChildAt(i); if (!leaf.getAllowsChildren()) {
for (index=node.getChildCount(); --index>=0;) { final javax.swing.tree.TreeNode param = node.getChildAt(index); if (param==leaf && !param.getAllowsChildren()) { break;
assertNotNull(actual); assertEquals("isLeaf()", expected.isLeaf(), actual.isLeaf()); assertEquals("getAllowsChildren()", expected.getAllowsChildren(), actual.getAllowsChildren()); assertEquals("getChildCount()", expected.getChildCount(), actual.getChildCount()); @SuppressWarnings("unchecked") final Enumeration<? extends TreeNode> ec = expected.children();