de.qfs.apps.qflog.logview
Class LogTableModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--de.qfs.apps.qflog.logview.LogTableModel

public class LogTableModel
extends javax.swing.table.AbstractTableModel
implements de.qfs.lib.log.LogUser

This is a TableModel for LogEntries.

Version:
$Revision: 1.16 $
Author:
Gregor Schmid
See Also:
Serialized Form

Field Summary
static int COL_CLASS
          Index for the class column.
static int COL_DETAIL
          Index for the message column.
static int COL_ENTRY
          Pseudo index for the LogEntry column.
static int COL_LEVEL
          Index for the level column.
static int COL_METHOD
          Index for the method column.
static int COL_THREAD
          Index for the thread column.
static int COL_TIME
          Index for the timestamp column.
static int NUM_COLUMNS
          Number of columns
protected  de.qfs.apps.qflog.logview.LogTableModel.Updater updater
          Background thread that updates the table's data.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface de.qfs.lib.log.LogUser
FILTER_ALL, FILTER_NONE, FILTER_UNUSED, FILTER_USED
 
Constructor Summary
LogTableModel()
          Create a new LogTableModel.
 
Method Summary
 void cleanup()
          Remove all data and terminate the Updater thread.
 boolean filter(de.qfs.lib.log.LogEntry logEntry)
          Add a LogEntry to the table's data.
 de.qfs.lib.log.LogEntry[] filter(de.qfs.lib.log.LogEntry[] entries)
          Add some LogEntries to the table's data.
 void finalize()
          Finalize the LogTableModel.
 java.lang.Class getColumnClass(int column)
          Get a common base class for elements from one column.
 int getColumnCount()
          Get the number of columns in the table.
 java.lang.String getColumnName(int column)
          Get the name of a column.
 de.qfs.lib.log.LogEntry[] getData()
          Get the whole table data.
 int getDeleted()
          Get the number of deleted rows.
 de.qfs.lib.log.LogEntry getEntry(int row)
          Get an entry from the table.
 int getMaxRows()
          Get the maximum number of rows of the LogTableModel.
 int getRowCount()
          Get the number of rows in the table.
 java.lang.Object getValueAt(int row, int column)
          Get a table cell value.
 void reduceToVisible(de.qfs.lib.gui.TableModelFilter filter)
          Remove all invisible Rows from the table.
 void removeVisible(de.qfs.lib.gui.TableModelFilter filter)
          Remove all visible Rows from the table.
 void setColumnNames(java.lang.String[] names)
          Set the names for the table columns.
 void setData(de.qfs.lib.log.LogEntry[] data)
          Reset the table's date to a whole new set of LogEntries.
 void setFilterMode(int mode)
          Configure the LogUser's filter mode.
 void setLoggingEnabled(boolean enable)
          Enable or disable logging output caused directly or indirectly by LogTableModel methods.
 void setMaxRows(int maxRows)
          Set the maximum number of rows of the LogTableModel.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COL_LEVEL

public static final int COL_LEVEL
Index for the level column.

COL_TIME

public static final int COL_TIME
Index for the timestamp column.

COL_THREAD

public static final int COL_THREAD
Index for the thread column.

COL_CLASS

public static final int COL_CLASS
Index for the class column.

COL_METHOD

public static final int COL_METHOD
Index for the method column.

COL_DETAIL

public static final int COL_DETAIL
Index for the message column.

NUM_COLUMNS

public static final int NUM_COLUMNS
Number of columns

COL_ENTRY

public static final int COL_ENTRY
Pseudo index for the LogEntry column.

updater

protected de.qfs.apps.qflog.logview.LogTableModel.Updater updater
Background thread that updates the table's data.
Constructor Detail

LogTableModel

public LogTableModel()
Create a new LogTableModel.
Method Detail

setColumnNames

public void setColumnNames(java.lang.String[] names)
Set the names for the table columns.
Parameters:
names - A 6 element String array containing the column titles in the order level, time, thread, class, method, message.

setLoggingEnabled

public final void setLoggingEnabled(boolean enable)
Enable or disable logging output caused directly or indirectly by LogTableModel methods. If logging is disabled, all calls to methods that might create log messages will be protected with de.qfs.lib.log.Log.excludeThread. This is necessary, if the LogFilterTreeModel is used inside the application whose logs it is supposed to filter.

The default value is false.

Parameters:
enable - True to enable logging, false to disable it.

getEntry

public de.qfs.lib.log.LogEntry getEntry(int row)
Get an entry from the table.
Parameters:
row - The entry's row.
Returns:
The entry from the row.

getData

public de.qfs.lib.log.LogEntry[] getData()
Get the whole table data.
Returns:
An array of all LogEntries of the table.

setData

public void setData(de.qfs.lib.log.LogEntry[] data)
Reset the table's date to a whole new set of LogEntries.
Parameters:
data - The new table data.

getDeleted

public int getDeleted()
Get the number of deleted rows.

getMaxRows

public final int getMaxRows()
Get the maximum number of rows of the LogTableModel. When new data arrives and the maximum is exceeded, the oldest messages will be removed.
Returns:
The maximum number of rows of the LogTableModel. 0 means unlimited.

setMaxRows

public final void setMaxRows(int maxRows)
Set the maximum number of rows of the LogTableModel. When new data arrives and the maximum is exceeded, the oldest messages will be removed.
Parameters:
maxRows - The new maximum number of rows. 0 means unlimited.

reduceToVisible

public void reduceToVisible(de.qfs.lib.gui.TableModelFilter filter)
Remove all invisible Rows from the table.
Parameters:
filter - The filter that decides which rows to keep.

removeVisible

public void removeVisible(de.qfs.lib.gui.TableModelFilter filter)
Remove all visible Rows from the table.
Parameters:
filter - The filter that decides which rows to keep.

cleanup

public void cleanup()
Remove all data and terminate the Updater thread.

getColumnName

public java.lang.String getColumnName(int column)
Get the name of a column.
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
column - The column to query.
Returns:
The name of the column.

getColumnCount

public int getColumnCount()
Get the number of columns in the table.
Overrides:
getColumnCount in class javax.swing.table.AbstractTableModel
Returns:
The number of columns.

getColumnClass

public java.lang.Class getColumnClass(int column)
Get a common base class for elements from one column.
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Parameters:
column - The column to query.
Returns:
The class for the elements.

getRowCount

public int getRowCount()
Get the number of rows in the table.
Overrides:
getRowCount in class javax.swing.table.AbstractTableModel
Returns:
The number of rows.

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Get a table cell value. Supports a pseudo column with index COL_ENTRY. The whole LogEntry will be rturned for this column.
Overrides:
getValueAt in class javax.swing.table.AbstractTableModel
Parameters:
row - The row index.
column - The column index.
Returns:
The value of the cell.

filter

public boolean filter(de.qfs.lib.log.LogEntry logEntry)
Add a LogEntry to the table's data.
Parameters:
logEntry - The entry to add.
Returns:
Depends on the mode set with setFilterMode.

filter

public de.qfs.lib.log.LogEntry[] filter(de.qfs.lib.log.LogEntry[] entries)
Add some LogEntries to the table's data.
Parameters:
entries - The entries to add.
Returns:
Depends on the mode set with setFilterMode.

setFilterMode

public final void setFilterMode(int mode)
Configure the LogUser's filter mode. The default value is LogUser.FILTER_ALL.
Specified by:
setFilterMode in interface de.qfs.lib.log.LogUser
Parameters:
mode - The mode to set. LogUser.FILTER_USED and LogUser.FILTER_ALL will cause all entries to be eaten, LogUser.FILTER_NONE and LogUser.FILTER_UNUSEDwill let all entries pass.

finalize

public void finalize()
Finalize the LogTableModel.
Overrides:
finalize in class java.lang.Object