Class MessageTableModel

  • All Implemented Interfaces:
    java.io.Serializable, javax.swing.table.TableModel

    public class MessageTableModel
    extends javax.swing.table.AbstractTableModel
    The table model for messages. It uses a sorted list to store the messages, cause the sequence of messages must be conserved regardless of their insertion time.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.List COLUMN_HEADERS
      List of all available column headers.
      protected SortedList messages
      SortedList of messages in table model.
      • Fields inherited from class javax.swing.table.AbstractTableModel

        listenerList
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean addMessage​(Message message)
      Add a message to the table
      void addMessages​(Message[] messages)
      Add an array of message to the table.
      boolean containsMessage​(Message message)
      Returns true if the message is in the table
      java.lang.Class getColumnClass​(int columnIndex)
      Returns the class of column columnIndex.
      int getColumnCount()
      Returns the number of columns in the model
      java.lang.String getColumnName​(int columnIndex)
      Returns the name for the column.
      Message getMessage​(int i)
      Returns the message at row i.
      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.
      void removeAllMessages()
      Remove all messages from table.
      boolean removeMessage​(Message message)
      Remove a message from the table.
      • Methods inherited from class javax.swing.table.AbstractTableModel

        addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COLUMN_HEADERS

        public static final java.util.List COLUMN_HEADERS
        List of all available column headers.
      • messages

        protected SortedList messages
        SortedList of messages in table model.
    • Constructor Detail

      • MessageTableModel

        public MessageTableModel()
    • Method Detail

      • addMessage

        public boolean addMessage​(Message message)
        Add a message to the table
        Parameters:
        message - The message to add.
        Returns:
        true if success
      • removeMessage

        public boolean removeMessage​(Message message)
        Remove a message from the table.
        Parameters:
        message - The message to remove.
        Returns:
        true if success
      • addMessages

        public void addMessages​(Message[] messages)
        Add an array of message to the table.
        Parameters:
        messages - The Array of messages to add.
      • removeAllMessages

        public void removeAllMessages()
        Remove all messages from table.
      • getColumnCount

        public int getColumnCount()
        Returns the number of columns in the model
        Returns:
        The number of columns in the model
      • getRowCount

        public int getRowCount()
        Returns the number of rows in the model.
        Returns:
        the number of rows in the model
      • getValueAt

        public java.lang.Object getValueAt​(int rowIndex,
                                           int columnIndex)
        Returns the value for the cell at columnIndex and rowIndex.
        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
      • getColumnName

        public java.lang.String getColumnName​(int columnIndex)
        Returns the 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 default name of column
      • getColumnClass

        public java.lang.Class getColumnClass​(int columnIndex)
        Returns the class of column columnIndex.
        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 of column columnIndex
      • containsMessage

        public boolean containsMessage​(Message message)
        Returns true if the message is in the table
        Parameters:
        message - The message queried
        Returns:
        true if the message exist
      • getMessage

        public Message getMessage​(int i)
        Returns the message at row i.
        Parameters:
        i - The row with the message.
        Returns:
        The message at row i.