/** * Delete all virtual parents that no longer have child nodes attached. * This method does not depend upon child nodes being properly configured. */ private void deleteObsoleteVirtualLeaves(List<Node<E>> nodesToVerify) { deleteObsoleteLeaves: for(Iterator<Node<E>> i = nodesToVerify.iterator(); i.hasNext(); ) { Node<E> node = i.next(); // walk up the tree, deleting nodes while(node != null) { // we've reached a real parent, don't delete it! if(!node.virtual) continue deleteObsoleteLeaves; // we've already deleted this parent, we're done if(node.element == null) continue deleteObsoleteLeaves; // this node now has children, don't delete it if(!node.isLeaf()) continue deleteObsoleteLeaves; // if this virtual node has no children, then it's obsolete and // we can delete it right away. Afterwards, we might need to // delete that node's parent deleteNode(node); node = node.parent; } } }
/** * Delete all virtual parents that no longer have child nodes attached. * This method does not depend upon child nodes being properly configured. */ private void deleteObsoleteVirtualLeaves(List<Node<E>> nodesToVerify) { deleteObsoleteLeaves: for(Iterator<Node<E>> i = nodesToVerify.iterator(); i.hasNext(); ) { Node<E> node = i.next(); // walk up the tree, deleting nodes while(node != null) { // we've reached a real parent, don't delete it! if(!node.virtual) continue deleteObsoleteLeaves; // we've already deleted this parent, we're done if(node.element == null) continue deleteObsoleteLeaves; // this node now has children, don't delete it if(!node.isLeaf()) continue deleteObsoleteLeaves; // if this virtual node has no children, then it's obsolete and // we can delete it right away. Afterwards, we might need to // delete that node's parent deleteNode(node); node = node.parent; } } }
/** * Delete all virtual parents that no longer have child nodes attached. * This method does not depend upon child nodes being properly configured. */ private void deleteObsoleteVirtualLeaves(List<Node<E>> nodesToVerify) { deleteObsoleteLeaves: for(Iterator<Node<E>> i = nodesToVerify.iterator(); i.hasNext(); ) { Node<E> node = i.next(); // walk up the tree, deleting nodes while(node != null) { // we've reached a real parent, don't delete it! if(!node.virtual) continue deleteObsoleteLeaves; // we've already deleted this parent, we're done if(node.element == null) continue deleteObsoleteLeaves; // this node now has children, don't delete it if(!node.isLeaf()) continue deleteObsoleteLeaves; // if this virtual node has no children, then it's obsolete and // we can delete it right away. Afterwards, we might need to // delete that node's parent deleteNode(node); node = node.parent; } } }
/** * Remove the node at the specified index, firing all the required * notifications. */ private void deleteAndDetachNode(int sourceIndex, List<Node<E>> nodesToVerify) { Node<E> node = data.get(sourceIndex, REAL_NODES).get(); // if it has children, replace it with a virtual copy and schedule that for verification if(!node.isLeaf()) { Node<E> replacement = new Node<E>(node.virtual, new ArrayList<E>(node.path())); replaceNode(node, replacement, true); nodesToVerify.add(replacement); // otherwise delete it directly } else { Node<E> follower = node.next(); deleteNode(node); // remove the parent if necessary in the next iteration nodesToVerify.add(node.parent); // also remove the follower - it may have become redundant as well if(follower != null && follower.virtual) nodesToVerify.add(follower); } }
/** * Remove the node at the specified index, firing all the required * notifications. */ private void deleteAndDetachNode(int sourceIndex, List<Node<E>> nodesToVerify) { Node<E> node = data.get(sourceIndex, REAL_NODES).get(); // if it has children, replace it with a virtual copy and schedule that for verification if(!node.isLeaf()) { Node<E> replacement = new Node<E>(node.virtual, new ArrayList<E>(node.path())); replaceNode(node, replacement, true); nodesToVerify.add(replacement); // otherwise delete it directly } else { Node<E> follower = node.next(); deleteNode(node); // remove the parent if necessary in the next iteration nodesToVerify.add(node.parent); // also remove the follower - it may have become redundant as well if(follower != null && follower.virtual) nodesToVerify.add(follower); } }
/** * Remove the node at the specified index, firing all the required * notifications. */ private void deleteAndDetachNode(int sourceIndex, List<Node<E>> nodesToVerify) { Node<E> node = data.get(sourceIndex, REAL_NODES).get(); // if it has children, replace it with a virtual copy and schedule that for verification if(!node.isLeaf()) { Node<E> replacement = new Node<E>(node.virtual, new ArrayList<E>(node.path())); replaceNode(node, replacement, true); nodesToVerify.add(replacement); // otherwise delete it directly } else { Node<E> follower = node.next(); deleteNode(node); // remove the parent if necessary in the next iteration nodesToVerify.add(node.parent); // also remove the follower - it may have become redundant as well if(follower != null && follower.virtual) nodesToVerify.add(follower); } }
/** * @return <code>true</code> if the node at the specified index has * children, regardless of whether such children are visible. */ public boolean hasChildren(int visibleIndex) { boolean hasChildren = subtreeSize(visibleIndex, true) > 1; boolean isLeaf = getTreeNode(visibleIndex).isLeaf(); if(isLeaf == hasChildren) { subtreeSize(visibleIndex, true, true); } return hasChildren; }
/** * @return <code>true</code> if the node at the specified index has * children, regardless of whether such children are visible. */ public boolean hasChildren(int visibleIndex) { boolean hasChildren = subtreeSize(visibleIndex, true) > 1; boolean isLeaf = getTreeNode(visibleIndex).isLeaf(); if(isLeaf == hasChildren) { subtreeSize(visibleIndex, true, true); } return hasChildren; }
/** {@inheritDoc} */ public boolean isLeaf(Object node) { if(node == treeRoot) { return treeList.isEmpty(); } else { TreeList.Node<E> treeNode = (TreeList.Node<E>)node; return treeNode.isLeaf(); } }
/** {@inheritDoc} */ @Override public boolean isLeaf(Object node) { if(node == treeRoot) { return treeList.isEmpty(); } else { TreeList.Node<E> treeNode = (TreeList.Node<E>)node; return treeNode.isLeaf(); } }
/** * @return <code>true</code> if the node at the specified index has * children, regardless of whether such children are visible. */ public boolean hasChildren(int visibleIndex) { boolean hasChildren = subtreeSize(visibleIndex, true) > 1; boolean isLeaf = getTreeNode(visibleIndex).isLeaf(); if(isLeaf == hasChildren) { subtreeSize(visibleIndex, true, true); } return hasChildren; }
/** {@inheritDoc} */ public boolean isLeaf(Object node) { if(node == treeRoot) { return treeList.isEmpty(); } else { TreeList.Node<E> treeNode = (TreeList.Node<E>)node; return treeNode.isLeaf(); } }