DESY ACOP Beans Home

com.cosylab.gui.components.table
Class QueueTableModelInterceptor

java.lang.Object
  extended by com.cosylab.gui.components.table.QueueTableModelInterceptor
All Implemented Interfaces:
java.lang.Runnable, java.util.EventListener, javax.swing.event.TableModelListener, javax.swing.table.TableModel

public class QueueTableModelInterceptor
extends java.lang.Object
implements javax.swing.table.TableModel, javax.swing.event.TableModelListener, java.lang.Runnable

QueueTableModelInterceptor wraps around TableModel and intercepts update events. All events are queued and dispatched in AWT thread. Similar events are integrated into one event. This makes updates from delegate GUI thread safe and prevents table to be updated unnecessary.

Tu use interceptor, create your model, create interceptor and pass your model as parameter, then add to the table interceptor as model. Listen to model events directly on your model and not on interceptor or on model, which is rerturned from the table (except if QueueTable becouse it completly hides the interceptor).

Since:
May 3, 2004.
Version:
$Id: QueueTableModelInterceptor.java,v 1.11 2008-08-25 11:18:22 jbobnar Exp $
Author:
Igor Kriznar

Constructor Summary
QueueTableModelInterceptor(javax.swing.table.TableModel delegate)
          Creates a new QueueTableModelInterceptor object.
 
Method Summary
 void addTableModelListener(javax.swing.event.TableModelListener l)
           
protected  javax.swing.event.TableModelEvent dequeue()
           
 void destroy()
          Clears internal interceptor thread.
protected  void enqueue(javax.swing.event.TableModelEvent e)
           
protected  void fire(javax.swing.event.TableModelEvent e)
           
 java.lang.Class<?> getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 java.lang.String getColumnName(int columnIndex)
           
 javax.swing.table.TableModel getDelegate()
          The model which is wrapped by this interceptor.
 int getRelaxationTime()
          Returns minimum time betwean two table updates interceptor will wait.
 int getRowCount()
           
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
           
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 boolean isDestroyed()
          Returns true after destroy was called.
 void removeTableModelListener(javax.swing.event.TableModelListener l)
           
 void run()
           
 void setRelaxationTime(int relaxationTime)
          Sets minimum time betwean two table updates interceptor will wait.
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
           
 void tableChanged(javax.swing.event.TableModelEvent e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueueTableModelInterceptor

public QueueTableModelInterceptor(javax.swing.table.TableModel delegate)
Creates a new QueueTableModelInterceptor object.

Parameters:
delegate - the wrapped model
Method Detail

getColumnCount

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

getRowCount

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

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface javax.swing.table.TableModel

getColumnClass

public java.lang.Class<?> getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface javax.swing.table.TableModel

getValueAt

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

setValueAt

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

getColumnName

public java.lang.String getColumnName(int columnIndex)
Specified by:
getColumnName in interface javax.swing.table.TableModel

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)
Specified by:
addTableModelListener in interface javax.swing.table.TableModel

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
Specified by:
removeTableModelListener in interface javax.swing.table.TableModel

getDelegate

public javax.swing.table.TableModel getDelegate()
The model which is wrapped by this interceptor.

Returns:

tableChanged

public void tableChanged(javax.swing.event.TableModelEvent e)
Specified by:
tableChanged in interface javax.swing.event.TableModelListener

fire

protected void fire(javax.swing.event.TableModelEvent e)

enqueue

protected void enqueue(javax.swing.event.TableModelEvent e)

dequeue

protected javax.swing.event.TableModelEvent dequeue()

run

public void run()
Specified by:
run in interface java.lang.Runnable

getRelaxationTime

public int getRelaxationTime()
Returns minimum time betwean two table updates interceptor will wait.

Returns:
minimum time betwean two table updates

setRelaxationTime

public void setRelaxationTime(int relaxationTime)
Sets minimum time betwean two table updates interceptor will wait.

Parameters:
relaxationTime -

isDestroyed

public boolean isDestroyed()
Returns true after destroy was called.

Returns:
true if destroyed

destroy

public void destroy()
Clears internal interceptor thread.



Copyright © 2010. All Rights Reserved.