org.tentackle.ui
Class FormTableEntry

java.lang.Object
  extended by org.tentackle.ui.FormTableEntry
Direct Known Subclasses:
AppDbObjectDefaultTableEntry, HistoryTableEntry, SecurityTableEntry, SumFormTableEntry

public abstract class FormTableEntry
extends Object

Entry per object that describes the data and configuration in order to keep all table-config-stuff in one place.


Constructor Summary
FormTableEntry()
           
 
Method Summary
 int compareTo(FormTableEntry entry, int[] compareBy)
          Compares this entry with another one (for sorting).
 void fireCellsUpdated(int... mColumns)
          Fires an update of the given cells in current row.
 void fireRowUpdated()
          Fires an update of all cells in the current row.
 TableCellEditor getCellEditor(int mColumn)
          Gets the cell editor for a given column.
 Rectangle getCellRect(int vRow, int vColumn, boolean includeSpacing)
          Gets the cellrect for a column.
The method is only invoked if isCellRectFixed() returns false.
 TableCellRenderer getCellRenderer(int mColumn)
          Gets the cell renderer for a given column.
Depending on isCellRendererFixed() this method is invoked only once per column or for each cell.
 Class getColumnClass(int mColumn)
          Determines the class for a given column.
If not overridden (or returning null) the class will be determined by inspecting the data.
abstract  int getColumnCount()
          Determines the number of data-model columns.
abstract  String getColumnName(int mColumn)
          Describes the column name.
This may be a symbolic name if getDisplayedColumnName() is overridden.
 char getConvert(int mColumn)
          Defines the character conversion attribute for each column.
 String getDisplayedColumnName(int mColumn)
          Gets the displayed column name.
By default the column-name and the displayed column name are the same.
 String getFormat(int mColumn)
          Defines the format (for numeric or date/time-types) for each column.
 int getHorizontalAlignment(int mColumn)
          Defines the horizontal alignment for each column.
 AbstractFormTableModel getModel()
          Gets the model.
abstract  Object getObject()
          Gets the object wrapped by this entry.
 int getReferencedColumn(int vRow, int vColumn)
          Gets the referenced column if cells are merged.
If cells are merged they must reference to valid cell.
 int getReferencedRow(int vRow, int vColumn)
          Gets the referenced row if cells are merged.
If cells are merged they must reference to valid cell.
 int getRow()
          Gets the row of this entry with respect to the model.
 boolean getShowHorizontalLine(int vRow)
          Determines whether the horizontal grid line following the given row should be drawn or not.
 boolean getShowVerticalLine(int vRow, int vColumn)
          Determines whether the vertical grid line following the given cell should be drawn or not.
abstract  Object getValueAt(int mColumn)
          Gets the column-object for this entry in a given column.
 int getVerticalAlignment(int mColumn)
          Defines the vertical alignment for each column.
 boolean isAutoSelect(int mColumn)
          Gets the autoselect flag.
 boolean isBlankZero(int mColumn)
          Defines the "blankzero" attribute for each column.
 boolean isCellEditable(int mColumn)
          Determines whether the cell is editable or not.
 boolean isCellEditorFixed()
          Determines whether the cell editors are fixed.
FormTable invokes getCellEditor in FormTableEntry only once to improve performance.
 boolean isCellRectFixed()
          Determines whether the cell rectangles are fixed.
Usually the cell dimension is fixed and does not depend on the data.
 boolean isCellRendererFixed()
          Determines whether the cell renderers are fixed.
FormTable invokes getCellRenderer in FormTableEntry only once to improve performance.
 boolean isCellVisible(int vRow, int vColumn)
          Determines whether the cell is visible or not.
The method is only invoked if isCellRectFixed() returns false.
 boolean isColumnNotSummable(int mColumn)
          Determines whether the given column is summable.
The SumFormTableEntry will sumup all numeric columns by default.
 boolean isVisiblyEqual(FormTableEntry entry)
          Compares what the user sees on the GUI between two HistoryTableEntries.
abstract  FormTableEntry newInstanceOf(Object object)
          Creates a new instance of an entry for a given data-object.
 void setModel(AbstractFormTableModel model)
          Sets the model this entry lives in.
 void setRow(int row)
          Sets the row of this entry with respect to the model.
 void setValueAt(int mColumn, Object value)
          Sets the data object for a column.
 boolean updateArray(int mRow)
          Performs an update of the current entry to the underlying array, if the data-model is based on an object array.
 boolean updateCursor(int mRow)
          Performs an update of the current entry to the underlying database cursor, if the data-model is based on a cursor.
 boolean updateList(int mRow)
          Performs an update of the current entry to the underlying list, if the data-model is based on a List.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormTableEntry

public FormTableEntry()
Method Detail

newInstanceOf

public abstract FormTableEntry newInstanceOf(Object object)
Creates a new instance of an entry for a given data-object.

Parameters:
object - the data-object
Returns:
the FormTableEntry for this object

getColumnCount

public abstract int getColumnCount()
Determines the number of data-model columns. Notice that not all columns may actually be visible.

Returns:
the number of columns

getColumnName

public abstract String getColumnName(int mColumn)
Describes the column name.
This may be a symbolic name if getDisplayedColumnName() is overridden.

Parameters:
mColumn - the datamodel-column
Returns:
the name of the column

getDisplayedColumnName

public String getDisplayedColumnName(int mColumn)
Gets the displayed column name.
By default the column-name and the displayed column name are the same.

Parameters:
mColumn - the datamodel column
Returns:
the display name of the column

getColumnClass

public Class getColumnClass(int mColumn)
Determines the class for a given column.
If not overridden (or returning null) the class will be determined by inspecting the data.

Parameters:
mColumn - the datamodel-column
Returns:
the column class or null

getFormat

public String getFormat(int mColumn)
Defines the format (for numeric or date/time-types) for each column. If null is returned a default format will be used according to the column class.

Parameters:
mColumn - the datamodel-column
Returns:
the format or null if default

getHorizontalAlignment

public int getHorizontalAlignment(int mColumn)
Defines the horizontal alignment for each column. If -1 is returned a default will be used according to the column class.

Parameters:
mColumn - the datamodel-column
Returns:
the alignment or -1 if default

getVerticalAlignment

public int getVerticalAlignment(int mColumn)
Defines the vertical alignment for each column. If -1 is returned a default will be used according to the column class.

Parameters:
mColumn - the datamodel-column
Returns:
the alignment or -1 if default

isBlankZero

public boolean isBlankZero(int mColumn)
Defines the "blankzero" attribute for each column.

Parameters:
mColumn - the datamodel-column
Returns:
true if blank zeros, false if not (default)

isAutoSelect

public boolean isAutoSelect(int mColumn)
Gets the autoselect flag.

Parameters:
mColumn - the datamodel-column
Returns:
true if autoselect, false if not (default)

getConvert

public char getConvert(int mColumn)
Defines the character conversion attribute for each column. Default is CONVERT_NONE.

Parameters:
mColumn - the datamodel-column
Returns:
the conversion

isColumnNotSummable

public boolean isColumnNotSummable(int mColumn)
Determines whether the given column is summable.
The SumFormTableEntry will sumup all numeric columns by default. However, for some numeric columns it doesn't make sense to build sums. In this case, better override this method. Furthermore, some apps (like AppDbObjectNaviPanel) check the first row to determine whether a sumup-Button should be visible at all. If the first row contains null-values, it cannot eliminate the possibilty that this column is a numeric unless the getColumnClass() method explicitly tells so.

Parameters:
mColumn - the datamodel column
Returns:
true if column is definitely NOT numeric, else we dont know

isCellRendererFixed

public boolean isCellRendererFixed()
Determines whether the cell renderers are fixed.
FormTable invokes getCellRenderer in FormTableEntry only once to improve performance. If the cellrenderer changes according to content this method must be overridden.

Returns:
false if FormTable should invoke getCellRenderer for every cell.

isCellEditorFixed

public boolean isCellEditorFixed()
Determines whether the cell editors are fixed.
FormTable invokes getCellEditor in FormTableEntry only once to improve performance. If the celleditor changes according to content this method must be overridden.

Returns:
false if FormTable should invoke getCellEditor for every cell.

isCellRectFixed

public boolean isCellRectFixed()
Determines whether the cell rectangles are fixed.
Usually the cell dimension is fixed and does not depend on the data. However, in special cases (e.g. multi-column cells), it is desirable to get the cellRect computed for every cell.

Returns:
true if cell-dimensions are fixed (default).

setModel

public void setModel(AbstractFormTableModel model)
Sets the model this entry lives in. Will be invoked in FormTableModel.getEntryAt.

Parameters:
model - the data-model

getModel

public AbstractFormTableModel getModel()
Gets the model. Useful to determine the chain of models up to the table

Returns:
the data-model the entry lives in

setRow

public void setRow(int row)
Sets the row of this entry with respect to the model. Will be invoked in FormTableModel.getEntryAt.

Parameters:
row - the data-model row

getRow

public int getRow()
Gets the row of this entry with respect to the model. Useful to determine the model row and via the model the view-row.

Returns:
the data-model row of this entry

getObject

public abstract Object getObject()
Gets the object wrapped by this entry.

Returns:
the data object

getValueAt

public abstract Object getValueAt(int mColumn)
Gets the column-object for this entry in a given column.

Parameters:
mColumn - the datamodel-column
Returns:
the column data object

setValueAt

public void setValueAt(int mColumn,
                       Object value)
Sets the data object for a column. The default implementation does nothing.

Parameters:
mColumn - the datamodel-column
value - the cell value

updateCursor

public boolean updateCursor(int mRow)
Performs an update of the current entry to the underlying database cursor, if the data-model is based on a cursor. The default implemenation does nothing and returns true.

Parameters:
mRow - the datamodel-row
Returns:
true if update sucessful, false if not.

updateList

public boolean updateList(int mRow)
Performs an update of the current entry to the underlying list, if the data-model is based on a List. The default implemenation does nothing and returns true.

Parameters:
mRow - the datamodel-row
Returns:
true if update sucessful, false if not.

updateArray

public boolean updateArray(int mRow)
Performs an update of the current entry to the underlying array, if the data-model is based on an object array. The default implemenation does nothing and returns true.

Parameters:
mRow - the datamodel-row
Returns:
true if update sucessful, false if not.

compareTo

public int compareTo(FormTableEntry entry,
                     int[] compareBy)
Compares this entry with another one (for sorting). If the data-objects implement the Comparable-interface the compareTo method of the data-objects will be used. Otherwise the string-represenation (from toString()) will be compared. This default behaviour is ok for most applications.

Parameters:
entry - to be compared against this entry
compareBy - is an array of mColumns where 0 is the first and negative minus 1 means descending. I.e.: [-1, 2] means: first column descending, third ascending
Returns:
a positive integer if this entry is logically "larger" than the given entry. A negative if "smaller" and zero if "equal".

isVisiblyEqual

public boolean isVisiblyEqual(FormTableEntry entry)
Compares what the user sees on the GUI between two HistoryTableEntries. This is in order to suppress invisible changes (i.e. editedBy, editedSince)

Parameters:
entry - to be compared against this entry
Returns:
true if equal.

getCellRenderer

public TableCellRenderer getCellRenderer(int mColumn)
Gets the cell renderer for a given column.
Depending on isCellRendererFixed() this method is invoked only once per column or for each cell. The default implementation returns null, i.e. a default renderer depending on the class is used.

Parameters:
mColumn - the datamodel-column
Returns:
the renderer or null if default

isCellEditable

public boolean isCellEditable(int mColumn)
Determines whether the cell is editable or not. The default is not editable.

Parameters:
mColumn - the datamodel-column
Returns:
true if the cell is editable.

getCellEditor

public TableCellEditor getCellEditor(int mColumn)
Gets the cell editor for a given column. Depending on isCellEditorFixed() this method is invoked only once per column or for each cell. Furthermore the cell must be editable. The default implementation returns null, i.e. a default editor depending on the class is used.

Parameters:
mColumn - the datamodel-column
Returns:
the editor or null if default

getCellRect

public Rectangle getCellRect(int vRow,
                             int vColumn,
                             boolean includeSpacing)
Gets the cellrect for a column.
The method is only invoked if isCellRectFixed() returns false.

Note: Usually tables with dynamic cell sizes (i.e. multispan columns) don't allow the user to change column ordering and/or sort rows. For optimization reasons the given row and column are according to the view which is usually is identical to the model. If this is not the case (which is hard to handle btw.) getCellRect must convert the row and column to the datamodel.

Parameters:
vRow - the row in table view
vColumn - the column in table view
includeSpacing - is true to include margins
Returns:
the cellrect for a cell, null if use default

isCellVisible

public boolean isCellVisible(int vRow,
                             int vColumn)
Determines whether the cell is visible or not.
The method is only invoked if isCellRectFixed() returns false. Invisible cells are not rendered. Overwriting this method usually makes sense if cells are merged depending on the data, i.e. the merged cells should not be rendered. The default is visible.

Parameters:
vRow - the row in table view
vColumn - the column in table view
Returns:
true if the cell is visible.

getReferencedRow

public int getReferencedRow(int vRow,
                            int vColumn)
Gets the referenced row if cells are merged.
If cells are merged they must reference to valid cell. The method is only invoked if isCellRectFixed() returns false.

Parameters:
vRow - the row in table view
vColumn - the column in table view
Returns:
the referenced row for this cell

getReferencedColumn

public int getReferencedColumn(int vRow,
                               int vColumn)
Gets the referenced column if cells are merged.
If cells are merged they must reference to valid cell. The method is only invoked if isCellRectFixed() returns false.

Parameters:
vRow - the row in table view
vColumn - the column in table view
Returns:
the referenced column for this cell

getShowHorizontalLine

public boolean getShowHorizontalLine(int vRow)
Determines whether the horizontal grid line following the given row should be drawn or not. The method is only invoked if isCellRectFixed() returns false.

Parameters:
vRow - the row in table view
Returns:
true if draw horizontal grid

getShowVerticalLine

public boolean getShowVerticalLine(int vRow,
                                   int vColumn)
Determines whether the vertical grid line following the given cell should be drawn or not. The method is only invoked if isCellRectFixed() returns false.

Parameters:
vRow - the row in table view
vColumn - the column in table view
Returns:
true if draw horizontal grid

fireRowUpdated

public void fireRowUpdated()
Fires an update of all cells in the current row.


fireCellsUpdated

public void fireCellsUpdated(int... mColumns)
Fires an update of the given cells in current row.

Parameters:
mColumns - columns with respect to the model


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