no.ntnu.vegare.visualizer.client.db
Class LogEntrySet

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by no.ntnu.vegare.visualizer.client.db.LogEntrySet
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel, DatabaseObserver

public class LogEntrySet
extends javax.swing.table.AbstractTableModel
implements DatabaseObserver

Collection of log entries. Works as a table model, feeding the overview screen and the filter view automatically, if used correctly.

You can use either setQueryFilter() to modify content according to rules, or setEntries() to set a specific set.

Author:
vegare
See Also:
Serialized Form

Field Summary
 java.lang.Object logEntryLock
           
 
Constructor Summary
LogEntrySet(AbstractLogDatabase db)
          Create a new log entry collection, based on a database instance
 
Method Summary
 void entriesAdded(java.util.Collection<LogEntry> entries)
          New entries has been added to the database.
 int getColumnCount()
           
 java.lang.String getColumnName(int col)
           
 int getCurrentTime()
          This is not the current system time, but rather the time the entry set is located at.
 java.util.Collection<LogEntry> getEntries()
           
 LogEntry getEntry(int row)
           
 int getRowCount()
           
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
           
 boolean isLive()
           
 void setCurrentTime(int currentTime)
          Set the current time watched by the user.
 void setEntries(java.util.Collection<LogEntry> entries)
          When a entry set is set, the entire model is invalidated and fetched from the database.
 void setQueryFilter(QueryFilter filter)
          When a new query filter is set, the entire model is invalidated and fetched from the database.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logEntryLock

public final java.lang.Object logEntryLock
Constructor Detail

LogEntrySet

public LogEntrySet(AbstractLogDatabase db)
Create a new log entry collection, based on a database instance

Parameters:
db - Database instance
Method Detail

getEntry

public LogEntry getEntry(int row)
Parameters:
row - Row number in current log entry set
Returns:
Corresponding row

setQueryFilter

public void setQueryFilter(QueryFilter filter)

When a new query filter is set, the entire model is invalidated and fetched from the database. Used when the user specified a filter, or when the application only needs a subset.


setEntries

public void setEntries(java.util.Collection<LogEntry> entries)

When a entry set is set, the entire model is invalidated and fetched from the database. Used when the user or software wants a specific set of entries, rather than a rule based collection.

Parameters:
entries -

isLive

public boolean isLive()
Returns:
Whether the entry set is receiving live updates

getEntries

public java.util.Collection<LogEntry> getEntries()
Returns:
All log entries

entriesAdded

public void entriesAdded(java.util.Collection<LogEntry> entries)
Description copied from interface: DatabaseObserver
New entries has been added to the database.

Specified by:
entriesAdded in interface DatabaseObserver
Parameters:
entries - Collection of entries.

getCurrentTime

public int getCurrentTime()

This is not the current system time, but rather the time the entry set is located at. If we are watching a historical overview, this method returns the time of observation.

Returns:
The current time of the entry set.

setCurrentTime

public void setCurrentTime(int currentTime)

Set the current time watched by the user.

Parameters:
currentTime - Time specified by user.

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface javax.swing.table.TableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface javax.swing.table.TableModel

getColumnName

public java.lang.String getColumnName(int col)
Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Specified by:
getValueAt in interface javax.swing.table.TableModel