Class MyTableModel

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

    class MyTableModel
    extends javax.swing.table.AbstractTableModel
    Represents a list of EventDetails objects that are sorted on logging time. Methods are provided to filter the events that are visible.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  MyTableModel.Processor
      Helper that actually processes incoming events.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String[] COL_NAMES
      names of the columns in the table
      private static java.text.DateFormat DATE_FORMATTER
      used to format dates
      private static EventDetails[] EMPTY_LIST
      definition of an empty list
      private static Logger LOG
      used to log messages
      private java.util.SortedSet mAllEvents
      set of all logged events - not filtered
      private java.lang.String mCategoryFilter
      filter for the category
      private EventDetails[] mFilteredEvents
      events that are visible after filtering
      private java.lang.Object mLock
      the lock to control access
      private java.lang.String mMessageFilter
      filter for the message
      private java.lang.String mNDCFilter
      filter for the NDC
      private boolean mPaused
      indicates whether event collection is paused to the UI
      private java.util.List mPendingEvents
      list of events that are buffered for processing
      private Priority mPriorityFilter
      filter for the priority
      private java.lang.String mThreadFilter
      filter for the thread
      private static java.util.Comparator MY_COMP
      use the compare logging events
      • Fields inherited from class javax.swing.table.AbstractTableModel

        listenerList
    • Constructor Summary

      Constructors 
      Constructor Description
      MyTableModel()
      Creates a new MyTableModel instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEvent​(EventDetails aEvent)
      Add an event to the list.
      void clear()
      Clear the list of all events.
      java.lang.Class getColumnClass​(int aCol)  
      int getColumnCount()  
      java.lang.String getColumnName​(int aCol)  
      EventDetails getEventDetails​(int aRow)
      Get the throwable information at a specified row in the filtered events.
      int getRowCount()  
      java.lang.Object getValueAt​(int aRow, int aCol)  
      boolean isPaused()  
      private boolean matchFilter​(EventDetails aEvent)
      Returns whether an event matches the filters.
      void setCategoryFilter​(java.lang.String aStr)
      Set the filter for the category field.
      void setMessageFilter​(java.lang.String aStr)
      Set the filter for the message field.
      void setNDCFilter​(java.lang.String aStr)
      Set the filter for the NDC field.
      void setPriorityFilter​(Priority aPriority)
      Sets the priority to filter events on.
      void setThreadFilter​(java.lang.String aStr)
      Set the filter for the thread field.
      void toggle()
      Toggle whether collecting events
      private void updateFilteredEvents​(boolean aInsertedToFront)
      Update the filtered events data structure.
      • 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

      • LOG

        private static final Logger LOG
        used to log messages
      • MY_COMP

        private static final java.util.Comparator MY_COMP
        use the compare logging events
      • COL_NAMES

        private static final java.lang.String[] COL_NAMES
        names of the columns in the table
      • EMPTY_LIST

        private static final EventDetails[] EMPTY_LIST
        definition of an empty list
      • DATE_FORMATTER

        private static final java.text.DateFormat DATE_FORMATTER
        used to format dates
      • mLock

        private final java.lang.Object mLock
        the lock to control access
      • mAllEvents

        private final java.util.SortedSet mAllEvents
        set of all logged events - not filtered
      • mFilteredEvents

        private EventDetails[] mFilteredEvents
        events that are visible after filtering
      • mPendingEvents

        private final java.util.List mPendingEvents
        list of events that are buffered for processing
      • mPaused

        private boolean mPaused
        indicates whether event collection is paused to the UI
      • mThreadFilter

        private java.lang.String mThreadFilter
        filter for the thread
      • mMessageFilter

        private java.lang.String mMessageFilter
        filter for the message
      • mNDCFilter

        private java.lang.String mNDCFilter
        filter for the NDC
      • mCategoryFilter

        private java.lang.String mCategoryFilter
        filter for the category
      • mPriorityFilter

        private Priority mPriorityFilter
        filter for the priority
    • Constructor Detail

      • MyTableModel

        MyTableModel()
        Creates a new MyTableModel instance.
    • Method Detail

      • getRowCount

        public int getRowCount()
        See Also:
        TableModel
      • getColumnCount

        public int getColumnCount()
        See Also:
        TableModel
      • getColumnName

        public java.lang.String getColumnName​(int aCol)
        Specified by:
        getColumnName in interface javax.swing.table.TableModel
        Overrides:
        getColumnName in class javax.swing.table.AbstractTableModel
        See Also:
        TableModel
      • getColumnClass

        public java.lang.Class getColumnClass​(int aCol)
        Specified by:
        getColumnClass in interface javax.swing.table.TableModel
        Overrides:
        getColumnClass in class javax.swing.table.AbstractTableModel
        See Also:
        TableModel
      • getValueAt

        public java.lang.Object getValueAt​(int aRow,
                                           int aCol)
        See Also:
        TableModel
      • setPriorityFilter

        public void setPriorityFilter​(Priority aPriority)
        Sets the priority to filter events on. Only events of equal or higher property are now displayed.
        Parameters:
        aPriority - the priority to filter on
      • setThreadFilter

        public void setThreadFilter​(java.lang.String aStr)
        Set the filter for the thread field.
        Parameters:
        aStr - the string to match
      • setMessageFilter

        public void setMessageFilter​(java.lang.String aStr)
        Set the filter for the message field.
        Parameters:
        aStr - the string to match
      • setNDCFilter

        public void setNDCFilter​(java.lang.String aStr)
        Set the filter for the NDC field.
        Parameters:
        aStr - the string to match
      • setCategoryFilter

        public void setCategoryFilter​(java.lang.String aStr)
        Set the filter for the category field.
        Parameters:
        aStr - the string to match
      • addEvent

        public void addEvent​(EventDetails aEvent)
        Add an event to the list.
        Parameters:
        aEvent - a EventDetails value
      • clear

        public void clear()
        Clear the list of all events.
      • toggle

        public void toggle()
        Toggle whether collecting events
      • isPaused

        public boolean isPaused()
        Returns:
        whether currently paused collecting events
      • getEventDetails

        public EventDetails getEventDetails​(int aRow)
        Get the throwable information at a specified row in the filtered events.
        Parameters:
        aRow - the row index of the event
        Returns:
        the throwable information
      • updateFilteredEvents

        private void updateFilteredEvents​(boolean aInsertedToFront)
        Update the filtered events data structure.
        Parameters:
        aInsertedToFront - indicates whether events were added to front of the events. If true, then the current first event must still exist in the list after the filter is applied.
      • matchFilter

        private boolean matchFilter​(EventDetails aEvent)
        Returns whether an event matches the filters.
        Parameters:
        aEvent - the event to check for a match
        Returns:
        whether the event matches