SalesPoint Framework v3.0

util.swing
Interface TableEntryDescriptor

All Known Implementing Classes:
AbstractTableEntryDescriptor

public interface TableEntryDescriptor
extends Serializable

Strategy that describes how individual records of an AbstractTableModel are to be split up into columns of a table and how the individual cells are to be displayed and edited.

You should think of a TableEntryDescriptor as a device that is given a record and splits this record into individual values, that correspond to cells.

When implementing this interface, you might want to subclass AbstractTableEntryDescriptor, that will already give you a head start with some of the more common tasks.

Hooks:
Define New Table Layout
Since:
v2.0
Version:
2.0 27/07/1999
Author:
Steffen Zschaler
See Also:
JAbstractTable

Method Summary
 boolean canSortByColumn(int nIdx)
          Return true if the records can be sorted by the specified column.
 TableCellEditor getCellEditor(int nIdx)
          Return the cell editor to be used for cells in the given column.
 TableCellRenderer getCellRenderer(int nIdx)
          Return the cell renderer to be used for cells in the given column.
 Class getColumnClass(int nIdx)
          Return the class of objects that make up the values of cells of the given column.
 int getColumnCount()
          Return the number of columns each record will consist of.
 String getColumnName(int nIdx)
          Return the text to be printed in the header of the given column.
 Comparator getColumnOrder(int nIdx)
          Return a comparator to be used when ordering records by the specified column.
 Object getValueAt(Object oRecord, int nIdx)
          Get the value to be printed in the given column for the given record.
 boolean isElementEditable(Object oRecord, int nIdx)
          Return whether a given column is editable for a given record.
 void setValueAt(Object oRecord, int nIdx, Object oValue)
          Set the value of the given column for the given record.
 

Method Detail

getColumnCount

public int getColumnCount()
Return the number of columns each record will consist of.
Override:
Always.
Returns:
the number of columns each record will consist of.
Hooks:
Define New Table Layout

getColumnName

public String getColumnName(int nIdx)
Return the text to be printed in the header of the given column.
Override:
Always.
Parameters:
nIdx - the index of the column for which to return the header. Indices run from 0 to getColumnCount() - 1.
Returns:
the text to be printed in the header of the given column.
Hooks:
Define New Table Layout

getColumnClass

public Class getColumnClass(int nIdx)
Return the class of objects that make up the values of cells of the given column. This will be used to determine the cell renderer and editor unless you specify otherwise through getCellEditor(int) and getCellRenderer(int).
Override:
Always.
Parameters:
nIdx - the index of the column for which to return the value class. Indices run from 0 to getColumnCount() - 1.
Returns:
the class of objects that make up the values of cells of the given column.
Hooks:
Define New Table Layout

getCellRenderer

public TableCellRenderer getCellRenderer(int nIdx)
Return the cell renderer to be used for cells in the given column.
Override:
Always.
Parameters:
nIdx - the index of the column for which to return the renderer. Indices run from 0 to getColumnCount() - 1.
Returns:
the cell renderer to be used for cells in the given column. You can return null to indicate that the default cell renderer for the column class should be used.

getCellEditor

public TableCellEditor getCellEditor(int nIdx)
Return the cell editor to be used for cells in the given column. This is only effective if isElementEditable(java.lang.Object, int) returns true for the column and a given record.
Override:
Always.
Parameters:
nIdx - the index of the column for which to return the editor. Indices run from 0 to getColumnCount() - 1.
Returns:
the cell editor to be used for cells in the given column. You can return null to indicate that the default cell editor for the column class should be used.
Hooks:
Make Table Editable

getValueAt

public Object getValueAt(Object oRecord,
                         int nIdx)
Get the value to be printed in the given column for the given record.
Override:
Always.
Parameters:
oRecord - the record for which to determine the value. The actual class depends on the AbstractTableModel you are working with. It will be declared in the documentation for the AbstractTableModel.getRecord(int) method of that class.
nIdx - the index of the column for which to return the cell value. Indices run from 0 to getColumnCount() - 1.
Returns:
the value to be printed in the given column for the given record. The actual class must be a subclass of what was returned by getColumnClass(int) or that class itself.
Hooks:
Define New Table Layout

isElementEditable

public boolean isElementEditable(Object oRecord,
                                 int nIdx)
Return whether a given column is editable for a given record.
Override:
Always.
Parameters:
oRecord - the record for which to determine editability. The actual class depends on the AbstractTableModel you are working with. It will be declared in the documentation for the AbstractTableModel.getRecord(int) method of that class.
nIdx - the index of the column for which to determine editability. Indices run from 0 to getColumnCount() - 1.
Returns:
whether the given column is editable for the given record.
Hooks:
Make Table Editable

setValueAt

public void setValueAt(Object oRecord,
                       int nIdx,
                       Object oValue)
Set the value of the given column for the given record.

This method will only be invoked if isElementEditable(java.lang.Object, int) returned true for the given cell and if the user actually edited the given cell.

Note that changes will only become visible if they result in an event being fired to the JTable that uses the model.

Override:
Always.
Parameters:
oRecord - the record for which to determine the value. The actual class depends on the AbstractTableModel you are working with. It will be declared in the documentation for the AbstractTableModel.getRecord(int) method of that class.
nIdx - the index of the column for which to return the cell value. Indices run from 0 to getColumnCount() - 1.
oValue - the value to become the new value of the cell. The class of this object depends on the editor used for editing the cell. Normally, this will be determined by getCellEditor(int).
Hooks:
Make Table Editable

canSortByColumn

public boolean canSortByColumn(int nIdx)
Return true if the records can be sorted by the specified column. If true, getColumnOrder(int) must return a valid comparator for the specified column.
Override:
Always.
Parameters:
nIdx - the index of the column concerned.
Returns:
whether or not records can be sorted by the specified column.
Since:
v3.0 12/14/2000

getColumnOrder

public Comparator getColumnOrder(int nIdx)
Return a comparator to be used when ordering records by the specified column. Depending on the specific TableModel, the comparator compares records or elements of records.
Override:
Always.
Parameters:
nIdx - the index of the column concerned.
Since:
v3.0 12/14/2000

SalesPoint Framework v3.0