cmu.survey.data
Class DataTableModelSingularInfo<DTM extends DataTableModel>

java.lang.Object
  extended by cmu.survey.data.DataTableModelSingularInfo<DTM>

public class DataTableModelSingularInfo<DTM extends DataTableModel>
extends java.lang.Object

The information about a data table that is independent of its views. i.e. if there are many views of a table, there should still be just one of these classes, which will handle all view updates, etc.


Field Summary
protected  java.util.Vector<DTM> allTableModels
          All copies of the table that are currently open.
protected  int holdFiredTableChangeEvents
           
protected  int levelOfEventsHeld
           
protected  java.util.Vector<javax.swing.event.TableModelListener> listenerList
          All TableModelListeners added to any DataTableModel
protected  TableFormat tableFormat
          The prototype/design of the table.
protected  java.lang.String tableName
           
 
Constructor Summary
DataTableModelSingularInfo(java.lang.String tableName)
           
DataTableModelSingularInfo(TableFormat tableFormat)
           
 
Method Summary
 void addGUIListener(DataTableModel.DataTableModelGUIListener listener)
           
 void addOneLock(java.lang.String description)
          Start holding the firing of events -- add one more thing that's holding this.
 void addTable(DTM table)
           
 void addTableModelListener(javax.swing.event.TableModelListener l)
          Adds a listener to the list that's notified each time a change to the data model occurs.
 void close()
          Close all DataTableModels here.
 void fireTableCellUpdated(int r, int r2, DTM firedFrom)
           
 void fireTableChanged(javax.swing.event.TableModelEvent e)
          Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model.
 void fireTableDataChanged(DTM firedFrom)
           
 void fireTableRowsDeleted(int r, int r2, DTM firedFrom)
           
 void fireTableRowsInserted(int r, int r2, DTM firedFrom)
          the following methods may have a distinction in the future, but since we don't know which rows were changed across all models, we fire only one event.
 void fireTableRowsUpdated(int r, int r2, DTM firedFrom)
           
 void fireTableStructureChanged(DataTableModel firedFrom)
           
 TableFormat getTableFormat()
           
 java.lang.String getTableName()
           
 boolean isLocked()
          Whether there is currently a lock on this table -- i.e.
 boolean removeGUIListener(DataTableModel.DataTableModelGUIListener listener)
           
 void removeOneLock(DTM firedFrom)
          Remove one hold from firing events.
 void removeTable(DTM table)
           
 void removeTableModelListener(javax.swing.event.TableModelListener l)
          Removes a listener from the list that's notified each time a change to the data model occurs.
 void setTableFormat(TableFormat tableFormat)
           
 void tableRenamed(java.lang.String newTableName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

allTableModels

protected java.util.Vector<DTM extends DataTableModel> allTableModels
All copies of the table that are currently open.


listenerList

protected java.util.Vector<javax.swing.event.TableModelListener> listenerList
All TableModelListeners added to any DataTableModel


tableFormat

protected TableFormat tableFormat
The prototype/design of the table. This is an optional thing you can use, but if you use it, the table will automatically get created and upgraded when it's needed, and only when it's needed.


tableName

protected java.lang.String tableName

holdFiredTableChangeEvents

protected int holdFiredTableChangeEvents

levelOfEventsHeld

protected int levelOfEventsHeld
Constructor Detail

DataTableModelSingularInfo

public DataTableModelSingularInfo(java.lang.String tableName)

DataTableModelSingularInfo

public DataTableModelSingularInfo(TableFormat tableFormat)
Method Detail

addTable

public void addTable(DTM table)

removeTable

public void removeTable(DTM table)

addGUIListener

public void addGUIListener(DataTableModel.DataTableModelGUIListener listener)

removeGUIListener

public boolean removeGUIListener(DataTableModel.DataTableModelGUIListener listener)

tableRenamed

public void tableRenamed(java.lang.String newTableName)

getTableName

public java.lang.String getTableName()

getTableFormat

public TableFormat getTableFormat()

setTableFormat

public void setTableFormat(TableFormat tableFormat)

isLocked

public boolean isLocked()
Whether there is currently a lock on this table -- i.e. UI events should not be sent, the GUI should not be updated, and new processes that are long should not start yet -- they should wait for this to complete before starting a new long operation which will read or modify the data.

Returns:

removeOneLock

public void removeOneLock(DTM firedFrom)
Remove one hold from firing events. If the number of holds goes down to zero, it will fire one similar event to those that were held, to let the table know that something's changed.


addOneLock

public void addOneLock(java.lang.String description)
Start holding the firing of events -- add one more thing that's holding this. This means that GUIs will not be updated of data changed or columns added, which is a hack around a pile of "bugs" in JTable that fail when many rapid updates happen from another gui. (i.e. JTable throws lots of exceptions because it fails in the middle of repainting because it does repaints and stuff immediately, I think). If you add one, you MUST remove it, at all costs! Else the GUI will fail unpredictably and badly. TODO WARNING: this is a hack. The correct implementation would have listeners for each GUI, and the GUIs would lock the interface when this happens.

Parameters:
holdFiredTableChangeEvents -

fireTableChanged

public void fireTableChanged(javax.swing.event.TableModelEvent e)
Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model.

Parameters:
e - the event to be forwarded
See Also:
addTableModelListener(javax.swing.event.TableModelListener), TableModelEvent, EventListenerList

fireTableDataChanged

public void fireTableDataChanged(DTM firedFrom)

fireTableStructureChanged

public void fireTableStructureChanged(DataTableModel firedFrom)

fireTableRowsInserted

public void fireTableRowsInserted(int r,
                                  int r2,
                                  DTM firedFrom)
the following methods may have a distinction in the future, but since we don't know which rows were changed across all models, we fire only one event.


fireTableRowsUpdated

public void fireTableRowsUpdated(int r,
                                 int r2,
                                 DTM firedFrom)

fireTableRowsDeleted

public void fireTableRowsDeleted(int r,
                                 int r2,
                                 DTM firedFrom)

fireTableCellUpdated

public void fireTableCellUpdated(int r,
                                 int r2,
                                 DTM firedFrom)

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)
Adds a listener to the list that's notified each time a change to the data model occurs.

Parameters:
l - the TableModelListener

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
Removes a listener from the list that's notified each time a change to the data model occurs.

Parameters:
l - the TableModelListener

close

public void close()
Close all DataTableModels here.