de.qfs.apps.qflog
Class Model

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

public class Model
extends javax.swing.table.AbstractTableModel
implements java.util.Observer

The Model singleton of the qflog application doesn't do much, as it delegates most of its tasks to the ViewTableModel.

It does however keep track of the ids used for clients.

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

Field Summary
static int COL_ENTRIES
          Identifier for the entries column
static int COL_NAME
          Identifier for the name column
static int COL_STATE
          Identifier for the state column
static int COL_TIME
          Identifier for the time column
static int NUM_COLUMNS
          Number of table columns
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Method Summary
 void addView(LogView view)
          Add a new LogView to the ViewTableModel.
 void addView(de.qfs.apps.qflog.Model.ViewData data)
          Add a new ViewData to the ViewTableModel.
 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.
 javax.swing.JFrame getFrameForRow(int index)
          Get the LogFrame for a table row.
 LogListenerImpl getListener(int id)
          Get the LogListener registered under an id.
 de.qfs.lib.logrmi.RemoteLogLevelListener getLogLevelListener(int id)
          Get the LogLevelListener registered under an id.
 int getNewId(java.lang.String clientName)
          Generate a new id for a client and register the client's name under it.
 int getRowCount()
          Get the number of rows in the table.
 java.lang.Object getValueAt(int row, int column)
          Get a table cell value.
 LogView getViewForRow(int index)
          Get the LogView for a table row.
static Model instance()
          Get the singleton Model instance.
 void listenerDisconnected(LogListenerImpl listener)
          Notify the Model that a client has disconnected from a listener.
 void removeView(int index)
          Remove the view for a table row.
 void setListener(int id, LogListenerImpl listener)
          Set a listener for an id.
 void setLogLevelListener(int id, de.qfs.lib.logrmi.RemoteLogLevelListener listener)
          Set a LogLevelListener for an id.
 void update(java.util.Observable obs, java.lang.Object arg)
          Notify the ViewTableModel that the Options have changed.
 
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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUM_COLUMNS

public static final int NUM_COLUMNS
Number of table columns

COL_STATE

public static final int COL_STATE
Identifier for the state column

COL_NAME

public static final int COL_NAME
Identifier for the name column

COL_TIME

public static final int COL_TIME
Identifier for the time column

COL_ENTRIES

public static final int COL_ENTRIES
Identifier for the entries column
Method Detail

instance

public static Model instance()
Get the singleton Model instance.
Returns:
The Model.

getNewId

public int getNewId(java.lang.String clientName)
Generate a new id for a client and register the client's name under it.
Parameters:
clientName - The client's name.
Returns:
The client's id.

getListener

public LogListenerImpl getListener(int id)
Get the LogListener registered under an id.
Parameters:
id - The client's id.
Returns:
The LogListener.

setListener

public final void setListener(int id,
                              LogListenerImpl listener)
Set a listener for an id.
Parameters:
id - The id of the client.
listener - The listener to set.

listenerDisconnected

public void listenerDisconnected(LogListenerImpl listener)
Notify the Model that a client has disconnected from a listener.
Parameters:
listener - The disconnected listener.

getLogLevelListener

public de.qfs.lib.logrmi.RemoteLogLevelListener getLogLevelListener(int id)
Get the LogLevelListener registered under an id.
Parameters:
id - The client's id.
Returns:
The LogLevelListener.

setLogLevelListener

public void setLogLevelListener(int id,
                                de.qfs.lib.logrmi.RemoteLogLevelListener listener)
Set a LogLevelListener for an id.
Parameters:
id - The client's id.
listener - The LogLevelListener to set.

addView

public void addView(LogView view)
Add a new LogView to the ViewTableModel.
Parameters:
view - The LogView to add.

getViewForRow

public LogView getViewForRow(int index)
Get the LogView for a table row.
Parameters:
index - The view's row index.
Returns:
The view for the row.

getFrameForRow

public javax.swing.JFrame getFrameForRow(int index)
Get the LogFrame for a table row. If the view for that row doesn't have a LogFrame yet, a new one is created.
Parameters:
index - The view's row index.
Returns:
The view's LogFrame.

removeView

public void removeView(int index)
Remove the view for a table row.
Parameters:
index - The index of the row.

addView

public void addView(de.qfs.apps.qflog.Model.ViewData data)
Add a new ViewData to the ViewTableModel.
Parameters:
data - The ViewData to add.

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.

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.

getColumnCount

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

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.
Overrides:
getValueAt in class javax.swing.table.AbstractTableModel
Parameters:
row - The row index.
column - The column index.
Returns:
The value of the cell, currently a String for all columns.

update

public void update(java.util.Observable obs,
                   java.lang.Object arg)
Notify the ViewTableModel that the Options have changed. This may lead to listeners being removed to satisfy the constraints.
Specified by:
update in interface java.util.Observer
Parameters:
obs - The observable, i.e. the logserver Options.
arg - An argument to notifyObservers, ignored.