D - The type (class name) of the model object used.public class TableModel<D> extends AbstractTableModel<D>
TableModel used to
hold instances of objects of the type specified.
The following shows sample usage of this class:
import com.sptci.echo.table.Table;
import com.sptci.echo.table.TableModel;
...
Collection<Model> collection = ... // Fetch the collection of data
TableModel<Model> tableModel = new TableModel<>( collection );
Table<Model> table = new Table<>( tableModel );
© Copyright 2007 Sans Pareil Technologies, Inc.
| Modifier and Type | Field and Description |
|---|---|
protected List<ColumnMetaData> |
columns
The list of columns displayed in the
Table. |
protected List<D> |
data
The list of data objects that are being displayed in the
Table. |
sortDirection, sortIndex| Modifier | Constructor and Description |
|---|---|
protected |
TableModel()
Default constructor.
|
|
TableModel(Collection<D> collection)
Create a new instance of the model using the specified collection of
data objects.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRow(D row)
Add the specified object to the end of the model.
|
void |
deleteRow(D rowData)
Delete the row(s) containing the specified object from the model.
|
void |
deleteRow(int row)
Delete the specified row from the model.
|
protected Map<Field,Column> |
getColumnAnnotations(Map<String,Field> fields)
|
Class |
getColumnClass(int column)
Returns the class of the objects displayed in the specified column.
|
int |
getColumnCount()
Returns the number of columns displayed in the table.
|
String |
getColumnName(int column)
Returns the name of the specified column.
|
D |
getObjectAt(int row)
Return the object stored at the specified index in
data. |
int |
getRowCount()
Return the total number of entries in
data. |
Object |
getValueAt(int column,
int row)
Return the value at the specified coordinate in the table.
|
void |
init()
Initialise this model.
|
void |
insertRow(int row,
D rowData)
Insert the specified object at the specified row index into the model.
|
protected void |
processColumnAnnotations(Map<Field,Column> fields)
Process the annotated fields and populate
columns as
annotated. |
protected void |
processColumns()
|
protected void |
processColumnsAnnotation(D obj)
|
protected void |
processFields(Map<String,Field> fields)
|
void |
updateRow(int row,
D rowData)
Replace the row specified with the object specified.
|
getSortDirectionaddTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getEventListenerList, removeTableModelListenerprotected List<ColumnMetaData> columns
Table.
This is used by the getColumnName(int) and getColumnCount()
methods.protected TableModel()
public TableModel(Collection<D> collection)
init() method to
initialise this model.collection - The collection of data objects to display in the
Table.public void init()
processColumns() if the
columns collection is empty. This gives a chance to
sub-classes to get around over-riding the processColumns()
method and also helps automatic initialisers get around the default
processing.
This method is usually invoked from Table constructor
before the Table.setModel(nextapp.echo.app.table.TableModel) method is invoked. It is
imperative that the model be initialised before the Table.setModel(nextapp.echo.app.table.TableModel) method is invoked keeping in mind the implementation
of Table.setModel(nextapp.echo.app.table.TableModel).
init in class AbstractTableModel<D>processColumns()public void addRow(D row)
row - The data object that is to be added to the model.insertRow(int, D)public void insertRow(int row,
D rowData)
row - The index at which the object is to be inserted.rowData - The object that is to be added to the model.AbstractTableModel.fireTableRowsInserted(int, int)public void deleteRow(int row)
row - The index of the row that is to be deleted.AbstractTableModel.fireTableRowsDeleted(int, int)public void deleteRow(D rowData)
rowData - The object that is to be removed.deleteRow( int )public void updateRow(int row,
D rowData)
row - The index at which the object is to be updated.rowData - The new object that is to be used in the model.AbstractTableModel.fireTableRowsUpdated(int, int)public Class getColumnClass(int column)
getColumnClass in interface TableModelgetColumnClass in class AbstractTableModelcolumn - The column whose class is to be returned.TableModel.getColumnClass(int)public int getColumnCount()
TableModel.getColumnCount()public String getColumnName(int column)
<D.class.getName()>.<fieldName>.heading
and if found returns the localised value.getColumnName in interface TableModelgetColumnName in class AbstractTableModelcolumn - The index of the column whose name is to be returned.TableModel.getColumnName(int)public int getRowCount()
data.TableModel.getRowCount()public Object getValueAt(int column, int row) throws IllegalArgumentException
Level.SEVERE message with stack trace is logged.
Throwing a RuntimeException results in Echo
framework handling it improperly and ultimately killing the user
session with a unrelated message.column - The column index.row - The row index.IllegalArgumentException - If column or
row indices are invalid for this model.TableModel.getValueAt(int, int)public D getObjectAt(int row)
data.row - The index of the row whose underlying object is to be
returned.protected void processColumns()
protected void processColumnsAnnotation(D obj) throws RuntimeException
obj - The data object to check for the annotation.RuntimeException - If errors are encountered while fetching the
Field from the data object via reflection.protected Map<Field,Column> getColumnAnnotations(Map<String,Field> fields)
fields - The map of fields that are to be checked for the
annotation.protected void processColumnAnnotations(Map<Field,Column> fields)
columns as
annotated.protected void processFields(Map<String,Field> fields) throws RuntimeException
Fields in the underlying data
object and initialise columns. Only process fields with
common types such as primitives and their wrappers, String,
Calendar and Date. In addition
these fields must have a JavaBeans compliant accessor method.fields - The map of fields that are to be processed.RuntimeException - If errors are encountered while fetching the
value of the Field from fields.