1 27 package org.objectweb.clif.console.lib.gui; 28 29 import java.util.Vector ; 30 31 import javax.swing.table.DefaultTableModel ; 32 33 public class GraphTableModel extends DefaultTableModel { 34 35 public int rows; 36 private int id; 37 private Vector injectors = new Vector (); 38 private Boolean value; 39 40 public GraphTableModel(String [] cname) { 41 super(cname, 0); 42 } 43 44 49 public void setId(int id) { 50 this.id = id; 51 } 52 53 56 public int getId() { 57 return id; 58 } 59 60 64 public void addInjector(String injectorName) { 65 Object [] arg = new Object [3]; 66 arg[0] = new Boolean (false); 67 arg[1] = new Boolean (true); 68 arg[2] = injectorName; 69 addRow(arg); 70 } 71 72 76 public Class getColumnClass(int c) { 77 return getValueAt(0, c).getClass(); 78 } 79 80 83 public Object [] getAllInjectors() { 84 injectors.removeAllElements(); 85 rows = getRowCount(); 86 87 for (int i = 0; i < rows; i++) { 88 injectors.add(getValueAt(i, 2)); 89 } 90 91 return injectors.toArray(); 92 } 93 94 97 public Object [] getInjectorsToDisplay() { 98 injectors.removeAllElements(); 99 rows = getRowCount(); 100 101 for (int i = 0; i < rows; i++) { 102 value = (Boolean ) getValueAt(i, 0); 103 if (value.booleanValue()) 104 injectors.add(getValueAt(i, 2)); 105 } 106 107 return injectors.toArray(); 108 } 109 110 113 public Object [] getInjectorsToCollect() { 114 injectors.removeAllElements(); 115 rows = getRowCount(); 116 117 for (int i = 0; i < rows; i++) { 118 value = (Boolean ) getValueAt(i, 1); 119 if (value.booleanValue()) 120 injectors.add(getValueAt(i, 2)); 121 } 122 123 return injectors.toArray(); 124 } 125 126 130 public boolean isCellEditable(int rowIndex, int columnIndex) { 131 if (columnIndex == 2) 132 return false; 133 else 134 return true; 135 } 136 137 } | Popular Tags |