1 29 30 package nextapp.echo2.app.table; 31 32 import java.beans.PropertyChangeListener ; 33 import java.beans.PropertyChangeSupport ; 34 import java.io.Serializable ; 35 36 import nextapp.echo2.app.Extent; 37 38 41 public class TableColumn 42 implements Serializable { 43 44 public static final String CELL_RENDERER_CHANGED_PROPERTY = "cellRenderer"; 45 public static final String HEADER_RENDERER_CHANGED_PROPERTY = "headerRenderer"; 46 public static final String HEADER_VALUE_CHANGED_PROPERTY = "headerValue"; 47 public static final String IDENTIFIER_CHANGED_PROPERTY = "identifier"; 48 public static final String MODEL_INDEX_CHANGED_PROPERTY = "modelIndex"; 49 public static final String WIDTH_CHANGED_PROPERTY = "width"; 50 51 private Extent width; 52 private TableCellRenderer cellRenderer; 53 private TableCellRenderer headerRenderer; 54 private Object headerValue; 55 private int modelIndex; 56 private Object identifier; 57 private PropertyChangeSupport pcs = new PropertyChangeSupport (this); 58 59 66 public TableColumn(int modelIndex) { 67 this(modelIndex, null, null, null); 68 } 69 70 78 public TableColumn(int modelIndex, Extent width) { 79 this(modelIndex, width, null, null); 80 } 81 82 92 public TableColumn(int modelIndex, Extent width, TableCellRenderer cellRenderer, TableCellRenderer headerRenderer) { 93 super(); 94 95 this.modelIndex = modelIndex; 96 this.width = width; 97 setCellRenderer(cellRenderer); 98 setHeaderRenderer(headerRenderer); 99 } 100 101 107 public void addPropertyChangeListener(PropertyChangeListener l) { 108 pcs.addPropertyChangeListener(l); 109 } 110 111 119 public TableCellRenderer getCellRenderer() { 120 return cellRenderer; 121 } 122 123 131 public TableCellRenderer getHeaderRenderer() { 132 return headerRenderer; 133 } 134 135 142 public Object getHeaderValue() { 143 return headerValue; 144 } 145 146 154 public Object getIdentifier() { 155 return identifier; 156 } 157 158 166 public int getModelIndex() { 167 return modelIndex; 168 } 169 170 177 public Extent getWidth() { 178 return width; 179 } 180 181 187 public void removePropertyChangeListener(PropertyChangeListener l) { 188 pcs.removePropertyChangeListener(l); 189 } 190 191 199 public void setCellRenderer(TableCellRenderer newValue) { 200 TableCellRenderer oldValue = cellRenderer; 201 cellRenderer = newValue; 202 pcs.firePropertyChange(CELL_RENDERER_CHANGED_PROPERTY, oldValue, newValue); 203 } 204 205 213 public void setHeaderRenderer(TableCellRenderer newValue) { 214 TableCellRenderer oldValue = headerRenderer; 215 headerRenderer = newValue; 216 pcs.firePropertyChange(HEADER_RENDERER_CHANGED_PROPERTY, oldValue, newValue); 217 } 218 219 226 public void setHeaderValue(Object newValue) { 227 Object oldValue = headerValue; 228 headerValue = newValue; 229 pcs.firePropertyChange(HEADER_VALUE_CHANGED_PROPERTY, oldValue, newValue); 230 } 231 232 240 public void setIdentifier(Object newValue) { 241 Object oldValue = identifier; 242 identifier = newValue; 243 pcs.firePropertyChange(IDENTIFIER_CHANGED_PROPERTY, oldValue, newValue); 244 } 245 246 254 public void setModelIndex(int newValue) { 255 int oldValue = modelIndex; 256 modelIndex = newValue; 257 pcs.firePropertyChange(MODEL_INDEX_CHANGED_PROPERTY, oldValue, newValue); 258 } 259 260 267 public void setWidth(Extent newValue) { 268 Extent oldValue = width; 269 width = newValue; 270 pcs.firePropertyChange(WIDTH_CHANGED_PROPERTY, oldValue, newValue); 271 } 272 } 273 | Popular Tags |