|
SalesPoint Framework v3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.table.AbstractTableModel util.swing.AbstractTableModel
A TableModel
that models a list of records rather than a matrix of cells.
Usage of this TableModel is always recommendable when the data that is to be displayed consists of
a list of uniformly structured records and you want to display a selection of attributes for each record.
As the data management classes (Catalog
, Stock
, DataBasket
) of the
"SalesPoint" framework match this scheme, there are concrete subclasses of this model for each of
those classes.
util.swing.AbstractTableModel
will give one row in the table to each record of the model.
The record that is to be displayed in a certain row is determined by the getRecord(int)
method which is
abstract and must be overridden in subclasses. Thus, subclasses have the opportunity to define what
type (class) of records they use and how they are derived from the actual data source in the background.
There's only one more method that subclasses will have to override:
TableModel.getRowCount()
.
A TableEntryDescriptor
will be used to determine how individual records are represented in one
row of the table model, i.e. how many columns there are and what is displayed in the cells as well as
formatting and editing issues.
JAbstractTable
,
Serialized FormField Summary |
Fields inherited from class javax.swing.table.AbstractTableModel |
listenerList |
Constructor Summary | |
AbstractTableModel(TableEntryDescriptor ted)
Create a new AbstractTableModel. |
Method Summary | |
Class |
getColumnClass(int nIdx)
Get the class of the given column in this TableModel . |
int |
getColumnCount()
Get the number of columns in this TableModel . |
String |
getColumnName(int nIdx)
Get the name of the given column in this TableModel . |
TableEntryDescriptor |
getEntryDescriptor()
Get the TableEntryDescriptor that is used to split records into columns. |
abstract Object |
getRecord(int row)
Get the record associated to the given row. |
Object |
getValueAt(int row,
int col)
Get the value of the given cell in this TableModel .
|
boolean |
isCellEditable(int row,
int col)
Check whether the given cell is editable in this TableModel .
|
void |
orderByColumn(int nIdx,
boolean fAscending)
Reorders the table by the specified column if that's possible. |
protected void |
reOrderBy(Comparator cmp)
Reorder the records displayed according to the specified comparator. |
abstract void |
setData(Object data)
Set the table's data. |
void |
setValueAt(Object oValue,
int row,
int col)
Set the value of the given cell in this TableModel .
|
Methods inherited from class javax.swing.table.AbstractTableModel |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener |
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 |
getRowCount |
Constructor Detail |
public AbstractTableModel(TableEntryDescriptor ted)
ted
- the TableEntryDescriptor
that is to be used to split records into columns.Method Detail |
public abstract void setData(Object data)
data
- the new data
Exception
public TableEntryDescriptor getEntryDescriptor()
TableEntryDescriptor
that is used to split records into columns.
public int getColumnCount()
TableModel
.
TableEntryDescriptor
.TableEntryDescriptor.getColumnCount()
public String getColumnName(int nIdx)
TableModel
.
nIdx
- the column's index. Columns indices run from 0 to
getColumnCount() - 1
.
TableEntryDescriptor
.TableEntryDescriptor.getColumnName(int)
public Class getColumnClass(int nIdx)
TableModel
.
nIdx
- the column's index. Columns indices run from 0 to
getColumnCount() - 1
.
TableEntryDescriptor
.TableEntryDescriptor.getColumnClass(int)
public Object getValueAt(int row, int col)
TableModel
.
First determines the record associated to the row by calling getRecord(int)
, then calls
getValueAt()
in the associated TableEntryDescriptor.
row
- the row index for which to determine the value. This will be passed on to getRecord(int)
.
Row indices run from 0 to getRowCount() - 1
.col
- the column's index. Columns indices run from 0 to
getColumnCount() - 1
.
TableEntryDescriptor.getValueAt(java.lang.Object, int)
.public boolean isCellEditable(int row, int col)
TableModel
.
First determines the record associated to the row by calling getRecord(int)
, then calls
isElementEditable()
in the associated
TableEntryDescriptor.
row
- the row index for which to determine editability. This will be passed on to getRecord(int)
.
Row indices run from 0 to getRowCount() - 1
.col
- the column's index. Columns indices run from 0 to
getColumnCount() - 1
.
TableEntryDescriptor.isElementEditable(java.lang.Object, int)
.public void setValueAt(Object oValue, int row, int col)
TableModel
.
First determines the record associated to the row by calling getRecord(int)
, then calls
setValueAt()
in the associated TableEntryDescriptor.
oValue
- the new value for the cell. This will be passed on to
TableEntryDescriptor.setValueAt(java.lang.Object, int, java.lang.Object)
as the oValue
parameter.row
- the row index for which to set the value. This will be passed on to getRecord(int)
.
Row indices run from 0 to getRowCount() - 1
.col
- the column's index. Columns indices run from 0 to
getColumnCount() - 1
.public void orderByColumn(int nIdx, boolean fAscending)
nIdx
- the index of the column by which to sortfAscending
- if false orders the records in descending orderreOrderBy(java.util.Comparator)
public abstract Object getRecord(int row)
Subclasses must indicate the class of the record in their documentation.
row
- the row index for which to return the record. Row indices run from 0 to
getRowCount() - 1
.
null
, instead of throwing an exception,
if the given index is without its bounds.protected void reOrderBy(Comparator cmp)
cmp
- the comparator by which to order.
|
SalesPoint Framework v3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |