public class SwingTableModel extends AbstractTableModel
A table model implementation for tables defined by the TableTag
tag
handler class.
This class implements the typical table model functionality based on the data
provided by a TableTag
object. Especially the model collection
and the constructed renderer and editor forms are used for extracting the
required data. The basic idea is as follows: the index of the last accessed
row is cached. If a different row is to be accessed, the model will fetch the
data bean with this index from the model collection specified for the table
tag. Then the forms will be initialized with this bean.
For editable columns special handling is required: If the column defines a
special editor component, default form operations can be performed for
validating user input and transfering it into the corresponding model bean.
Otherwise the data passed to the setValueAt()
method must be
manually passed to the corresponding ComponentHandler
objects;
after that typical form operations can be used, too.
listenerList
Constructor and Description |
---|
SwingTableModel(TableTag tt,
JTable tab)
Creates a new instance of
SwingTableModel and initializes
it. |
Modifier and Type | Method and Description |
---|---|
protected List<Object> |
fetchModelData(TableTag tt)
Prepares the list with the model data.
|
void |
fireTableChanged(TableModelEvent event)
Notifies listeners about a change in the data of this model.
|
Class<?> |
getColumnClass(int col)
Returns the data class of the specified column.
|
int |
getColumnCount()
Returns the number of columns of the represented table.
|
String |
getColumnName(int col)
Returns the name for the specified column.
|
TableCellEditor |
getEditor()
Returns the cell editor associated with this model.
|
List<Object> |
getModelData()
Returns the list with the data of this model.
|
TableCellRenderer |
getRenderer()
Returns the cell renderer associated with this model.
|
int |
getRowCount()
Returns the number of rows of the represented table.
|
JTable |
getTable()
Returns a reference to the associated table.
|
TableTag |
getTableTag()
Returns the table tag this model is based onto.
|
Object |
getValueAt(int row,
int col)
Returns the value at the specified cell.
|
boolean |
hasEditor(int col)
Checks whether for the specified column a custom editor is specified.
|
boolean |
hasRenderer(int col)
Tests whether for the specified column a custom renderer is specified.
|
boolean |
isCellEditable(int row,
int col)
Returns a flag whether the specified cell can be modified.
|
void |
setValueAt(Object value,
int row,
int col)
Sets the value for the specified cell.
|
protected boolean |
validateColumn(int col)
Validates the column with the specified index.
|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
public List<Object> getModelData()
public TableTag getTableTag()
public JTable getTable()
public int getColumnCount()
public int getRowCount()
public Object getValueAt(int row, int col)
row
- the row indexcol
- the column indexpublic Class<?> getColumnClass(int col)
getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
col
- the column indexpublic String getColumnName(int col)
getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
col
- the column indexpublic boolean isCellEditable(int row, int col)
isCellEditable
in interface TableModel
isCellEditable
in class AbstractTableModel
row
- the row indexcol
- the column indexpublic void setValueAt(Object value, int row, int col)
setValueAt
in interface TableModel
setValueAt
in class AbstractTableModel
value
- the value to setrow
- the row indexcol
- the column indexpublic void fireTableChanged(TableModelEvent event)
fireTableChanged
in class AbstractTableModel
event
- the eventpublic boolean hasEditor(int col)
col
- the column indexpublic TableCellEditor getEditor()
public boolean hasRenderer(int col)
col
- the column indexpublic TableCellRenderer getRenderer()
protected List<Object> fetchModelData(TableTag tt)
tt
- the table tag defining the underlying tableprotected boolean validateColumn(int col)
TableEditorValidationHandler
set for this table. If validation is successful, the value(s) will be
written into the model.col
- the column to be validatedCopyright © 2013 The JGUIraffe Team. All Rights Reserved.