Package org.ka2ddo.yaac.gui
Class RawPacketTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
org.ka2ddo.yaac.gui.RawPacketTableModel
- All Implemented Interfaces:
Serializable
,TableModel
,SnifferDataListener
,ColumnSizingTableModel
,FastComparableTableModel
,ClearableTableModel
public final class RawPacketTableModel
extends AbstractTableModel
implements ColumnSizingTableModel, SnifferDataListener, FastComparableTableModel, ClearableTableModel
This class wraps the SnifferDataModel with a Java Swing TableModel.
- 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
-
Constructor Summary
ConstructorDescriptionRawPacketTableModel
(SnifferDataModel snifferDataModel) Create a table model for displaying the recent raw packets. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a listener to the list that's notified each time a change to the data model occurs.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 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.getMessage
(int rowIndex) Get the AX.25 frame associated with a particular row in the RawPacketTableModel.getMode()
Get the current message body rendering mode.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) Indicate whether tabel cell is editable.boolean
isSizeToFit
(int columnIndex) Specifies whether setWidthToFit() should be enabled on this column.boolean
Indicate whether packets are sorted by time of local receipt, or any timestamp embedded in the packet (if any).void
messagesDeleted
(int firstRow, int lastRow) Report that a block of messages has been deleted at the following range of indexes.void
messagesInserted
(int firstRow, int lastRow) Report that a block of messages has been inserted at the following range of indexes.void
Removes a listener from the list that's notified each time a change to the data model occurs.void
Schedule a short-running operation that should only occur on the GUI dispatch thread (however the implementing GUI chooses to do it).void
setMode
(RawPacketDisplayMode mode) Set the current message body rendering mode.void
setSortByRcvTime
(boolean sortByRcvTime) Specify whether packets are sorted by time of local receipt, or any timestamp embedded in the packet (if any).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, setValueAt
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.swing.table.TableModel
setValueAt
-
Constructor Details
-
RawPacketTableModel
Create a table model for displaying the recent raw packets.- Parameters:
snifferDataModel
- SnifferDataModel that contains the packet history
-
-
Method Details
-
isSortByRcvTime
public boolean isSortByRcvTime()Indicate whether packets are sorted by time of local receipt, or any timestamp embedded in the packet (if any).- Returns:
- boolean true if receive time should be used
-
setSortByRcvTime
public void setSortByRcvTime(boolean sortByRcvTime) Specify whether packets are sorted by time of local receipt, or any timestamp embedded in the packet (if any).- Parameters:
sortByRcvTime
- boolean true if receive time should be used
-
getColumnClass
Returns the data Class for the specified column.- Specified by:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractTableModel
- Parameters:
columnIndex
- the column being queried- Returns:
- the Class object for the column's data
-
getColumnName
Returns the localized 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
-
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
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex) Indicate whether tabel cell is editable.- Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
- Parameters:
rowIndex
- zero-based row index of the cellcolumnIndex
- zero-based column index of the cell- Returns:
- always false
-
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:
-
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
-
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:
-
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
-
getMessage
Get the AX.25 frame associated with a particular row in the RawPacketTableModel.- Parameters:
rowIndex
- zero-based row index- Returns:
- AX25Frame for that row
- Throws:
IndexOutOfBoundsException
- if rowIndex not between 0 and the number of messages in the table
-
getMode
Get the current message body rendering mode.- Returns:
- current SnifferPacketDisplayMode enum
-
setMode
Set the current message body rendering mode.- Parameters:
mode
- the RawPacketDisplayMode to use for future rendering
-
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
-
messagesDeleted
public void messagesDeleted(int firstRow, int lastRow) Report that a block of messages has been deleted at the following range of indexes.- Specified by:
messagesDeleted
in interfaceSnifferDataListener
- Parameters:
firstRow
- zero-based index of first messagelastRow
- zero-based index of last message
-
messagesInserted
public void messagesInserted(int firstRow, int lastRow) Report that a block of messages has been inserted at the following range of indexes.- Specified by:
messagesInserted
in interfaceSnifferDataListener
- Parameters:
firstRow
- zero-based index of first messagelastRow
- zero-based index of last message
-
scheduleToGuiThread
Schedule a short-running operation that should only occur on the GUI dispatch thread (however the implementing GUI chooses to do it).- Specified by:
scheduleToGuiThread
in interfaceSnifferDataListener
- Parameters:
r
- Runnable to be scheduled as soon as possible on the GUI thread
-
deleteAllRows
Delete all rows from this table.- Specified by:
deleteAllRows
in interfaceClearableTableModel
- Parameters:
clearType
- type of rows to delete- 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.
-