1 package org.netbeans.modules.tasklist.usertasks.treetable; 2 3 import java.util.ArrayList ; 4 import java.util.Collections ; 5 import java.util.Comparator ; 6 import java.util.List ; 7 8 import javax.swing.tree.DefaultMutableTreeNode ; 9 import javax.swing.tree.TreeNode ; 10 11 14 public class DefaultMutableTreeTableNode extends DefaultMutableTreeNode 15 implements TreeTableNode { 16 private List <Object > values; 17 18 22 public DefaultMutableTreeTableNode() { 23 super(null); 24 } 25 26 33 public DefaultMutableTreeTableNode(Object userObject) { 34 super(userObject, true); 35 } 36 37 47 public DefaultMutableTreeTableNode(Object userObject, boolean allowsChildren) { 48 super(userObject, allowsChildren); 49 } 50 51 public void setValueAt(Object aValue, int column) { 52 if (values == null) 53 values = new ArrayList <Object >(); 54 55 while (values.size() <= column) { 56 values.add(null); 57 } 58 values.set(column, aValue); 59 } 60 61 public Object getValueAt(int column) { 62 if (values == null) 63 return null; 64 if (values.size() > column) 65 return values.get(column); 66 else 67 return null; 68 } 69 70 public boolean isCellEditable(int column) { 71 return false; 72 } 73 74 79 @SuppressWarnings ("unchecked") 80 public void sort(final Comparator <TreeNode > c) { 81 if (children == null) 82 return; 83 84 Collections.sort(children, c); 87 88 for (int i = 0; i < getChildCount(); i++) { 89 TreeNode tn = getChildAt(i); 90 ((DefaultMutableTreeTableNode) tn).sort(c); 91 } 92 } 93 } 94 | Popular Tags |