001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.addressbook.gui.table.model;
019:
020: import java.util.Map;
021:
022: import javax.swing.event.TableModelListener;
023:
024: import org.columba.addressbook.model.IContactModelPartial;
025:
026: /**
027: * Decorator for TableModel.
028: *
029: * @author fdietz
030: */
031: public abstract class TableModelDecorator implements
032: ContactItemTableModel, TableModelListener {
033: // the model which is decorated
034: private ContactItemTableModel realModel;
035:
036: public TableModelDecorator(ContactItemTableModel model) {
037: this .realModel = model;
038: realModel.addTableModelListener(this );
039: }
040:
041: /** *********************** TableModel implementation ******************* */
042: public void addTableModelListener(TableModelListener l) {
043: realModel.addTableModelListener(l);
044: }
045:
046: public Class getColumnClass(int columnIndex) {
047: return realModel.getColumnClass(columnIndex);
048: }
049:
050: public int getColumnCount() {
051: return realModel.getColumnCount();
052: }
053:
054: public String getColumnName(int columnIndex) {
055: return realModel.getColumnName(columnIndex);
056: }
057:
058: public int getRowCount() {
059: return realModel.getRowCount();
060: }
061:
062: public Object getValueAt(int rowIndex, int columnIndex) {
063: return realModel.getValueAt(rowIndex, columnIndex);
064: }
065:
066: public boolean isCellEditable(int rowIndex, int columnIndex) {
067: return realModel.isCellEditable(rowIndex, columnIndex);
068: }
069:
070: public void removeTableModelListener(TableModelListener l) {
071: realModel.removeTableModelListener(l);
072: }
073:
074: public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
075: realModel.setValueAt(aValue, rowIndex, columnIndex);
076: }
077:
078: /**
079: * Subclasses should use this method to access the underlying "real model"
080: *
081: * @return
082: */
083: protected ContactItemTableModel getRealModel() {
084: return realModel;
085: }
086:
087: /**
088: * @see org.columba.addressbook.gui.table.model.ContactItemTableModel#getContactItemMap()
089: */
090: public Map<String, IContactModelPartial> getContactItemMap() {
091: return realModel.getContactItemMap();
092: }
093:
094: /**
095: * @see org.columba.addressbook.gui.table.model.ContactItemTableModel#setHeaderItemList(org.columba.addressbook.folder.HeaderItemList)
096: */
097: public void setContactItemMap(Map<String, IContactModelPartial> list) {
098: realModel.setContactItemMap(list);
099: }
100:
101: /**
102: * @see org.columba.addressbook.gui.table.model.ContactItemTableModel#getHeaderItem(int)
103: */
104: public IContactModelPartial getContactItem(int index) {
105: return realModel.getContactItem(index);
106: }
107: }
|