public Component getCropOwner() { return getTree(); //the whole tree is a single cropping scope }
public boolean isCropper() { final Tree tree = getTree(); return tree != null && tree.inPagingMold(); }
public void setParent(Component parent) { final Component oldp = getParent(); if (oldp == parent) return; //nothing changed final Tree oldtree = oldp != null ? getTree() : null; super.setParent(parent); //maintain the selected status if (oldtree != null) oldtree.onTreechildrenRemoved(this); if (parent != null) { final Tree tree = getTree(); if (tree != null) tree.onTreechildrenAdded(this); } }
public boolean insertBefore(Component newChild, Component refChild) { final Tree tree = getTree(); if (newChild.getParent() == this && tree != null && tree.inPagingMold() && !tree.isInvalidated()) { //might change page, have to invalidate tree.invalidate(); } return super.insertBefore(newChild, refChild); }
public Set<? extends Component> getAvailableAtClient() { if (!isCropper()) return null; final Tree tree = getTree(); final Component parent = getParent(); final Execution exe = Executions.getCurrent(); final String attrnm = VISIBLE_ITEM + tree.getUuid(); Map<Treeitem, Boolean> map = cast((Map) exe.getAttribute(attrnm)); if (map == null) { //Test very simple case first since getVisibleItems costly if (parent instanceof Treeitem) { for (Treeitem ti = (Treeitem) parent;;) { if (!ti.isOpen()) return Collections.emptySet(); Component gp = ti.getParent().getParent(); if (!(gp instanceof Treeitem)) break; ti = (Treeitem) gp; } } map = tree.getVisibleItems(); Executions.getCurrent().setAttribute(attrnm, map); } return map.keySet(); //yes, we return all visible items, not just direct children //in other words, we consider the whole tree as a single scope //See also bug 2814504 } }