SalesPoint Framework v3.1

util.swing
Interface TableEntryDescriptor

All Superinterfaces:
Serializable
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.

Since:
v2.0
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.

Returns:
the number of columns each record will consist of.
Override:
Always

getColumnName

public String getColumnName(int nIdx)
Return the text to be printed in the header of the given column.

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.
Override:
Always

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).

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.
Override:
Always

getCellRenderer

public TableCellRenderer getCellRenderer(int nIdx)
Return the cell renderer to be used for cells in the given column.

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.
Override:
Always

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.

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.
Override:
Always

getValueAt

public Object getValueAt(Object oRecord,
                         int nIdx)
Get the value to be printed in the given column for the given record.

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.
Override:
Always

isElementEditable

public boolean isElementEditable(Object oRecord,
                                 int nIdx)
Return whether a given column is editable for a given record.

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.
Override:
Always

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.

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).
Override:
Always

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.

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
Override:
Always

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.

Parameters:
nIdx - the index of the column concerned.
Since:
v3.0 12/14/2000
Override:
Always

SalesPoint Framework v3.1