Package xal.extension.widgets.swing
Class KeyValueTableModel<T>
java.lang.Object
javax.swing.table.AbstractTableModel
xal.extension.widgets.swing.KeyValueTableModel<T>
- All Implemented Interfaces:
Serializable,TableModel
- Direct Known Subclasses:
KeyValueFilteredTableModel
Table Model whose records are arbitrary objects and whose values are obtained
through the Key-Value adaptor
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final KeyValueAdaptorkey value adaptor to get the value from a record (row) for the specified key path (column property)Fields inherited from class javax.swing.table.AbstractTableModel
listenerList -
Constructor Summary
ConstructorsConstructorDescriptionEmpty ConstructorKeyValueTableModel(List<T> records, String... keyPaths) Primary Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidaddKeyValueRecordListener(KeyValueRecordListener<? extends KeyValueTableModel<T>, T> listener) Add the specified listener as a receiver of record modification events from this instance.Class<?>getColumnClass(int column) Get the data class for the specified columnintGet the number of columns to displayintgetColumnForKeyPath(String keyPath) Get the model column for the specified key pathgetColumnName(int column) Get the name of the specified columngetKeyPathForColumn(int column) Get the key path for the specified model columngetRecordAtRow(int row) Get the record at the specified row indexintGet the number of rows to displayGet the records indexed by rowgetValueAt(int row, int column) get the value for the specified cellbooleanisCellEditable(int row, int column) Determine whether the cell is editablevoidRemove the specified listener from receiving record modification events from this instance.voidsetColumnClass(String keyPath, Class<?> columnClass) Set the column class for the specified columnvoidsetColumnClassForKeyPaths(Class<?> columnClass, String... keyPaths) Set the column class for the columns specified by the key pathsvoidsetColumnEditable(String keyPath, boolean allowsEdit) Set whether the column associated with the specified key path is editablevoidsetColumnEditKeyPath(String columnKeyPath, String editKeyPath) Set whether a cell associated with the specified column key path is editable based on the cell's record value corresponding to the specified edit key pathvoidsetColumnEditKeyPath(String columnKeyPath, String editKeyPath, boolean negation) Set whether a cell associated with the specified column key path is editable based on the cell's record value corresponding to the specified edit key pathvoidsetColumnName(String keyPath, String name) Set the name of the specified columnvoidsetDataSource(List<T> records, String... keyPaths) Set the records (row) and key paths (column accessors)voidsetKeyPaths(String... keyPaths) Set the key paths (column accessors)voidsetRecords(List<T> records) Set the records (row)voidsetValueAt(Object value, int row, int column) Set the value of the specified cellMethods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
-
Field Details
-
keyValueAdaptor
key value adaptor to get the value from a record (row) for the specified key path (column property)
-
-
Constructor Details
-
KeyValueTableModel
Primary Constructor- Parameters:
records- the list of objects (one record for each table row)keyPaths- specifies the array of key paths to get the data to display (one key path for each column)
-
KeyValueTableModel
public KeyValueTableModel()Empty Constructor
-
-
Method Details
-
addKeyValueRecordListener
public void addKeyValueRecordListener(KeyValueRecordListener<? extends KeyValueTableModel<T>, T> listener) Add the specified listener as a receiver of record modification events from this instance.- Parameters:
listener- object to receive events
-
removeKeyValueRecordListener
Remove the specified listener from receiving record modification events from this instance.- Parameters:
listener- object to be removed from receiving events
-
setDataSource
Set the records (row) and key paths (column accessors)- Parameters:
records- the list of objects (one record for each table row)keyPaths- specifies the array of key paths to get the data to display (one key path for each column)
-
getRecordAtRow
Get the record at the specified row index -
getRowRecords
Get the records indexed by row -
setRecords
Set the records (row)- Parameters:
records- the list of objects (one record for each table row)
-
getKeyPathForColumn
Get the key path for the specified model column- Parameters:
column- model column for which to get the key path- Returns:
- key path for the specified model column or null if the column is out of bounds
-
getColumnForKeyPath
Get the model column for the specified key path- Parameters:
keyPath- key path to the specified column- Returns:
- model column index for the specified key path or -1 if no match
-
setKeyPaths
Set the key paths (column accessors)- Parameters:
keyPaths- specifies the array of key paths to get the data to display (one key path for each column)
-
setColumnName
Set the name of the specified column- Parameters:
keyPath- key path for which to assign the namename- the new name to assign the column
-
getColumnName
Get the name of the specified column- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractTableModel
-
setColumnClass
Set the column class for the specified column- Parameters:
keyPath- key path for which to assign the classcolumnClass- the new class to assign the column
-
setColumnClassForKeyPaths
Set the column class for the columns specified by the key paths- Parameters:
columnClass- the new class to assign the columnkeyPaths- key paths for which to assign the class
-
getColumnClass
Get the data class for the specified column- Specified by:
getColumnClassin interfaceTableModel- Overrides:
getColumnClassin classAbstractTableModel
-
getRowCount
public int getRowCount()Get the number of rows to display -
getColumnCount
public int getColumnCount()Get the number of columns to display -
setColumnEditable
Set whether the column associated with the specified key path is editable -
setColumnEditKeyPath
Set whether a cell associated with the specified column key path is editable based on the cell's record value corresponding to the specified edit key path- Parameters:
columnKeyPath- key path of the column for which the edit rule applieseditKeyPath- key path (applied to the row's record) whose corresponding value determines whether the cell (of the row's record) is editable
-
setColumnEditKeyPath
Set whether a cell associated with the specified column key path is editable based on the cell's record value corresponding to the specified edit key path- Parameters:
columnKeyPath- key path of the column for which the edit rule applieseditKeyPath- key path (applied to the row's record) whose corresponding value determines whether the cell (of the row's record) is editablenegation- indicates whether to reverse the boolean indication of the edit column
-
isCellEditable
public boolean isCellEditable(int row, int column) Determine whether the cell is editable- Specified by:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein classAbstractTableModel
-
getValueAt
get the value for the specified cell -
setValueAt
Set the value of the specified cell- Specified by:
setValueAtin interfaceTableModel- Overrides:
setValueAtin classAbstractTableModel
-