org.ka2ddo.yaac.gui
Class RawPacketTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.ka2ddo.yaac.gui.RawPacketTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel, SnifferDataListener, ColumnSizingTableModel, FastComparableTableModel, ClearableTableModel

public final class RawPacketTableModel
extends javax.swing.table.AbstractTableModel
implements ColumnSizingTableModel, SnifferDataListener, FastComparableTableModel, ClearableTableModel

This class wraps the SnifferDataModel with a Java Swing TableModel.

See Also:
Serialized Form

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
RawPacketTableModel(SnifferDataModel snifferDataModel)
           
 
Method Summary
 void addTableModelListener(javax.swing.event.TableModelListener l)
          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.
 java.lang.Class<?> getColumnClass(int columnIndex)
          Returns the data Class for the specified column.
 int getColumnCount()
          Returns the number of columns in the model.
 java.lang.String 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.
 AX25Frame getMessage(int rowIndex)
          Get the AX.25 frame associated with a particular row in the RawPacketTableModel.
 RawPacketDisplayMode getMode()
          Get the current message body rendering mode.
 int getRowCount()
          Returns the number of rows in the model.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Returns the value for the cell at columnIndex and rowIndex.
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 boolean isSizeToFit(int columnIndex)
          Specifies whether setWidthToFit() should be enabled on this column.
 boolean isSortByRcvTime()
           
 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 removeTableModelListener(javax.swing.event.TableModelListener l)
          Removes a listener from the list that's notified each time a change to the data model occurs.
 void scheduleToGuiThread(java.lang.Runnable r)
          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)
           
 
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 Detail

RawPacketTableModel

public RawPacketTableModel(SnifferDataModel snifferDataModel)
Method Detail

isSortByRcvTime

public boolean isSortByRcvTime()

setSortByRcvTime

public void setSortByRcvTime(boolean sortByRcvTime)

getColumnClass

public java.lang.Class<?> getColumnClass(int columnIndex)
Returns the data Class for the specified column.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Parameters:
columnIndex - the column being queried
Returns:
the Class object for the column's data

getColumnName

public java.lang.String getColumnName(int column)
Returns the localized name for the column.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
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 interface FastComparableTableModel
Parameters:
rowIndex1 - zero-based model row index of first row to compare
rowIndex2 - zero-based model row index of second row to compare
columnIndex - 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)
Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel

getColumnCount

public int getColumnCount()
Returns the number of columns in the model.

Specified by:
getColumnCount in interface javax.swing.table.TableModel
Returns:
the number of columns in the model
See Also:
getRowCount()

getColumnWidth

public int getColumnWidth(int columnIndex)
Description copied from interface: ColumnSizingTableModel
Specifies the default initial width of a column from this model. Should only be queried at table creation time.

Specified by:
getColumnWidth in interface ColumnSizingTableModel
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)
Description copied from interface: ColumnSizingTableModel
Specifies whether setWidthToFit() should be enabled on this column.

Specified by:
isSizeToFit in interface ColumnSizingTableModel
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 interface javax.swing.table.TableModel
Returns:
the number of rows in the model
See Also:
getColumnCount()

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Returns the value for the cell at columnIndex and rowIndex.

Specified by:
getValueAt in interface javax.swing.table.TableModel
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried
Returns:
the value Object at the specified cell

getMessage

public AX25Frame getMessage(int rowIndex)
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:
java.lang.IndexOutOfBoundsException - if rowIndex not between 0 and the number of messages in the table

getMode

public RawPacketDisplayMode getMode()
Get the current message body rendering mode.

Returns:
current SnifferPacketDisplayMode enum

setMode

public void setMode(RawPacketDisplayMode mode)
Set the current message body rendering mode.

Parameters:
mode - the RawPacketDisplayMode to use for future rendering

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)
Adds a listener to the list that's notified each time a change to the data model occurs.

Specified by:
addTableModelListener in interface javax.swing.table.TableModel
Overrides:
addTableModelListener in class javax.swing.table.AbstractTableModel
Parameters:
l - the TableModelListener

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
Removes a listener from the list that's notified each time a change to the data model occurs.

Specified by:
removeTableModelListener in interface javax.swing.table.TableModel
Overrides:
removeTableModelListener in class javax.swing.table.AbstractTableModel
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 interface SnifferDataListener
Parameters:
firstRow - zero-based index of first message
lastRow - 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 interface SnifferDataListener
Parameters:
firstRow - zero-based index of first message
lastRow - zero-based index of last message

scheduleToGuiThread

public void scheduleToGuiThread(java.lang.Runnable r)
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 interface SnifferDataListener
Parameters:
r - Runnable to be scheduled as soon as possible on the GUI thread

deleteAllRows

public int deleteAllRows(ClearableTableModel.ClearType clearType)
Delete all rows from this table.

Specified by:
deleteAllRows in interface ClearableTableModel
Parameters:
clearType - type of rows to delete
Returns:
number of rows deleted