@Override public final void nodeCollapsed(Object node) { if (isNodeVisible(node) == true) { invalidateNodeWithChildren(node); } }
@Override public final void nodeExpanded(Object node) { if (isNodeVisible(node) == true) { invalidateNodeWithChildren(node); } }
/** * 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()); } } }
/** * @see TreeModelListener#treeStructureChanged(TreeModelEvent) */ @Override public final void treeStructureChanged(TreeModelEvent e) { if (dirtyAll) { return; } // get the parent node of changed nodes Object node = e.getTreePath() != null ? e.getTreePath().getLastPathComponent() : null; // has the tree root changed? if (node == null || e.getTreePath().getPathCount() == 1) { invalidateAll(); } else { invalidateNodeWithChildren(node); } }
invalidateNodeWithChildren(grandparentNode);