Package org.ka2ddo.yaac.gui
Class StationListTableModel
java.lang.Object
org.ka2ddo.yaac.gui.StationListTableModel
- All Implemented Interfaces:
ActionListener
,PropertyChangeListener
,Runnable
,EventListener
,TableModel
,UnitEnumChangeListener
,TrackerListener
,FilterChangeListener
,ColumnSizingTableModel
,FastComparableTableModel
,ExtraColumnProviderChangeListener
public class StationListTableModel
extends Object
implements TableModel, ColumnSizingTableModel, TrackerListener, Runnable, PropertyChangeListener, ActionListener, FilterChangeListener, FastComparableTableModel, UnitEnumChangeListener, ExtraColumnProviderChangeListener
This provides a sortable, filterable situational status display, as a backing TableModel for
a JTable view.
- Author:
- Andrew Pavlin, KA2DDO
-
Constructor Summary
ConstructorDescriptionStationListTableModel
(ResourceBundle msgBundle, boolean isOneShot) Create a StationListViewer TableModel, obtaining column labels from the specified ResourceBundle. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Do not call.static void
Register an ExtraColumnProvider to supplement the columns in instances of this TableModel.void
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.void
filterSettingsChanged
(Filter changedFilter, boolean changedByUser) Called when the specified Filter's matching criteria have been changed.Class<?>
getColumnClass
(int columnIndex) Returns the data Class for the specified column.int
Returns the number of columns in the model.getColumnName
(int column) Returns the localized name for the column.int
getColumnWidth
(int columnIndex) Specifies the default initial width of a column from this model.static ArrayList<ExtraColumnProvider>
Get a copy of the list of registeredExtraColumnProvider
s.Get the current mode for viewing the list of stations and objects.int
Get the current number of objects known to YAAC, regardless of the view mode.int
Returns the number of rows in the model.getSortedRow
(int rowIndex) Return the object state record for the specified index into the sorted list of objects that is backing the table model.int
Get the current number of stations known to YAAC, regardless of the view mode.getValueAt
(int rowIndex, int columnIndex) Returns the value for the cell atcolumnIndex
androwIndex
.boolean
Report whether the currently defined filters should restrict the contents of the station/object list.boolean
isCellEditable
(int rowIndex, int columnIndex) Returns true if the cell atrowIndex
andcolumnIndex
is editable.boolean
isSizeToFit
(int columnIndex) Specifies whether setWidthToFit() should be enabled on this columnvoid
messageAdded
(StationState ss, int index, AX25Message msg) Called when a AX25Message is added to the history for a station in the tracker.void
messageDeleted
(StationState ss, int index, AX25Message msg) Called when a AX25Message is deleted from the history for a station in the tracker.void
This method gets called when a bound property is changed.static void
Remove an ExtraColumnProvider from supplementing the columns in instances of this TableModel.void
Removes a listener from the list that's notified each time a change to the data model occurs.void
run()
DO NOT CALL.void
setApplyFilter
(boolean applyFilter) Specify whether filters should be applied when generating the list of stations and objects.void
setListViewMode
(ListViewMode listViewMode) Set the current view mode.void
setValueAt
(Object aValue, int rowIndex, int columnIndex) Allow changing the editable columns of the table.void
stationAdded
(StationState ss, int index) Called when a new station is initially added to the tracker.void
stationDeleted
(StationState ss, int index) Called when an existing station is deleted from the tracker.void
Called when an existing station is updated with new information in the tracker.void
unitEnumChanged
(Enum<? extends UnitEnum> oldEnumValue, Enum<? extends UnitEnum> newEnumValue) Reports that a unit enum was changed.
-
Constructor Details
-
StationListTableModel
Create a StationListViewer TableModel, obtaining column labels from the specified ResourceBundle.- Parameters:
msgBundle
- ResourceBundle providing localized column titlesisOneShot
- boolean true if model does not refresh itself (useful for mini-webserver)
-
-
Method Details
-
getRowCount
public int getRowCount()Returns the number of rows in the model.- Specified by:
getRowCount
in interfaceTableModel
- Returns:
- the number of rows in the model
- See Also:
-
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:
-
getSortedRow
Return the object state record for the specified index into the sorted list of objects that is backing the table model.- Parameters:
rowIndex
- zero-based row index- Returns:
- StationState record describing the Object or Item
-
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
-
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
-
getColumnClass
Returns the data Class for the specified column.- Specified by:
getColumnClass
in interfaceTableModel
- Parameters:
columnIndex
- the column being queried- Returns:
- the Class object for the column's data
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex) Returns true if the cell atrowIndex
andcolumnIndex
is editable. Otherwise,setValueAt
on the cell will not change the value of that cell.- Specified by:
isCellEditable
in interfaceTableModel
- Parameters:
rowIndex
- the row whose value to be queriedcolumnIndex
- the column whose value to be queried- Returns:
- true if the cell is editable
- See Also:
-
getColumnName
Returns the localized name for the column.- Specified by:
getColumnName
in interfaceTableModel
- Parameters:
column
- the column being queried- Returns:
- a string containing the name of
column
-
setValueAt
Allow changing the editable columns of the table. Note that only column 11 (alias) and column 12 (alternate symbol) is editable.- Specified by:
setValueAt
in interfaceTableModel
- Parameters:
aValue
- value to assign to cellrowIndex
- row of cellcolumnIndex
- column of cell
-
getColumnWidth
public int getColumnWidth(int columnIndex) Specifies the default initial width of a column from this model. Should only be queried at table creation time.- Specified by:
getColumnWidth
in interfaceColumnSizingTableModel
- Parameters:
columnIndex
- int index of the model's column whose width should be obtained- Returns:
- the width, in the same units used by the TableColumn class's setWidth() method, or -1 to indicate the width should not be forced
-
isSizeToFit
public boolean isSizeToFit(int columnIndex) Specifies whether setWidthToFit() should be enabled on this column- Specified by:
isSizeToFit
in interfaceColumnSizingTableModel
- Parameters:
columnIndex
- int index of the model's column whose width should be obtained- Returns:
- boolean true if sizeWidthToFit() should be called on this column
-
getListViewMode
Get the current mode for viewing the list of stations and objects.- Returns:
- current ListViewMode
-
setListViewMode
Set the current view mode.- Parameters:
listViewMode
- ListViewMode to use for future display of stations/objects
-
getStationCount
public int getStationCount()Get the current number of stations known to YAAC, regardless of the view mode.- Returns:
- count of station records in tracker
-
getObjectCount
public int getObjectCount()Get the current number of objects known to YAAC, regardless of the view mode.- Returns:
- count of object records in tracker
-
addTableModelListener
Adds a listener to the list that's notified each time a change to the data model occurs.- Specified by:
addTableModelListener
in interfaceTableModel
- Parameters:
l
- the TableModelListener
-
actionPerformed
Do not call. Here to support the timer that refreshes the Age column.- Specified by:
actionPerformed
in interfaceActionListener
-
removeTableModelListener
Removes a listener from the list that's notified each time a change to the data model occurs.- Specified by:
removeTableModelListener
in interfaceTableModel
- Parameters:
l
- the TableModelListener
-
isApplyFilter
public boolean isApplyFilter()Report whether the currently defined filters should restrict the contents of the station/object list.- Returns:
- boolean true if filters will be applied
-
setApplyFilter
public void setApplyFilter(boolean applyFilter) Specify whether filters should be applied when generating the list of stations and objects.- Parameters:
applyFilter
- boolean true if filters should be used
-
messageAdded
Called when a AX25Message is added to the history for a station in the tracker.- Specified by:
messageAdded
in interfaceTrackerListener
- Parameters:
ss
- StationState containing the station's informationindex
- zero-based index of the message added to the StationState objectmsg
- APRS Message object being added to the tracker; note that non-APRS packets that can still be decoded (such as OpenTRAC) will also be passed here; AX25Frames that cannot be decoded will pass null here
-
messageDeleted
Called when a AX25Message is deleted from the history for a station in the tracker.- Specified by:
messageDeleted
in interfaceTrackerListener
- Parameters:
ss
- StationState containing the station's information; the initial Message will already be removed from the StationState objectindex
- zero-based index of the message removed from the StationState objectmsg
- APRS Message object being removed from the tracker; note that non-APRS packets that can still be decoded (such as OpenTRAC) will also be passed here; AX25Frames that cannot be decoded will pass null here
-
stationAdded
Called when a new station is initially added to the tracker.- Specified by:
stationAdded
in interfaceTrackerListener
- Parameters:
ss
- StationState containing the station's information; the initial AX25Message will not yet be stored within the StationState objectindex
- zero-based integer sequence number for this station in the StationTracker
-
stationUpdated
Called when an existing station is updated with new information in the tracker.- Specified by:
stationUpdated
in interfaceTrackerListener
- Parameters:
ss
- StationState containing the station's information
-
stationDeleted
Called when an existing station is deleted from the tracker.- Specified by:
stationDeleted
in interfaceTrackerListener
- Parameters:
ss
- StationState containing the station's informationindex
- zero-based integer sequence number for this station in the StationTracker
-
run
public void run()DO NOT CALL. AWT dispatch thread handler to bring station changes into table model. -
filterSettingsChanged
Called when the specified Filter's matching criteria have been changed.- Specified by:
filterSettingsChanged
in interfaceFilterChangeListener
- Parameters:
changedFilter
- Filter that has changedchangedByUser
- boolean true if change was manually made by user, false if change was made automatically by dynamic filter logic
-
propertyChange
This method gets called when a bound property is changed.- Specified by:
propertyChange
in interfacePropertyChangeListener
- Parameters:
evt
- A PropertyChangeEvent object describing the event source and the property that has changed.
-
unitEnumChanged
public void unitEnumChanged(Enum<? extends UnitEnum> oldEnumValue, Enum<? extends UnitEnum> newEnumValue) Reports that a unit enum was changed.- Specified by:
unitEnumChanged
in interfaceUnitEnumChangeListener
- Parameters:
oldEnumValue
- old enumeration unit of the typenewEnumValue
- new enumeration unit of the same enum type
-
getExtraColumnProvidersCopy
Get a copy of the list of registeredExtraColumnProvider
s. Intended for use by other TableModels that intend to support extra data columns.- Returns:
- ArrayList of
ExtraColumnProvider
s
-
addExtraColumnProvider
Register an ExtraColumnProvider to supplement the columns in instances of this TableModel.- Parameters:
p
- ExtraColumnProvider to register
-
removeExtraColumnProvider
Remove an ExtraColumnProvider from supplementing the columns in instances of this TableModel.- Parameters:
p
- ExtraColumnProvider to unregister
-
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
-