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; }
@Override protected boolean shouldHideAddedRows() { return !getContainerStrategy().isNodeOpen(toggledItemId); }
/** * Checks if Item with given identifier is collapsed in the UI. * * <p> * * @param itemId * the identifier of the checked Item * @return true if the Item with given id is collapsed * @see Collapsible#isCollapsed(Object) */ public boolean isCollapsed(Object itemId) { return !getContainerStrategy().isNodeOpen(itemId); }
@Override protected void paintRowAttributes(PaintTarget target, Object itemId) throws PaintException { super.paintRowAttributes(target, itemId); target.addAttribute("depth", getContainerStrategy().getDepth(itemId)); if (getContainerDataSource().areChildrenAllowed(itemId)) { target.addAttribute("ca", true); target.addAttribute("open", getContainerStrategy().isNodeOpen(itemId)); } }