List<TreeItem> children = item.getChildren(); String id = item.getId(); int index = parent != null ? parent.getChildren().indexOf(item) : -1; parent.getChildren().set(index, item);
/** * 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()); } } }
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); if (item.getChildren() == null)
List<TreeItem> itemChildren = parentItem.getChildren(); int childLevel = parentItem.getLevel() + 1; final int[] childIndices = e.getChildIndices();
parentItem.getChildren().remove(itemToDelete); removeItem(itemToDelete);
/** * 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); } } }
private boolean hasParentWithChildrenMarkedToRecreation() { return getParentItem() != null && (getParentItem().getChildren() == null || getParentItem().hasParentWithChildrenMarkedToRecreation()); } }