01: package com.jeta.swingbuilder.gui.components;
02:
03: /**
04: * In a chain of data manipulators some behaviour is common. TableMap
05: * provides most of this behavour and can be subclassed by filters
06: * that only need to override a handful of specific methods. TableMap
07: * implements TableModel by routing all requests to its model, and
08: * TableModelListener by routing all events to its listeners. Inserting
09: * a TableMap which has not been subclassed into a chain of table filters
10: * should have no effect.
11: *
12: * @version 1.4 12/17/97
13: * @author Philip Milne */
14:
15: import javax.swing.event.TableModelEvent;
16: import javax.swing.event.TableModelListener;
17: import javax.swing.table.AbstractTableModel;
18: import javax.swing.table.TableModel;
19:
20: public class TableMap extends AbstractTableModel implements
21: TableModelListener {
22: protected TableModel model;
23:
24: public TableModel getModel() {
25: return model;
26: }
27:
28: public void setModel(TableModel model) {
29: this .model = model;
30: // model.addTableModelListener(this);
31: }
32:
33: // By default, implement TableModel by forwarding all messages
34: // to the model.
35: public Object getValueAt(int aRow, int aColumn) {
36: return model.getValueAt(aRow, aColumn);
37: }
38:
39: public void setValueAt(Object aValue, int aRow, int aColumn) {
40: model.setValueAt(aValue, aRow, aColumn);
41: }
42:
43: public int getRowCount() {
44: return (model == null) ? 0 : model.getRowCount();
45: }
46:
47: public int getColumnCount() {
48: return (model == null) ? 0 : model.getColumnCount();
49: }
50:
51: public String getColumnName(int aColumn) {
52: return model.getColumnName(aColumn);
53: }
54:
55: public Class getColumnClass(int aColumn) {
56: return model.getColumnClass(aColumn);
57: }
58:
59: public boolean isCellEditable(int row, int column) {
60: return model.isCellEditable(row, column);
61: }
62:
63: //
64: // Implementation of the TableModelListener interface,
65: //
66: // By default forward all events to all the listeners.
67: public void tableChanged(TableModelEvent e) {
68: fireTableChanged(e);
69: }
70: }
|