| 1 |
14 |
jlechner |
/* TableModel.java --
|
| 2 |
|
|
Copyright (C) 2002, 2005, Free Software Foundation, Inc.
|
| 3 |
|
|
|
| 4 |
|
|
This file is part of GNU Classpath.
|
| 5 |
|
|
|
| 6 |
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
| 7 |
|
|
it under the terms of the GNU General Public License as published by
|
| 8 |
|
|
the Free Software Foundation; either version 2, or (at your option)
|
| 9 |
|
|
any later version.
|
| 10 |
|
|
|
| 11 |
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
| 12 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
|
|
General Public License for more details.
|
| 15 |
|
|
|
| 16 |
|
|
You should have received a copy of the GNU General Public License
|
| 17 |
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
| 18 |
|
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
| 19 |
|
|
02110-1301 USA.
|
| 20 |
|
|
|
| 21 |
|
|
Linking this library statically or dynamically with other modules is
|
| 22 |
|
|
making a combined work based on this library. Thus, the terms and
|
| 23 |
|
|
conditions of the GNU General Public License cover the whole
|
| 24 |
|
|
combination.
|
| 25 |
|
|
|
| 26 |
|
|
As a special exception, the copyright holders of this library give you
|
| 27 |
|
|
permission to link this library with independent modules to produce an
|
| 28 |
|
|
executable, regardless of the license terms of these independent
|
| 29 |
|
|
modules, and to copy and distribute the resulting executable under
|
| 30 |
|
|
terms of your choice, provided that you also meet, for each linked
|
| 31 |
|
|
independent module, the terms and conditions of the license of that
|
| 32 |
|
|
module. An independent module is a module which is not derived from
|
| 33 |
|
|
or based on this library. If you modify this library, you may extend
|
| 34 |
|
|
this exception to your version of the library, but you are not
|
| 35 |
|
|
obligated to do so. If you do not wish to do so, delete this
|
| 36 |
|
|
exception statement from your version. */
|
| 37 |
|
|
|
| 38 |
|
|
package javax.swing.table;
|
| 39 |
|
|
|
| 40 |
|
|
import javax.swing.event.TableModelListener;
|
| 41 |
|
|
|
| 42 |
|
|
/**
|
| 43 |
|
|
* A <code>TableModel</code> is a two dimensional data structure that
|
| 44 |
|
|
* can store arbitrary <code>Object</code> instances, usually for the
|
| 45 |
|
|
* purpose of display in a {@link javax.swing.JTable} component. Individual
|
| 46 |
|
|
* objects can be accessed by specifying the row index and column index for
|
| 47 |
|
|
* the object. Each column in the model has a name associated with it.
|
| 48 |
|
|
* <p>
|
| 49 |
|
|
* The {@link DefaultTableModel} class provides one implementation of
|
| 50 |
|
|
* this interface.
|
| 51 |
|
|
*
|
| 52 |
|
|
* @author Andrew Selkirk
|
| 53 |
|
|
*/
|
| 54 |
|
|
public interface TableModel
|
| 55 |
|
|
{
|
| 56 |
|
|
/**
|
| 57 |
|
|
* Returns the number of rows in the model.
|
| 58 |
|
|
*
|
| 59 |
|
|
* @return The row count.
|
| 60 |
|
|
*/
|
| 61 |
|
|
int getRowCount();
|
| 62 |
|
|
|
| 63 |
|
|
/**
|
| 64 |
|
|
* Returns the number of columns in the model.
|
| 65 |
|
|
*
|
| 66 |
|
|
* @return The column count
|
| 67 |
|
|
*/
|
| 68 |
|
|
int getColumnCount();
|
| 69 |
|
|
|
| 70 |
|
|
/**
|
| 71 |
|
|
* Returns the name of a column in the model.
|
| 72 |
|
|
*
|
| 73 |
|
|
* @param columnIndex the column index.
|
| 74 |
|
|
*
|
| 75 |
|
|
* @return The column name.
|
| 76 |
|
|
*/
|
| 77 |
|
|
String getColumnName(int columnIndex);
|
| 78 |
|
|
|
| 79 |
|
|
/**
|
| 80 |
|
|
* Returns the <code>Class</code> for all <code>Object</code> instances
|
| 81 |
|
|
* in the specified column.
|
| 82 |
|
|
*
|
| 83 |
|
|
* @param columnIndex the column index.
|
| 84 |
|
|
*
|
| 85 |
|
|
* @return The class.
|
| 86 |
|
|
*/
|
| 87 |
|
|
Class getColumnClass(int columnIndex);
|
| 88 |
|
|
|
| 89 |
|
|
/**
|
| 90 |
|
|
* Returns <code>true</code> if the cell is editable, and <code>false</code>
|
| 91 |
|
|
* otherwise.
|
| 92 |
|
|
*
|
| 93 |
|
|
* @param rowIndex the row index.
|
| 94 |
|
|
* @param columnIndex the column index.
|
| 95 |
|
|
*
|
| 96 |
|
|
* @return <code>true</code> if editable, <code>false</code> otherwise.
|
| 97 |
|
|
*/
|
| 98 |
|
|
boolean isCellEditable(int rowIndex, int columnIndex);
|
| 99 |
|
|
|
| 100 |
|
|
/**
|
| 101 |
|
|
* Returns the value (<code>Object</code>) at a particular cell in the
|
| 102 |
|
|
* table.
|
| 103 |
|
|
*
|
| 104 |
|
|
* @param rowIndex the row index.
|
| 105 |
|
|
* @param columnIndex the column index.
|
| 106 |
|
|
*
|
| 107 |
|
|
* @return The value at the specified cell.
|
| 108 |
|
|
*/
|
| 109 |
|
|
Object getValueAt(int rowIndex, int columnIndex);
|
| 110 |
|
|
|
| 111 |
|
|
/**
|
| 112 |
|
|
* Sets the value at a particular cell in the table.
|
| 113 |
|
|
*
|
| 114 |
|
|
* @param aValue the value (<code>null</code> permitted).
|
| 115 |
|
|
* @param rowIndex the row index.
|
| 116 |
|
|
* @param columnIndex the column index.
|
| 117 |
|
|
*/
|
| 118 |
|
|
void setValueAt(Object aValue, int rowIndex, int columnIndex);
|
| 119 |
|
|
|
| 120 |
|
|
/**
|
| 121 |
|
|
* Adds a listener to the model. The listener will receive notification
|
| 122 |
|
|
* of updates to the model.
|
| 123 |
|
|
*
|
| 124 |
|
|
* @param listener the listener.
|
| 125 |
|
|
*/
|
| 126 |
|
|
void addTableModelListener(TableModelListener listener);
|
| 127 |
|
|
|
| 128 |
|
|
/**
|
| 129 |
|
|
* Removes a listener from the model.
|
| 130 |
|
|
*
|
| 131 |
|
|
* @param listener the listener.
|
| 132 |
|
|
*/
|
| 133 |
|
|
void removeTableModelListener(TableModelListener listener);
|
| 134 |
|
|
}
|