org.tentackle.ui
Class AbstractFormTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.tentackle.ui.AbstractFormTableModel
All Implemented Interfaces:
Serializable, TableModel
Direct Known Subclasses:
FormTableMap, FormTableModel

public abstract class AbstractFormTableModel
extends AbstractTableModel

Abstract table model that maintains a chained mapping of rows by a FormTableMap.

Author:
harald
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
AbstractFormTableModel()
           
 
Method Summary
abstract  String getDisplayedColumnName(int column)
          Gets the displayed column name.
abstract  FormTableEntry getEntryAt(int rowIndex)
          Gets the form table entry at given row.
 FormTableMap getMap()
          Sets the chained mapper.
 int getMappedIndex(int mappedRow)
          Gets the mapped row index according to a given model row.
Inversion of getModelIndex().
 int[] getMappedIndex(int[] mappedRows)
          Gets the mapped row indexes according to given model rows.
Inversion of getModelIndex().
 int getModelIndex(int row)
          Gets the row in the original model according to the mapping.
The default implementation returns the same row.
 int[] getModelIndex(int[] rows)
          Gets the rows in the original model according to the mapping.
The default implementation returns the same rows.
 FormTable getTable()
          Gets the table.
abstract  FormTableEntry getTemplate()
          Gets the table entry template from the model.
 boolean isDataChanged()
          Returns whether data has changed.
 void setDataChanged(boolean dataChanged)
          Sets a flag that model data has changed.
 boolean setEntryAt(FormTableEntry entry, int rowIndex)
          Sets the form table entry at given row.
The default implementation just triggers a value changed event for the table.
 void setMap(FormTableMap map)
          Sets the chained mapper.
 void setTable(FormTable table)
          Sets the table.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
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
getColumnCount, getRowCount, getValueAt
 

Constructor Detail

AbstractFormTableModel

public AbstractFormTableModel()
Method Detail

setTable

public void setTable(FormTable table)
Sets the table.

Parameters:
table - the form table or null if this model is not the direct data model for the table (i.e. somewhere in a chain)

getTable

public FormTable getTable()
Gets the table.

Returns:
the form table or null if this model is not the direct data model for the table

setMap

public void setMap(FormTableMap map)
Sets the chained mapper.

Parameters:
map - the chained form table map or null if this model is not chaining another map

getMap

public FormTableMap getMap()
Sets the chained mapper.

Returns:
the chained form table map or null if this model is not chaining another map

getEntryAt

public abstract FormTableEntry getEntryAt(int rowIndex)
Gets the form table entry at given row.

Parameters:
rowIndex - the row of the table entry
Returns:
the table entry, null if rowIndex out of range

getTemplate

public abstract FormTableEntry getTemplate()
Gets the table entry template from the model.

Returns:
the form table entry template

setEntryAt

public boolean setEntryAt(FormTableEntry entry,
                          int rowIndex)
Sets the form table entry at given row.
The default implementation just triggers a value changed event for the table. Must be overridden for another mapping than 1:1.

Parameters:
entry - the formtable entry
rowIndex - the row of the table entry
Returns:
true if replaced, false if not (rowIndex out of range)

getModelIndex

public int getModelIndex(int row)
Gets the row in the original model according to the mapping.
The default implementation returns the same row. Must be overridden for another mapping than 1:1.

Parameters:
row - the row of this model
Returns:
the row of the mapped model

getModelIndex

public int[] getModelIndex(int[] rows)
Gets the rows in the original model according to the mapping.
The default implementation returns the same rows. Must be overridden for another mapping than 1:1.

Parameters:
rows - the array of rows of this model
Returns:
the rows of the mapped model

getMappedIndex

public int getMappedIndex(int mappedRow)
Gets the mapped row index according to a given model row.
Inversion of getModelIndex(). The default implementation returns the same row. Must be overridden for another mapping than 1:1.

Parameters:
mappedRow - the original row
Returns:
the mapped row index

getMappedIndex

public int[] getMappedIndex(int[] mappedRows)
Gets the mapped row indexes according to given model rows.
Inversion of getModelIndex(). The default implementation returns the same rows. Must be overridden for another mapping than 1:1.

Parameters:
mappedRows - the original rows
Returns:
the mapped row indexes

isDataChanged

public boolean isDataChanged()
Returns whether data has changed. Used to for the famous "discard any changes?"-question.

Returns:
true if model data has been changed

setDataChanged

public void setDataChanged(boolean dataChanged)
Sets a flag that model data has changed. Will be cleared on listChanged() or cursorChanged().

Parameters:
dataChanged - true if model data has changed

getDisplayedColumnName

public abstract String getDisplayedColumnName(int column)
Gets the displayed column name.

Parameters:
column - column index
Returns:
the column name


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de