1 19 20 package org.netbeans.modules.tasklist.timerwin; 21 22 import javax.swing.tree.TreeModel ; 23 import org.netbeans.modules.tasklist.core.util.ObjectList; 24 import org.netbeans.modules.tasklist.usertasks.UserTaskView; 25 import org.netbeans.modules.tasklist.usertasks.UserTaskViewRegistry; 26 import org.netbeans.modules.tasklist.usertasks.model.UserTaskList; 27 28 33 public class AllUserTasksTreeModel implements TreeModel { 34 private Object root = new Object (); 35 private UserTaskList[] utl; 36 37 42 public AllUserTasksTreeModel() { 43 UserTaskView[] all = UserTaskViewRegistry.getInstance().getAll(); 44 utl = new UserTaskList[all.length]; 45 for (int i = 0; i < all.length; i++) { 46 utl[i] = all[i].getUserTaskList(); 47 } 48 } 49 50 public boolean isLeaf(Object node) { 51 if (node == root) 52 return false; 53 else 54 return ((ObjectList.Owner) node).getObjectList().size() == 0; 55 } 56 57 public int getChildCount(Object parent) { 58 if (parent == root) 59 return utl.length; 60 else 61 return ((ObjectList.Owner) parent).getObjectList().size(); 62 } 63 64 public void valueForPathChanged(javax.swing.tree.TreePath path, Object newValue) { 65 } 66 67 public void removeTreeModelListener(javax.swing.event.TreeModelListener l) { 68 } 69 70 public void addTreeModelListener(javax.swing.event.TreeModelListener l) { 71 } 72 73 public Object getChild(Object parent, int index) { 74 if (parent == root) 75 return utl[index]; 76 else 77 return ((ObjectList.Owner) parent).getObjectList().get(index); 78 } 79 80 public Object getRoot() { 81 return root; 82 } 83 84 public int getIndexOfChild(Object parent, Object child) { 85 return -1; 86 } 87 } 88 | Popular Tags |