@Override public Collection<?> getChildren(Object itemId) { // If the wrapped container implements the method directly, use it if (hierarchical) { return ((Container.Hierarchical) container).getChildren(itemId); } final Collection<?> c = children.get(itemId); if (c == null) { return null; } return Collections.unmodifiableCollection(c); }
private void addVisibleChildTree(Object id) { if (isNodeOpen(id)) { Collection<?> children = getContainerDataSource() .getChildren(id); if (children != null) { for (Object childId : children) { preOrder.add(childId); addVisibleChildTree(childId); } } } }
private int countSubNodesRecursively(Hierarchical hc, Object itemId) { int count = 0; // we need the number of children for toggledItemId no matter if its // collapsed or expanded. Other items' children are only counted if the // item is expanded. if (getContainerStrategy().isNodeOpen(itemId) || itemId == toggledItemId) { Collection<?> children = hc.getChildren(itemId); if (children != null) { count += children != null ? children.size() : 0; for (Object id : children) { count += countSubNodesRecursively(hc, id); } } } return count; }
/** * Removes the Item identified by given itemId and all its children from the * given Container. * * @param container * the container where the item is to be removed * @param itemId * the identifier of the Item to be removed * @return true if the operation succeeded */ public static boolean removeItemRecursively( Container.Hierarchical container, Object itemId) { boolean success = true; Collection<?> children2 = container.getChildren(itemId); if (children2 != null) { for (Object o : children2.toArray()) { boolean removeItemRecursively = removeItemRecursively(container, o); if (!removeItemRecursively) { success = false; } } } // remove the root of subtree if children where successfully removed if (success) { success = container.removeItem(itemId); } return success; }
@Override public Collection<?> getChildren(Object itemId) { return getContainerDataSource().getChildren(itemId); }
@Override public Collection<?> getChildren(Object itemId) { return hierarchical.getChildren(itemId); }
/** * Gets the IDs of all Items that are children of the specified Item. * * @see Container.Hierarchical#getChildren(Object) */ @Override public Collection<?> getChildren(Object itemId) { return ((Container.Hierarchical) items).getChildren(itemId); }