SalesPoint v3.3 API

util.swing
Interface TableEntryDescriptor

All Superinterfaces:
Serializable
All Known Implementing Classes:
AbstractTableEntryDescriptor, DefaultCatalogItemDBETableEntryDescriptor, DefaultCatalogItemTED, DefaultCountingStockDBETableEntryDescriptor, DefaultCountingStockItemTED, DefaultCurrencyItemTED, DefaultLogEntryTED, DefaultMoneyBagItemTED, DefaultStockItemTED, DefaultStoringStockDBETableEntryDescriptor, DefaultUserTED

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<Object> 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

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

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

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

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

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

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

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

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

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

Comparator<Object> 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 v3.3 API