001: /*
002: * Modifications of Sun Microsystems code:
003: * <copyright>
004: *
005: * Copyright 1997-2004 BBNT Solutions, LLC
006: * under sponsorship of the Defense Advanced Research Projects
007: * Agency (DARPA).
008: *
009: * You can redistribute this software and/or modify it under the
010: * terms of the Cougaar Open Source License as published on the
011: * Cougaar Open Source Website (www.cougaar.org).
012: *
013: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
014: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
015: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
016: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
017: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
018: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
019: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
020: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
021: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
022: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
023: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
024: *
025: * </copyright>
026: */
027:
028: package org.cougaar.util;
029:
030: /*
031: * @(#)TableMap.java 1.7 99/04/23
032: *
033: * Copyright (c) 1997-1999 by Sun Microsystems, Inc. All Rights Reserved.
034: *
035: * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
036: * modify and redistribute this software in source and binary code form,
037: * provided that i) this copyright notice and license appear on all copies of
038: * the software; and ii) Licensee does not utilize the software in a manner
039: * which is disparaging to Sun.
040: *
041: * This software is provided "AS IS," without a warranty of any kind. ALL
042: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
043: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
044: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
045: * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
046: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
047: * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
048: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
049: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
050: * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
051: * POSSIBILITY OF SUCH DAMAGES.
052: *
053: * This software is not designed or intended for use in on-line control of
054: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
055: * the design, construction, operation or maintenance of any nuclear
056: * facility. Licensee represents and warrants that it will not use or
057: * redistribute the Software for such purposes.
058: */
059:
060: /**
061: * In a chain of data manipulators some behaviour is common. TableMap
062: * provides most of this behavour and can be subclassed by filters
063: * that only need to override a handful of specific methods. TableMap
064: * implements TableModel by routing all requests to its model, and
065: * TableModelListener by routing all events to its listeners. Inserting
066: * a TableMap which has not been subclassed into a chain of table filters
067: * should have no effect.
068: *
069: * @version 1.7 04/23/99
070: * @author Philip Milne */
071:
072: import javax.swing.event.TableModelEvent;
073: import javax.swing.event.TableModelListener;
074: import javax.swing.table.AbstractTableModel;
075: import javax.swing.table.TableModel;
076:
077: public class TableMap extends AbstractTableModel implements
078: TableModelListener {
079: protected TableModel model;
080:
081: public TableModel getModel() {
082: return model;
083: }
084:
085: public void setModel(TableModel model) {
086: this .model = model;
087: model.addTableModelListener(this );
088: }
089:
090: // By default, Implement TableModel by forwarding all messages
091: // to the model.
092:
093: public Object getValueAt(int aRow, int aColumn) {
094: return model.getValueAt(aRow, aColumn);
095: }
096:
097: public void setValueAt(Object aValue, int aRow, int aColumn) {
098: model.setValueAt(aValue, aRow, aColumn);
099: }
100:
101: public int getRowCount() {
102: return (model == null) ? 0 : model.getRowCount();
103: }
104:
105: public int getColumnCount() {
106: return (model == null) ? 0 : model.getColumnCount();
107: }
108:
109: public String getColumnName(int aColumn) {
110: return model.getColumnName(aColumn);
111: }
112:
113: public Class getColumnClass(int aColumn) {
114: return model.getColumnClass(aColumn);
115: }
116:
117: public boolean isCellEditable(int row, int column) {
118: return model.isCellEditable(row, column);
119: }
120:
121: //
122: // Implementation of the TableModelListener interface,
123: //
124:
125: // By default forward all events to all the listeners.
126: public void tableChanged(TableModelEvent e) {
127: fireTableChanged(e);
128: }
129: }
|