public class DomainObjectTableModel extends AbstractTableModel
TableModel
that may be used to display a (potentially
editable) list of persistent domain objects in a JTable
.PersistentObject
,
DomainObjectFieldAdapter
,
Serialized FormModifier and Type | Field and Description |
---|---|
private Vector |
data |
private boolean |
deferredStore |
private ExceptionHandler |
errorHandler |
private DomainObjectFieldAdapter |
fieldAdapter |
private boolean |
modified |
listenerList
Constructor and Description |
---|
DomainObjectTableModel(DomainObjectFieldAdapter adapter)
Construct a new
DomainObjectTableModel for the given
field adapter. |
Modifier and Type | Method and Description |
---|---|
private void |
_deliverException(Exception ex) |
void |
addObject(PersistentObject object)
Add an object to the end of the data vector.
|
void |
clear()
Remove all objects from the data vector.
|
void |
clearModified()
Clear the modification flag for this model.
|
Class |
getColumnClass(int column)
Get the object type for the specified column.
|
int |
getColumnCount()
Get the column count for this model.
|
String |
getColumnName(int column)
Get the name of a given column.
|
boolean |
getDeferredStore()
Get the deferred store mode for this model.
|
ExceptionHandler |
getExceptionHandler()
Get the current
ExceptionHandler for this model. |
PersistentObject |
getObjectForRow(int row)
Get the
PersistentObject for the specified row in the
table model. |
int |
getRowCount()
Get the row count for this model.
|
int |
getRowForObject(PersistentObject object)
Get the row for the specified
PersistentObject . |
Object |
getValueAt(int row,
int column)
Get the value at the specified row and column in the table model.
|
void |
insertObjectAt(PersistentObject object,
int row)
Insert an object at the specified position in the data vector.
|
boolean |
isCellEditable(int row,
int column)
Determine if the cell at the given coordinates is editable.
|
boolean |
isModified()
Determine if the data in this model has been modified.
|
void |
prepareJTable(JTable table)
Prepare a
JTable for use with this model. |
void |
removeObjectAt(int row)
Remove the object at the specified position from the data vector.
|
void |
setDeferredStore(boolean flag)
Set the deferred store mode for this model.
|
void |
setExceptionHandler(ExceptionHandler handler)
Set the
ExceptionHandler for this model. |
void |
setValueAt(Object value,
int row,
int column)
Set the value at the specified row and column in the table model.
|
void |
updateObjectAt(int row)
Notify the model that the object at the given row has been updated.
|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
private DomainObjectFieldAdapter fieldAdapter
private boolean modified
private boolean deferredStore
private ExceptionHandler errorHandler
public DomainObjectTableModel(DomainObjectFieldAdapter adapter)
DomainObjectTableModel
for the given
field adapter.adapter
- The field adapter to use.public void setDeferredStore(boolean flag)
PersistentObject
to be written to the persistent store
immediately via a call to its store()
method. If deferred
store is off, no automatic stores are performed.flag
- A flag that specifies whether deferred mode should be on
(true
) or off (false
).public boolean getDeferredStore()
true
if deferred store is on, and false
otherwise.public String getColumnName(int column)
getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
column
- The index of the column.public void addObject(PersistentObject object)
object
- The PersistentObject
to add.public void insertObjectAt(PersistentObject object, int row)
object
- The PersistentObject
to add.row
- The row at which to insert the object.public void updateObjectAt(int row)
row
- The row of the updated object.public void clear()
public void removeObjectAt(int row)
row
- The row of the object to remove.public int getRowCount()
public int getColumnCount()
public Object getValueAt(int row, int column)
row
- The row.column
- The columnpublic void setValueAt(Object value, int row, int column)
setValueAt
in interface TableModel
setValueAt
in class AbstractTableModel
row
- The row.column
- The columnvalue
- The new object for the specified coordinates.public void prepareJTable(JTable table)
JTable
for use with this model. This method
creates the necessary columns in the JTable
and assigns
the appropriate cell renderers and editors (as provided by the field
adapter) for each column.table
- The JTable
with which this model will be used.public PersistentObject getObjectForRow(int row)
PersistentObject
for the specified row in the
table model.row
- The row.PersistentObject
represented in the given row.getRowForObject(kiwi.db.PersistentObject)
public int getRowForObject(PersistentObject object)
PersistentObject
.object
- The PersistentObject
to locate.getObjectForRow(int)
public boolean isCellEditable(int row, int column)
isCellEditable
in interface TableModel
isCellEditable
in class AbstractTableModel
row
- The row.column
- The column.true
if the cell at the given row and column is
editable and false
otherwise. The field adapter is consulted
to determine if the field corresponding to the given column is mutable.public boolean isModified()
true
if modifications have been made, and
false
otherwise.clearModified()
public void clearModified()
isModified()
public Class getColumnClass(int column)
getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
column
- The column.Class
object for the specified column. This value
is ultimately obtained by calling the getFieldClass()
method
of the field adapter.public void setExceptionHandler(ExceptionHandler handler)
ExceptionHandler
for this model. If an exception
occurs while a domain object is being updated as a result of a change
to one of the values in this model, the exception is caught and delivered
to the handler (if one is registered).handler
- The new (possibly null
) exception handler.public ExceptionHandler getExceptionHandler()
ExceptionHandler
for this model.null
) exception handler.private void _deliverException(Exception ex)
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses