KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > admin > common > PropertyTable


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.admin.common;
5
6 import javax.swing.table.TableCellEditor JavaDoc;
7 import javax.swing.table.TableCellRenderer JavaDoc;
8 import javax.swing.table.TableModel JavaDoc;
9
10 public class PropertyTable extends XTable {
11   private PropertyTableModel m_model;
12  
13   public PropertyTable() {
14     super();
15   }
16   
17   public PropertyTable(PropertyTableModel model) {
18     super();
19     setModel(m_model = model);
20   }
21
22   protected TableModel JavaDoc createDefaultDataModel() {
23     return new PropertyTableModel();
24 }
25
26   public void setModel(TableModel JavaDoc model) {
27     if(!(model instanceof PropertyTableModel)) {
28       throw new IllegalArgumentException JavaDoc("Must be a PropertyTableModel");
29     }
30     super.setModel(m_model = (PropertyTableModel)model);
31   }
32   
33   public PropertyTableModel getPropertyModel() {
34     return (PropertyTableModel)getModel();
35   }
36   
37   public TableCellEditor JavaDoc getCellEditor(int row, int column) {
38     switch(column) {
39       case PropertyTableModel.VALUE_COLUMN:
40         return getDefaultEditor(m_model.getRowClass(row));
41     }
42
43     return super.getCellEditor(row, column);
44   }
45
46   public TableCellRenderer JavaDoc getCellRenderer(int row, int column) {
47     switch(column) {
48       case PropertyTableModel.VALUE_COLUMN:
49         return getDefaultRenderer(m_model.getRowClass(row));
50     }
51
52     return super.getCellRenderer(row, column);
53   }
54 }
55
Popular Tags