1 package org.netbeans.modules.tasklist.usertasks; 2 3 import java.util.ArrayList ; 4 import java.util.Comparator ; 5 import java.util.Iterator ; 6 import java.util.List ; 7 import org.netbeans.modules.tasklist.usertasks.model.Dependency; 8 9 import org.netbeans.modules.tasklist.usertasks.treetable.AdvancedTreeTableNode; 10 import org.netbeans.modules.tasklist.usertasks.treetable.FilterIntf; 11 import org.netbeans.modules.tasklist.usertasks.treetable.TreeTableNode; 12 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 13 14 17 public class UTDependenciesTreeTableNode extends UserTaskTreeTableNode { 18 24 public static boolean acceptsRecursivelyDep(UserTask ut, FilterIntf filter) { 25 if (filter.accept(ut)) 26 return true; 27 Iterator it = ut.getDependencies().iterator(); 28 while (it.hasNext()) { 29 Dependency child = (Dependency) it.next(); 30 if (acceptsRecursivelyDep(child.getDependsOn(), filter)) 31 return true; 32 } 33 return false; 34 } 35 36 44 public UTDependenciesTreeTableNode( 45 TreeTableNode parent, FilterIntf filter, 46 UserTasksTreeTableModel m, UserTask ut, 47 Comparator <AdvancedTreeTableNode> comparator) { 48 super(parent, filter, m, ut, comparator); 49 50 58 87 } 88 89 public boolean isLeaf() { 90 return getUserTask().getDependencies().isEmpty(); 91 } 92 93 98 99 public Iterator getChildrenObjectsIterator() { 100 List <UserTask> tasks = new ArrayList <UserTask>( 101 getUserTask().getDependencies().size()); 102 for (int i = 0; i < getUserTask().getDependencies().size(); i++) { 103 Dependency d = (Dependency) getUserTask().getDependencies().get(i); 104 tasks.add(d.getDependsOn()); 105 } 106 return tasks.iterator(); 107 } 108 109 public UTDependenciesTreeTableNode createChildNode(Object child) { 110 UTDependenciesTreeTableNode n = new UTDependenciesTreeTableNode( 111 this, filter, (UserTasksTreeTableModel) model, 112 (UserTask) child, comparator); 113 if (getFilter() != null && !getFilter().accept(child)) 114 n.unmatched = true; 115 return n; 116 } 117 118 public boolean accept(Object child) { 119 if (getFilter() == null) 120 return true; 121 122 return acceptsRecursivelyDep((UserTask) child, getFilter()); 123 } 124 } 125 | Popular Tags |