View Javadoc

1   package org.wcb.util;
2   /***
3    * Copyright (C) 1999  Walter Bogaardt
4    *
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10   * This library is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   * Lesser General Public License for more details.
14   *
15   * You should have received a copy of the GNU Lesser General Public
16   * License along with this library; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18   * @version 1.2 08/26/1999
19   * 
20   */
21  
22  import javax.swing.table.AbstractTableModel;
23  import javax.swing.table.TableModel;
24  import javax.swing.event.TableModelListener; 
25  import javax.swing.event.TableModelEvent; 
26  
27  public class TableMap extends AbstractTableModel implements TableModelListener
28  {
29      protected TableModel model; 
30  
31      public TableModel  getModel() {
32          return model;
33      }
34  
35      public void  setModel(TableModel model) {
36          this.model = model; 
37          model.addTableModelListener(this); 
38      }
39  
40      // By default, Implement TableModel by forwarding all messages 
41      // to the model. 
42  
43      public Object getValueAt(int aRow, int aColumn) {
44          return model.getValueAt(aRow, aColumn); 
45      }
46  	
47      public void setValueAt(Object aValue, int aRow, int aColumn) {
48          model.setValueAt(aValue, aRow, aColumn); 
49      }
50  
51      public int getRowCount() {
52          return (model == null) ? 0 : model.getRowCount(); 
53      }
54  
55      public int getColumnCount() {
56          return (model == null) ? 0 : model.getColumnCount(); 
57      }
58  	
59      public String getColumnName(int aColumn) {
60          return model.getColumnName(aColumn); 
61      }
62  
63      public Class getColumnClass(int aColumn) {
64          return model.getColumnClass(aColumn); 
65      }
66  	
67      public boolean isCellEditable(int row, int column) { 
68           return model.isCellEditable(row, column); 
69      }
70  //
71  // Implementation of the TableModelListener interface, 
72  //
73  
74      // By default forward all events to all the listeners. 
75      public void tableChanged(TableModelEvent e) {
76          fireTableChanged(e);
77      }
78  }