boolean addingToHiddedRoot = parentItem.getParentItem() == null && isRootLess(); List<TreeItem> itemChildren = parentItem.getChildren(); int childLevel = parentItem.getLevel() + 1; final int[] childIndices = e.getChildIndices(); for (int i = 0; i < eventChildren.size(); ++i)
int level = item.getLevel(); List<TreeItem> children = item.getChildren(); String id = item.getId(); TreeItem parent = item.getParentItem(); int index = parent != null ? parent.getChildren().indexOf(item) : -1; dirtyItemsCreateDOM.remove(item); item.remove(); item.setChildren(children); parent.getChildren().set(index, item);
TreeItem parent = item.getParentItem(); int index = parent.getChildren().indexOf(item); TreeItem previous; previous = parent.getChildren().get(index - 1); while (previous.getChildren() != null && previous.getChildren().size() > 0) previous = previous.getChildren() .get(previous.getChildren().size() - 1); item.getMarkupId() + "\"," + "\"" + previous.getMarkupId() + "\")"); if (item.getChildren() == null) item.setRenderChildren(true);
parentItem.getChildren().remove(itemToDelete); removeItem(itemToDelete); if (!parentItem.hasChildTreeItems())
String tagName = ((ComponentTag)getMarkup().get(0)).getName(); Response response = getResponse(); response.write("<" + tagName + " style=\"display:none\" id=\"" + getMarkupId() + "\">"); if ("table".equals(tagName)) if (isRenderChildren())
/** * Marks the last but one visible child node of the given item as dirty, if give child is the * last item of parent. * * We need this to refresh the previous visible item in case the inserted / deleted item was * last. The reason is that the line shape of previous item changes from L to |- . * * @param parent * @param child */ private void markTheLastButOneChildDirty(TreeItem parent, TreeItem child) { if (parent.getChildren().indexOf(child) == parent.getChildren().size() - 1) { // go through the children backwards, start at the last but one // item for (int i = parent.getChildren().size() - 2; i >= 0; --i) { TreeItem item = parent.getChildren().get(i); // invalidate the node and it's children, so that they are // redrawn invalidateNodeWithChildren(item.getModelObject()); } } }
/** * Builds the children for given TreeItem. It recursively traverses children of it's TreeNode * and creates TreeItem for every visible TreeNode. * * @param item * The parent tree item */ private void buildItemChildren(TreeItem item) { List<TreeItem> items; // if the node is expanded if (isNodeExpanded(item.getModelObject())) { // build the items for children of the items' treenode. items = buildTreeItems(item, nodeChildren(item.getModelObject()), item.getLevel() + 1); } else { // it's not expanded, just set children to an empty list items = new ArrayList<TreeItem>(0); } item.setChildren(items); }
/** * Call the callback#visitItem method for every child of given item. * * @param item * The tree item * @param callback * The callback */ private void visitItemChildren(TreeItem item, IItemCallback callback) { if (item.getChildren() != null) { for (TreeItem child : item.getChildren()) { visitItemAndChildren(child, callback); } } }
/** * Rebuilds children of every item in dirtyItems that needs it. This method is called for * non-partial update. */ private void rebuildDirty() { // go through dirty items for (TreeItem item : dirtyItems) { // item children need to be rebuilt if (item.getChildren() == null) { buildItemChildren(item); } } }
/** * Creates a tree item for given node with specified id. * * @param parent * @param node * The tree node * @param level * The level * @param id * the component id * @return The new tree item */ private TreeItem newTreeItem(TreeItem parent, Object node, int level, String id) { return new TreeItem(parent, id, node, level); }
/** * Creates a tree item for given node. * * @param parent * @param node * The tree node * @param level * The level * * @return The new tree item */ private TreeItem newTreeItem(TreeItem parent, Object node, int level) { return new TreeItem(parent, "" + idCounter++, node, level); }
/** * * @return model object */ public Object getModelObject() { return getDefaultModelObject(); }
/** * Whether to render children. * * @return whether to render children */ protected final boolean isRenderChildren() { return getFlag(FLAG_RENDER_CHILDREN); }
/** * @see Component#getMarkupId() */ @Override public String getMarkupId() { // this is overridden to produce id that begins with id of tree // if the tree has set (shorter) id in markup, we can use it to // shorten the id of individual TreeItems return AbstractTree.this.getMarkupId() + "_" + getId(); }
@Override public void visitItem(TreeItem item) { // render child item.onRender(); // go through the behaviors and invoke IBehavior.afterRender List<? extends Behavior> behaviors = item.getBehaviors(); for (Behavior behavior : behaviors) { behavior.afterRender(item); } } });
@Override public void visitItem(TreeItem item) { item.detach(); } });
private boolean hasParentWithChildrenMarkedToRecreation() { return getParentItem() != null && (getParentItem().getChildren() == null || getParentItem().hasParentWithChildrenMarkedToRecreation()); } }
@Override public void visitItem(TreeItem item) { item.beforeRender(); } });