KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > addressbook > gui > table > model > TableModelDecorator


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.addressbook.gui.table.model;
19
20 import java.util.Map JavaDoc;
21
22 import javax.swing.event.TableModelListener JavaDoc;
23
24 import org.columba.addressbook.model.IContactModelPartial;
25
26 /**
27  * Decorator for TableModel.
28  *
29  * @author fdietz
30  */

31 public abstract class TableModelDecorator
32         implements
33             ContactItemTableModel,
34             TableModelListener JavaDoc {
35     // the model which is decorated
36
private ContactItemTableModel realModel;
37
38     public TableModelDecorator(ContactItemTableModel model) {
39         this.realModel = model;
40         realModel.addTableModelListener(this);
41     }
42
43     /** *********************** TableModel implementation ******************* */
44     public void addTableModelListener(TableModelListener JavaDoc l) {
45         realModel.addTableModelListener(l);
46     }
47
48     public Class JavaDoc getColumnClass(int columnIndex) {
49         return realModel.getColumnClass(columnIndex);
50     }
51
52     public int getColumnCount() {
53         return realModel.getColumnCount();
54     }
55
56     public String JavaDoc getColumnName(int columnIndex) {
57         return realModel.getColumnName(columnIndex);
58     }
59
60     public int getRowCount() {
61         return realModel.getRowCount();
62     }
63
64     public Object JavaDoc getValueAt(int rowIndex, int columnIndex) {
65         return realModel.getValueAt(rowIndex, columnIndex);
66     }
67
68     public boolean isCellEditable(int rowIndex, int columnIndex) {
69         return realModel.isCellEditable(rowIndex, columnIndex);
70     }
71
72     public void removeTableModelListener(TableModelListener JavaDoc l) {
73         realModel.removeTableModelListener(l);
74     }
75
76     public void setValueAt(Object JavaDoc aValue, int rowIndex, int columnIndex) {
77         realModel.setValueAt(aValue, rowIndex, columnIndex);
78     }
79
80     /**
81      * Subclasses should use this method to access the underlying "real model"
82      *
83      * @return
84      */

85     protected ContactItemTableModel getRealModel() {
86         return realModel;
87     }
88
89     /**
90      * @see org.columba.addressbook.gui.table.model.ContactItemTableModel#getContactItemMap()
91      */

92     public Map JavaDoc<String JavaDoc,IContactModelPartial> getContactItemMap() {
93         return realModel.getContactItemMap();
94     }
95
96     /**
97      * @see org.columba.addressbook.gui.table.model.ContactItemTableModel#setHeaderItemList(org.columba.addressbook.folder.HeaderItemList)
98      */

99     public void setContactItemMap(Map JavaDoc<String JavaDoc,IContactModelPartial> list) {
100         realModel.setContactItemMap(list);
101     }
102
103     /**
104      * @see org.columba.addressbook.gui.table.model.ContactItemTableModel#getHeaderItem(int)
105      */

106     public IContactModelPartial getContactItem(int index) {
107         return realModel.getContactItem(index);
108     }
109 }
Popular Tags