/** Refresh the expansion (recursive function) */ public void expandRefresh(TreeTableNode moved) { if (moved instanceof TaskNode) { Task movedTask = (Task) moved.getUserObject(); if (movedTask.getExpand()) { getTreeTable().getTree().expandPath(TreeUtil.createPath(moved)); } for (int i = 0; i < moved.getChildCount(); i++) { expandRefresh(moved.getChildAt(i)); } } }
@Override public void treeExpanded(TreeExpansionEvent e) { if (area != null) { area.repaint(); } DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) (e.getPath().getLastPathComponent()); Task task = (Task) node.getUserObject(); task.setExpand(true); myProject.setAskForSave(true); }
@Override public void applyPreservingExpansionState(Task rootTask, Predicate<Task> callable) { MutableTreeTableNode rootNode = getNode(rootTask); List<MutableTreeTableNode> subtree = TreeUtil.collectSubtree(rootNode); Collections.reverse(subtree); LinkedHashMap<Task, Boolean> states = Maps.newLinkedHashMap(); for (MutableTreeTableNode node : subtree) { Task t = (Task) node.getUserObject(); states.put(t, t.getExpand()); } callable.apply(rootTask); for (Map.Entry<Task, Boolean> state : states.entrySet()) { setExpanded(state.getKey(), state.getValue()); } }