Package org.ka2ddo.yaac.gui
Class LocalObjectTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
org.ka2ddo.yaac.gui.LocalObjectTableModel
- All Implemented Interfaces:
Serializable
,TableModel
,LocalObjectTracker.LocalObjectListener
,FastComparableTableModel
,ExtraColumnProviderChangeListener
,ClearableTableModel
public class LocalObjectTableModel
extends AbstractTableModel
implements LocalObjectTracker.LocalObjectListener, ClearableTableModel, FastComparableTableModel, ExtraColumnProviderChangeListener
This class provides the table information for displaying all locally
managed Objects/Items.
- Author:
- Andrew Pavlin, KA2DDO
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ka2ddo.yaac.util.ClearableTableModel
ClearableTableModel.ClearType
-
Field Summary
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a listener to the list that's notified each time a change to the data model occurs.void
cellValueChanged
(ExtraColumnProvider provider, GuiContentType guiContentType, int extraColumnIndex, SupportsExtraData rowData) This method is cslled by an ExtraColumnProvider when the value in a cell of an extra column changes (corresponding to a TableModelEvent.UPDATE on the displaying table's model).void
columnListChanged
(ExtraColumnProvider provider, GuiContentType guiContentType) This method is called by an ExtraColumnProvider when its set of columns changes.int
compareRows
(int rowIndex1, int rowIndex2, int columnIndex) Compare the selected column of the two rows.int
deleteAllRows
(ClearableTableModel.ClearType clearType) Delete all rows from this table.Class<?>
getColumnClass
(int columnIndex) Returns the Class for interpreting the value of the specified columnint
Returns the number of columns in the model.getColumnName
(int column) Returns the name for the column,int
Returns the number of rows in the model.getValueAt
(int rowIndex, int columnIndex) Returns the value for the cell atcolumnIndex
androwIndex
.boolean
isCellEditable
(int rowIndex, int columnIndex) Reports whether the specified cell can be modified by the user.void
objectAdded
(int index, LocalObjectTracker.ObjectLink objectLink) Report that an Object was added to the LocalObjectTracker.void
objectDeleted
(int index, LocalObjectTracker.ObjectLink objectLink) Report that an Object was deleted from the LocalObjectTracker.void
objectModified
(int index, LocalObjectTracker.ObjectLink objectLink) Report that an Object was modified in the LocalObjectTracker.void
Removes a listener from the list that's notified each time a change to the data model occurs.void
setValueAt
(Object aValue, int rowIndex, int columnIndex) Set the value of editable cells of the table.boolean
Identifies whether this table can contain playback (historical) data.boolean
Identifies whether this table can contain realtime data.Methods inherited from class javax.swing.table.AbstractTableModel
findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners
-
Method Details
-
getColumnCount
public int getColumnCount()Returns the number of columns in the model.- Specified by:
getColumnCount
in interfaceTableModel
- Returns:
- the number of columns in the model
- See Also:
-
getColumnClass
Returns the Class for interpreting the value of the specified column- Specified by:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractTableModel
- Parameters:
columnIndex
- the column being queried- Returns:
- the Class for the specified column
-
getColumnName
Returns the name for the column,- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractTableModel
- Parameters:
column
- the column being queried- Returns:
- a string containing the name of
column
-
getRowCount
public int getRowCount()Returns the number of rows in the model. AJTable
uses this method to determine how many rows it should display. This method should be quick, as it is called frequently during rendering.- Specified by:
getRowCount
in interfaceTableModel
- Returns:
- the number of rows in the model
- See Also:
-
getValueAt
Returns the value for the cell atcolumnIndex
androwIndex
.- Specified by:
getValueAt
in interfaceTableModel
- Parameters:
rowIndex
- the row whose value is to be queriedcolumnIndex
- the column whose value is to be queried- Returns:
- the value Object at the specified cell
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex) Reports whether the specified cell can be modified by the user.- Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
- Parameters:
rowIndex
- the row being queriedcolumnIndex
- the column being queried- Returns:
- boolean true if cell is editable
-
setValueAt
Set the value of editable cells of the table.- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classAbstractTableModel
- Parameters:
aValue
- value to assign to cellrowIndex
- row of cellcolumnIndex
- column of cell
-
addTableModelListener
Adds a listener to the list that's notified each time a change to the data model occurs.- Specified by:
addTableModelListener
in interfaceTableModel
- Overrides:
addTableModelListener
in classAbstractTableModel
- Parameters:
l
- the TableModelListener
-
removeTableModelListener
Removes a listener from the list that's notified each time a change to the data model occurs.- Specified by:
removeTableModelListener
in interfaceTableModel
- Overrides:
removeTableModelListener
in classAbstractTableModel
- Parameters:
l
- the TableModelListener
-
deleteAllRows
Delete all rows from this table.- Specified by:
deleteAllRows
in interfaceClearableTableModel
- Parameters:
clearType
- type of rows to be deleted- Returns:
- number of rows deleted
-
tableCanContainPlayback
public boolean tableCanContainPlayback()Identifies whether this table can contain playback (historical) data.- Specified by:
tableCanContainPlayback
in interfaceClearableTableModel
- Returns:
- boolean true if table can contain playback data.
-
tableCanContainRealtime
public boolean tableCanContainRealtime()Identifies whether this table can contain realtime data.- Specified by:
tableCanContainRealtime
in interfaceClearableTableModel
- Returns:
- boolean true if table can contain realtime data.
-
objectAdded
Report that an Object was added to the LocalObjectTracker.- Specified by:
objectAdded
in interfaceLocalObjectTracker.LocalObjectListener
- Parameters:
index
- zero-based index into tracker listobjectLink
- ObjectLink containing the new Object
-
objectModified
Report that an Object was modified in the LocalObjectTracker.- Specified by:
objectModified
in interfaceLocalObjectTracker.LocalObjectListener
- Parameters:
index
- zero-based index into tracker listobjectLink
- ObjectLink containing the modified Object
-
objectDeleted
Report that an Object was deleted from the LocalObjectTracker.- Specified by:
objectDeleted
in interfaceLocalObjectTracker.LocalObjectListener
- Parameters:
index
- zero-based index into tracker listobjectLink
- ObjectLink containing the deleted Object
-
compareRows
public int compareRows(int rowIndex1, int rowIndex2, int columnIndex) Compare the selected column of the two rows.- Specified by:
compareRows
in interfaceFastComparableTableModel
- Parameters:
rowIndex1
- zero-based model row index of first row to comparerowIndex2
- zero-based model row index of second row to comparecolumnIndex
- zero-based model column index of column to compare- Returns:
- +1 if the 1st row's column is after the 2nd row's column, -1 if before, or 0 if equal precedence
-
columnListChanged
This method is called by an ExtraColumnProvider when its set of columns changes. Note this does not mean the values of individual rows for the column, but when the presence/absence, data type, or column name of any column provided by this provider is modified. Typically, this event would cause a table model data structure change on tables using these columns.- Specified by:
columnListChanged
in interfaceExtraColumnProviderChangeListener
- Parameters:
provider
- the ExtraColumnProvider reporting the changeguiContentType
- the GuiContentType of the set of modified extra columns
-
cellValueChanged
public void cellValueChanged(ExtraColumnProvider provider, GuiContentType guiContentType, int extraColumnIndex, SupportsExtraData rowData) This method is cslled by an ExtraColumnProvider when the value in a cell of an extra column changes (corresponding to a TableModelEvent.UPDATE on the displaying table's model). Allows ExtraColumnProvider instances to have dynamically changing values.- Specified by:
cellValueChanged
in interfaceExtraColumnProviderChangeListener
- Parameters:
provider
- the ExtraColumnProvider reporting the changeguiContentType
- the GuiContentType of the set of extra columnsextraColumnIndex
- zero-based index of extra column from this provider that changedrowData
- SupportsExtraData object for the modified row, or null for all rows
-