com.jstatcom.table
Class JSCAbstractTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.jstatcom.table.JSCAbstractTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel
Direct Known Subclasses:
JSCNArrayTableModel, JSCSArrayTableModel

public abstract class JSCAbstractTableModel
extends javax.swing.table.AbstractTableModel

A table model to be used with JSCAbstractDataTable instances. It implements a listener to the underlying symbol that translates symbol events to table model events. Subclasses can reference the current symbol via getCurrentSymbol. Implementations of the methods getRowCount, getColumnCount and getValueAt should take the transposed property into account to provide a transposed view to the underlying data without changin it.

Author:
Markus Kraetzig
See Also:
Serialized Form

Constructor Summary
JSCAbstractTableModel(Symbol symbol)
          Creates a table model for a symbol.
 
Method Summary
 java.util.Map<java.lang.Integer,java.lang.Boolean> getColIndexEditableMap()
          Gets the current mapping from column indices to editable properties.
 JSCData getJSCData()
          Gets the JSCData object represented by this model.
 java.util.Map<java.lang.Integer,java.lang.Boolean> getRowIndexEditableMap()
          Gets the current mapping from row indices to editable properties.
 boolean isCellEditable(int rowIndex, int columnIndex)
          Overwrites default implementation to return isEditable for all cells.
 boolean isEditable()
          Gets whether all cells are editable.
 void setColEditableMap(java.util.Map<java.lang.Integer,java.lang.Boolean> colIndexEditableMap)
          Sets the editable properties for each column.
 void setEditable(boolean isEditable)
          Sets whether all cells are editable.
 void setRowEditableMap(java.util.Map<java.lang.Integer,java.lang.Boolean> rowIndexEditableMap)
          Sets the editable properties for each row.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
getColumnCount, getRowCount, getValueAt
 

Constructor Detail

JSCAbstractTableModel

public JSCAbstractTableModel(Symbol symbol)
Creates a table model for a symbol. It installs a symbol listener if symbol != null that translates symbol events into table model events.

Subclasses should provide a type check for the symbol.

Parameters:
symbol - the symbol to represent data for the model
Method Detail

getJSCData

public final JSCData getJSCData()
Gets the JSCData object represented by this model. The type of the data depends on the implementation.

Usage note:
The returned data is a reference to the underlying JSCData object only until a new data object has been set. It should be used read only. Changes that should not affect this model must be made on a copy of the returned object.

Returns:
JSCData represented by this model

isEditable

public final boolean isEditable()
Gets whether all cells are editable. The default is true.

Returns:
true if editable

setEditable

public final void setEditable(boolean isEditable)
Sets whether all cells are editable.

Parameters:
isEditable - true if editable

setColEditableMap

public void setColEditableMap(java.util.Map<java.lang.Integer,java.lang.Boolean> colIndexEditableMap)
Sets the editable properties for each column. This overwrites the overall editable settings.

Parameters:
colIndexEditableMap -

setRowEditableMap

public void setRowEditableMap(java.util.Map<java.lang.Integer,java.lang.Boolean> rowIndexEditableMap)
Sets the editable properties for each row. This overwrites the overall editable settings.

Parameters:
rowIndexEditableMap -

getColIndexEditableMap

public java.util.Map<java.lang.Integer,java.lang.Boolean> getColIndexEditableMap()
Gets the current mapping from column indices to editable properties.

Returns:
editable map

getRowIndexEditableMap

public java.util.Map<java.lang.Integer,java.lang.Boolean> getRowIndexEditableMap()
Gets the current mapping from row indices to editable properties.

Returns:
editable map

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Overwrites default implementation to return isEditable for all cells. The row index map overwrites all other settings for all row indices with non-null elements.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel
Parameters:
rowIndex - used if (getRowIndexEditableMap() != null), row settings overwrite overall editable property, null elements fall back to global editable property
columnIndex - used if (getColIndexEditableMap() != null), column settings overwrite overall editable property, null elements fall back to global editable property