1 19 20 package org.netbeans.modules.tasklist.usertasks.dependencies; 21 22 import javax.swing.tree.TreeModel ; 23 import org.netbeans.modules.tasklist.core.util.ObjectList; 24 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 25 import org.netbeans.modules.tasklist.usertasks.model.UserTaskList; 26 27 32 public class UserTaskTreeModel implements TreeModel { 33 private UserTaskList utl; 34 35 40 public UserTaskTreeModel(UserTaskList utl) { 41 this.utl = utl; 42 } 43 44 public boolean isLeaf(Object node) { 45 return extractObjectList(node).size() == 0; 46 } 47 48 public int getChildCount(Object parent) { 49 return extractObjectList(parent).size(); 50 } 51 52 public void valueForPathChanged(javax.swing.tree.TreePath path, Object newValue) { 53 } 54 55 public void removeTreeModelListener(javax.swing.event.TreeModelListener l) { 56 } 57 58 public void addTreeModelListener(javax.swing.event.TreeModelListener l) { 59 } 60 61 public Object getChild(Object parent, int index) { 62 return extractObjectList(parent).get(index); 63 } 64 65 public Object getRoot() { 66 return utl; 67 } 68 69 public int getIndexOfChild(Object parent, Object child) { 70 return -1; 71 } 72 73 78 private ObjectList extractObjectList(Object node) { 79 if (node instanceof UserTaskList) 80 return ((UserTaskList) node).getSubtasks(); 81 else 82 return ((UserTask) node).getSubtasks(); 83 } 84 } 85 | Popular Tags |