JIDE 3.5.15

com.jidesoft.grid
Class TableModelWrapperImpl

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.jidesoft.grid.TableModelWrapperImpl
All Implemented Interfaces:
ColumnIdentifierTableModel, ContextSensitiveTableModel, EditorStyleTableModel, IndexChangeEventGenerator, MultiTableModel, NavigableModel, SpanModel, StyleModel, TableModelWrapper, Serializable, EventListener, TableModelListener, TableModel
Direct Known Subclasses:
BatchedCrudTableModelWrapper, CachedTableModel, CrudTableModelAdapter, DefaultTableModelWrapper

public class TableModelWrapperImpl
extends AbstractTableModel
implements ColumnIdentifierTableModel, TableModelWrapper, ContextSensitiveTableModel, StyleModel, SpanModel, NavigableModel, MultiTableModel, TableModelListener, IndexChangeEventGenerator, EditorStyleTableModel

The default implementation of TableModelWrapper.

Note: This class should be named as DefaultTableModelWrapper but the name was taken and is too much trouble to change.

See Also:
Serialized Form

Field Summary
protected  TableModel _model
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface com.jidesoft.grid.MultiTableModel
FOOTER_COLUMN, HEADER_COLUMN, REGULAR_COLUMN
 
Fields inherited from interface com.jidesoft.grid.EditorStyleTableModel
EDITOR_STYLE_EDITABLE, EDITOR_STYLE_NORMAL, EDITOR_STYLE_READ_ONLY, EDITOR_STYLE_SELECT_ONLY
 
Constructor Summary
TableModelWrapperImpl(TableModel model)
          Creates a DefaultTableModelWrapper from any table model.
 
Method Summary
 void addIndexChangeListener(IndexChangeListener l)
          Add IndexChangelistener.
protected  CompoundTableModelEvent createCompoundTableModelEvent()
          Creates a CompoundTableModelEvent instance.
protected  void fireIndexChanged(int eventSerialNumber)
          Tells the TableModeWrapper that indexes is changed.
protected  int fireIndexChanging()
          Tells the TableModeWrapper that indexes is going to be changed.
 void fireTableCellsUpdated(int firstRow, int lastRow, int column)
          Called each time the cells in column in the range [firstRow, lastRow] are updated.
 void fireTableChanged(TableModelEvent e)
           
 TableModel getActualModel()
          Gets the actual table model.
 Class<?> getCellClassAt(int row, int column)
          Gets the cell class of the underlying table model.
 CellSpan getCellSpanAt(int rowIndex, int columnIndex)
          Gets cell span of the underlying table model.
 CellStyle getCellStyleAt(int row, int column)
          Returns null all the time unless you override this method to return a cell style.
 Class<?> getColumnClass(int column)
           
 int getColumnCount()
           
 Object getColumnIdentifier(int column)
          Returns the identifier of the column in the model.
 String getColumnName(int column)
           
 int getColumnType(int columnIndex)
          Checks if the column at the columnIndex is a header column or footer column or just regular column.
 ConverterContext getConverterContextAt(int row, int column)
          Gets the converter context of the underlying table model.
 EditorContext getEditorContextAt(int row, int column)
          Gets the editor context of the underlying table model.
 int getEditorStyleAt(int rowIndex, int columnIndex)
          Gets editor style at the cell.
 IndexChangeListener[] getIndexChangeListeners()
          Returns an array of all the IndexChangeListeners
 int getRowCount()
           
 int getTableIndex(int columnIndex)
          Gets the table index that this column belongs to.
 Object getValueAt(int row, int column)
           
 boolean isCellEditable(int row, int column)
           
 boolean isCellSpanOn()
          Delegates to underlying table model for cell span information.
 boolean isCellStyleOn()
          Returns false all the time unless you override this method to return true.
 boolean isNavigableAt(int rowIndex, int columnIndex)
          it return true by default.
 boolean isNavigationOn()
          It returns false.
 void removeIndexChangeListener(IndexChangeListener l)
          Remove IndexChangelistener.
 void setValueAt(Object value, int row, int column)
           
protected  void tableCellsUpdated(int column, int firstRow, int lastRow)
          Called each time the cells in column in the range [firstRow, lastRow] are updated.
 void tableChanged(TableModelEvent e)
          Implementation of the TableChangeListener interface.
protected  void tableDataChanged()
          Called each time all of the data (i.e.
protected  void tableDataChanged(CompoundTableModelEvent event)
          Called if it receives a table data changed event however the event is an instance of CompoundTableModelEvent.
protected  void tableRowsDeleted(int firstRow, int lastRow)
          Called each time one or more contiguous rows are deleted from the underlying TableModel.
protected  void tableRowsInserted(int firstRow, int lastRow)
          Called each time one or more contiguous rows are inserted into the underlying TableModel.
protected  void tableRowsUpdated(int firstRow, int lastRow)
          Called each time one or more contiguous rows are updated in the underlying TableModel.
protected  void tableStructureChanged()
          Called each time the structure (TableColumns, etc) of the underlying TableModel changes.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, removeTableModelListener
 

Field Detail

_model

protected TableModel _model
Constructor Detail

TableModelWrapperImpl

public TableModelWrapperImpl(TableModel model)
Creates a DefaultTableModelWrapper from any table model.

Parameters:
model - the actual table model.
Method Detail

addIndexChangeListener

public void addIndexChangeListener(IndexChangeListener l)
Description copied from interface: IndexChangeEventGenerator
Add IndexChangelistener.

Specified by:
addIndexChangeListener in interface IndexChangeEventGenerator
Parameters:
l - the listener

removeIndexChangeListener

public void removeIndexChangeListener(IndexChangeListener l)
Description copied from interface: IndexChangeEventGenerator
Remove IndexChangelistener.

Specified by:
removeIndexChangeListener in interface IndexChangeEventGenerator
Parameters:
l - the listener

getIndexChangeListeners

public IndexChangeListener[] getIndexChangeListeners()
Description copied from interface: IndexChangeEventGenerator
Returns an array of all the IndexChangeListeners

Specified by:
getIndexChangeListeners in interface IndexChangeEventGenerator
Returns:
all of the IndexChangeListeners added or an empty array if no listeners have been added
See Also:
IndexChangeEventGenerator.addIndexChangeListener(com.jidesoft.grid.IndexChangeListener)

fireIndexChanging

protected int fireIndexChanging()
Tells the TableModeWrapper that indexes is going to be changed. It will basically fire an INDEX_CHANGING_EVENT event.

Returns:
the event serial number for this call, to be used in its partner fireIndexChanged

fireIndexChanged

protected void fireIndexChanged(int eventSerialNumber)
Tells the TableModeWrapper that indexes is changed. It will basically fire an INDEX_CHANGED_EVENT event.

Parameters:
eventSerialNumber - the serial number indicating where this method is invoked, to be pair with fireIndexChanging

getActualModel

public TableModel getActualModel()
Gets the actual table model. Since TableModelWrapper is just a wrapper around another table model, this method will return you the actual table model.

Specified by:
getActualModel in interface TableModelWrapper
Returns:
the actual table model.

getValueAt

public Object getValueAt(int row,
                         int column)
Specified by:
getValueAt in interface TableModel

setValueAt

public void setValueAt(Object value,
                       int row,
                       int column)
Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface TableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel

getColumnName

public String getColumnName(int column)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

getColumnIdentifier

public Object getColumnIdentifier(int column)
Description copied from interface: ColumnIdentifierTableModel
Returns the identifier of the column in the model. A JideTable uses this method to get the unique identifier of this column.

Specified by:
getColumnIdentifier in interface ColumnIdentifierTableModel
Parameters:
column - the index of the column
Returns:
the unique identifier of the column.

getColumnClass

public Class<?> getColumnClass(int column)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel

getConverterContextAt

public ConverterContext getConverterContextAt(int row,
                                              int column)
Gets the converter context of the underlying table model. This will return a valid value only if underlying table model is instance of ContextSensitiveTableModel. If not, it will return null.

Specified by:
getConverterContextAt in interface ContextSensitiveTableModel
Parameters:
row - the row index.
column - the column index.
Returns:
converter context of the underlying table model.

getEditorContextAt

public EditorContext getEditorContextAt(int row,
                                        int column)
Gets the editor context of the underlying table model. This will return a valid value only if underlying table model is instance of ContextSensitiveTableModel. If not, it will return null.

Specified by:
getEditorContextAt in interface ContextSensitiveTableModel
Parameters:
row - the row index.
column - the column index.
Returns:
editor context of the underlying table model.

getCellClassAt

public Class<?> getCellClassAt(int row,
                               int column)
Gets the cell class of the underlying table model. This will return a valid value only if underlying table model is instance of ContextSensitiveTableModel. If not, it will return underlying model's getColumnClass(column).

Specified by:
getCellClassAt in interface ContextSensitiveTableModel
Parameters:
row - the row index.
column - the column index.
Returns:
cell class of the underlying table model.

getCellStyleAt

public CellStyle getCellStyleAt(int row,
                                int column)
Returns null all the time unless you override this method to return a cell style.

Specified by:
getCellStyleAt in interface StyleModel
Parameters:
row - the row index.
column - the column index.
Returns:
null.

isCellStyleOn

public boolean isCellStyleOn()
Returns false all the time unless you override this method to return true. The reason is CellStyleTable will look into the underlying model to see if it defined style. \ Thus no need we delegate to the underlying table model here.

Specified by:
isCellStyleOn in interface StyleModel
Returns:
false.

isNavigableAt

public boolean isNavigableAt(int rowIndex,
                             int columnIndex)
it return true by default.

Specified by:
isNavigableAt in interface NavigableModel
Parameters:
rowIndex - the row index.
columnIndex - the column index.
Returns:
true.

isNavigationOn

public boolean isNavigationOn()
It returns false.

Specified by:
isNavigationOn in interface NavigableModel
Returns:
false.

getCellSpanAt

public CellSpan getCellSpanAt(int rowIndex,
                              int columnIndex)
Gets cell span of the underlying table model.

Specified by:
getCellSpanAt in interface SpanModel
Parameters:
rowIndex - the row index
columnIndex - the column index.
Returns:
cell span of the underlying table model.

isCellSpanOn

public boolean isCellSpanOn()
Delegates to underlying table model for cell span information.

Specified by:
isCellSpanOn in interface SpanModel
Returns:
the isCellSpanOn value of underlying table model.

tableChanged

public void tableChanged(TableModelEvent e)
Implementation of the TableChangeListener interface. Depending on the type of the TableModelEvent, this method delegates to one of the following methods based on the contract of the TableModelEvent object:

createCompoundTableModelEvent

protected CompoundTableModelEvent createCompoundTableModelEvent()
Creates a CompoundTableModelEvent instance.

Returns:
the CompoundTableModelEvent instance.

tableRowsInserted

protected void tableRowsInserted(int firstRow,
                                 int lastRow)
Called each time one or more contiguous rows are inserted into the underlying TableModel. This default implementation simply fires a corresponding TableModelEvent to the listeners on this model.

Parameters:
firstRow - the index of the first row that was inserted
lastRow - the index of the last row that was inserted

tableRowsDeleted

protected void tableRowsDeleted(int firstRow,
                                int lastRow)
Called each time one or more contiguous rows are deleted from the underlying TableModel. This default implementation simply fires a corresponding TableModelEvent to the listeners on this model.

Parameters:
firstRow - the index of the first row that was deleted
lastRow - the index of the last row that was deleted

tableRowsUpdated

protected void tableRowsUpdated(int firstRow,
                                int lastRow)
Called each time one or more contiguous rows are updated in the underlying TableModel. simply fires a corresponding TableModelEvent to the listeners on this model.

Parameters:
firstRow - the index of the first row that was updated
lastRow - the index of the last row that was updated

fireTableCellsUpdated

public void fireTableCellsUpdated(int firstRow,
                                  int lastRow,
                                  int column)
Called each time the cells in column in the range [firstRow, lastRow] are updated. This default implementation simply fires a corresponding TableModelEvent to the listeners on this model.

Parameters:
firstRow - the index of the first row in the above column that was updated
lastRow - the index of the last row in the above column that was updated
column - the index of the column that was updated

tableCellsUpdated

protected void tableCellsUpdated(int column,
                                 int firstRow,
                                 int lastRow)
Called each time the cells in column in the range [firstRow, lastRow] are updated. This default implementation simply fires a corresponding TableModelEvent to the listeners on this model.

Parameters:
column - the index of the column that was updated
firstRow - the index of the first row in the above column that was updated
lastRow - the index of the last row in the above column that was updated

tableDataChanged

protected void tableDataChanged(CompoundTableModelEvent event)
Called if it receives a table data changed event however the event is an instance of CompoundTableModelEvent.

Parameters:
event - the received CompoundTableModelEvent

tableDataChanged

protected void tableDataChanged()
Called each time all of the data (i.e. all rows) is changed in the underlying TableModel. This default implementation simply fires a corresponding TableModelEvent to the listeners on this model.


tableStructureChanged

protected void tableStructureChanged()
Called each time the structure (TableColumns, etc) of the underlying TableModel changes. This default implementation simply fires a corresponding TableModelEvent to the listeners on this model.


getColumnType

public int getColumnType(int columnIndex)
Description copied from interface: MultiTableModel
Checks if the column at the columnIndex is a header column or footer column or just regular column. Header columns will be displayed at the left side of the table. Footer columns will be on the right side. Regular columns will in the middle and will have horizontal scroll bar if there are a lot of columns.

Specified by:
getColumnType in interface MultiTableModel
Parameters:
columnIndex - the column index
Returns:
column type. The possible values are REGULAR_COLUMN, HEADER_COLUMN, or FOOTER_COLUMN.

getTableIndex

public int getTableIndex(int columnIndex)
Description copied from interface: MultiTableModel
Gets the table index that this column belongs to. As convention, the table index starts from 0. So all columns that return 0 in this method will be grouped into the first table. Those return 1 will be on the second table, and so on.

Specified by:
getTableIndex in interface MultiTableModel
Parameters:
columnIndex - the column index
Returns:
the table index.

getEditorStyleAt

public int getEditorStyleAt(int rowIndex,
                            int columnIndex)
Description copied from interface: EditorStyleTableModel
Gets editor style at the cell.

Specified by:
getEditorStyleAt in interface EditorStyleTableModel
Parameters:
rowIndex - the row index
columnIndex - the column index
Returns:
the editor style.

fireTableChanged

public void fireTableChanged(TableModelEvent e)
Overrides:
fireTableChanged in class AbstractTableModel

JIDE 3.5.15