1 package org.netbeans.modules.tasklist.usertasks; 2 3 import java.util.Comparator ; 4 import java.util.Iterator ; 5 import org.netbeans.modules.tasklist.usertasks.treetable.AdvancedTreeTableNode; 6 import org.netbeans.modules.tasklist.usertasks.treetable.FilterIntf; 7 import org.openide.util.NbBundle; 8 import org.netbeans.modules.tasklist.core.util.ObjectList; 9 import org.netbeans.modules.tasklist.core.util.ObjectListEvent; 10 import org.netbeans.modules.tasklist.core.util.ObjectListListener; 11 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 12 import org.netbeans.modules.tasklist.usertasks.model.UserTaskList; 13 14 19 public class UserTaskListTreeTableNode extends 20 AdvancedTreeTableNode<UserTaskList> { 21 public static final int SUMMARY = 0; 22 public static final int PRIORITY = 1; 23 public static final int DONE = 2; 24 public static final int PERCENT_COMPLETE = 3; 25 public static final int EFFORT = 4; 26 public static final int REMAINING_EFFORT = 5; 27 public static final int SPENT_TIME = 6; 28 public static final int DETAILS = 7; 29 public static final int FILE_BASE_NAME = 8; 30 public static final int LINE_NUMBER = 9; 31 public static final int CATEGORY = 10; 32 public static final int CREATED = 11; 33 public static final int LAST_EDITED = 12; 34 public static final int DUE_DATE = 13; 35 36 private ObjectListListener tl; 37 38 46 public UserTaskListTreeTableNode(FilterIntf filter, 47 UserTasksTreeTableModel m, UserTaskList ut, 48 Comparator <AdvancedTreeTableNode> comparator) { 49 super(m, null, ut); 50 this.filter = filter; 51 this.comparator = comparator; 52 tl = new ObjectListListener() { 53 public void listChanged(ObjectListEvent ev) { 54 switch (ev.getType()) { 55 case ObjectListEvent.EVENT_ADDED: { 56 Object [] obj = ev.getObjects(); 57 for (int i = 0; i < obj.length; i++) { 58 fireChildObjectAdded(obj[i]); 59 } 60 break; 61 } 62 case ObjectListEvent.EVENT_REMOVED: { 63 Object [] obj = ev.getObjects(); 64 for (int i = 0; i < obj.length; i++) { 65 fireChildObjectRemoved(obj[i]); 66 } 67 break; 68 } 69 case ObjectListEvent.EVENT_REORDERED: 70 fireChildObjectsReordered(); 71 break; 72 case ObjectListEvent.EVENT_STRUCTURE_CHANGED: 73 refreshChildren(); 74 break; 75 } 76 } 77 }; 78 ut.getSubtasks().addListener(tl); 79 } 80 81 public Object getValueAt(int column) { 82 switch (column) { 83 case SUMMARY: 84 return NbBundle.getMessage(UserTaskListTreeTableNode.class, 85 "TaskList"); default: 87 return null; 88 } 89 } 90 91 public void setValueAt(Object aValue, int column) { 92 } 93 94 99 public UserTaskList getUserTaskList() { 100 return (UserTaskList) object; 101 } 102 103 public void destroy() { 104 super.destroy(); 105 this.getUserTaskList().getSubtasks().removeListener(tl); 106 } 107 108 public Iterator getChildrenObjectsIterator() { 109 return getUserTaskList().getSubtasks().iterator(); 110 } 111 112 public AdvancedTreeTableNode createChildNode(Object child) { 113 UserTaskTreeTableNode n = new UserTaskTreeTableNode( 114 this, filter, (UserTasksTreeTableModel) model, 115 (UserTask) child, comparator); 116 if (getFilter() != null && !getFilter().accept(child)) 117 n.setUnmatched(true); 118 return n; 119 } 120 121 public boolean accept(Object child) { 122 if (getFilter() == null) 123 return true; 124 125 return UserTaskTreeTableNode.acceptsRecursively( 126 (UserTask) child, getFilter()); 127 } 128 129 public boolean isCellEditable(int column) { 130 return false; 131 } 132 } 133 | Popular Tags |