Package org.apache.log4j.chainsaw
Class MyTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- org.apache.log4j.chainsaw.MyTableModel
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.table.TableModel
class MyTableModel extends javax.swing.table.AbstractTableModel
Represents a list ofEventDetails
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 tableprivate static java.text.DateFormat
DATE_FORMATTER
used to format datesprivate static EventDetails[]
EMPTY_LIST
definition of an empty listprivate static Logger
LOG
used to log messagesprivate java.util.SortedSet
mAllEvents
set of all logged events - not filteredprivate java.lang.String
mCategoryFilter
filter for the categoryprivate EventDetails[]
mFilteredEvents
events that are visible after filteringprivate java.lang.Object
mLock
the lock to control accessprivate java.lang.String
mMessageFilter
filter for the messageprivate java.lang.String
mNDCFilter
filter for the NDCprivate boolean
mPaused
indicates whether event collection is paused to the UIprivate java.util.List
mPendingEvents
list of events that are buffered for processingprivate Priority
mPriorityFilter
filter for the priorityprivate java.lang.String
mThreadFilter
filter for the threadprivate static java.util.Comparator
MY_COMP
use the compare logging events
-
Constructor Summary
Constructors Constructor Description MyTableModel()
Creates a newMyTableModel
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 eventsprivate 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
-
-
-
-
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
-
-
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 interfacejavax.swing.table.TableModel
- Overrides:
getColumnName
in classjavax.swing.table.AbstractTableModel
- See Also:
TableModel
-
getColumnClass
public java.lang.Class getColumnClass(int aCol)
- Specified by:
getColumnClass
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnClass
in classjavax.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
- aEventDetails
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
-
-