1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 *
26 * ident "%Z%%M% %I% %E% SMI"
27 */
28 package com.sun.dhcpmgr.ui;
29
30 /*
31 * @(#)TableMap.java 1.4 97/12/17
32 */
33
34 /**
35 * In a chain of data manipulators some behaviour is common. TableMap
36 * provides most of this behavour and can be subclassed by filters
37 * that only need to override a handful of specific methods. TableMap
38 * implements TableModel by routing all requests to its model, and
39 * TableModelListener by routing all events to its listeners. Inserting
40 * a TableMap which has not been subclassed into a chain of table filters
41 * should have no effect.
42 *
43 * @version 1.4 12/17/97
44 * @author Philip Milne */
45
46 import javax.swing.table.*;
47 import javax.swing.event.TableModelListener;
48 import javax.swing.event.TableModelEvent;
49
50 public class TableMap extends AbstractTableModel implements TableModelListener
51 {
52 protected TableModel model;
53
54 public TableModel getModel() {
55 return model;
56 }
57
58 public void setModel(TableModel model) {
59 this.model = model;
60 model.addTableModelListener(this);
61 }
62
63 // By default, Implement TableModel by forwarding all messages
64 // to the model.
65
66 public Object getValueAt(int aRow, int aColumn) {
67 return model.getValueAt(aRow, aColumn);
68 }
69
70 public void setValueAt(Object aValue, int aRow, int aColumn) {
71 model.setValueAt(aValue, aRow, aColumn);
72 }
73
74 public int getRowCount() {
75 return (model == null) ? 0 : model.getRowCount();
76 }
77
78 public int getColumnCount() {
79 return (model == null) ? 0 : model.getColumnCount();
80 }
81
82 public String getColumnName(int aColumn) {
83 return model.getColumnName(aColumn);
84 }
85
86 public Class getColumnClass(int aColumn) {
87 return model.getColumnClass(aColumn);
88 }
89
90 public boolean isCellEditable(int row, int column) {
91 return model.isCellEditable(row, column);
92 }
93 //
94 // Implementation of the TableModelListener interface,
95 //
96
97 // By default forward all events to all the listeners.
98 public void tableChanged(TableModelEvent e) {
99 fireTableChanged(e);
100 }
101 }