コード例 #1
0
ファイル: GanttTree2.java プロジェクト: rudaondo/ganttproject
 @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());
   }
 }
コード例 #2
0
ファイル: GanttTree2.java プロジェクト: rudaondo/ganttproject
  /** add an object with the expand information */
  DefaultMutableTreeTableNode addObjectWithExpand(Object child, MutableTreeTableNode parent) {
    DefaultMutableTreeTableNode childNode = new TaskNode((Task) child);

    if (parent == null) {
      parent = getRootNode();
    }

    getTreeModel().insertNodeInto(childNode, parent, parent.getChildCount());
    myProject.refreshProjectInformation();

    return childNode;
  }