|
SPT Core API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnextapp.echo2.app.table.AbstractTableModel
com.sptci.echo2.table.AbstractTableModel<D>
com.sptci.echo2.table.TableModel<D>
D - The type (class name) of the model object used.public class TableModel<D>
A genericised TableModel used to
hold instances of objects of the type specified.
The following shows sample usage of this class:
import com.sptci.echo2.table.Table;
import com.sptci.echo2.table.TableModel;
...
Collection collection = ... // Fetch the collection of data
TableModel tableModel = new TableModel( collection );
Table table = new Table( tableModel );
© Copyright 2007 Sans Pareil Technologies, Inc.
| Field Summary | |
|---|---|
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. |
| Fields inherited from class com.sptci.echo2.table.AbstractTableModel |
|---|
sortDirection, sortIndex |
| Constructor Summary | |
|---|---|
protected |
TableModel()
Default constructor. |
|
TableModel(Collection<D> collection)
Create a new instance of the model using the specified collection of data objects. |
| Method Summary | |
|---|---|
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)
Fetch any Fields in the specified array
that have a Column annotation. |
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()
Process the Fields of the object type
included in data and populate columns. |
protected void |
processColumnsAnnotation(D obj)
Check for the Columns annotation
on the data object and populate columns as appropriate. |
protected void |
processFields(Map<String,Field> fields)
Process the Fields in the underlying data
object and initialise columns. |
void |
updateRow(int row,
D rowData)
Replace the row specified with the object specified. |
| Methods inherited from class com.sptci.echo2.table.AbstractTableModel |
|---|
getSortDirection |
| Methods inherited from class nextapp.echo2.app.table.AbstractTableModel |
|---|
addTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getEventListenerList, removeTableModelListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected List<D> data
Table.
protected List<ColumnMetaData> columns
Table.
This is used by the getColumnName(int) and getColumnCount()
methods.
| Constructor Detail |
|---|
protected TableModel()
public TableModel(Collection<D> collection)
init() method to
initialise this model.
collection - The collection of data objects to display in the
Table.| Method Detail |
|---|
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.echo2.app.table.TableModel) method is invoked. It is
imperative that the model be initialised before the Table.setModel(nextapp.echo2.app.table.TableModel) method is invoked keeping in mind the implementation
of Table.setModel(nextapp.echo2.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()
Fields of the object type
included in data and populate columns.
processColumnsAnnotation(D),
getColumnAnnotations(java.util.Map) ,
processColumnAnnotations(java.util.Map) ,
processFields(java.util.Map)
protected void processColumnsAnnotation(D obj)
throws RuntimeException
Columns annotation
on the data object and populate columns as appropriate.
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 in the specified array
that have a Column annotation.
fields - The map of fields that are to be checked for the
annotation.
protected void processColumnAnnotations(Map<Field,Column> fields)
columns as
annotated.
fields - A map of Field and
Column instances to use to
initialise columns.
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.
|
SPT Core API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||