Interface AdapterBasicTableModel.BasicTableModel
-
- All Known Implementing Classes:
AbstractBasicTableModel
,SimpleTableModel
- Enclosing class:
- AdapterBasicTableModel
public static interface AdapterBasicTableModel.BasicTableModel
BasicTableModel provides a basic interface that can be adapted via
AdapterBasicTableModel
forWTable
. This model is used for data that is not in a tree like structure (ie not expandable).As the data is not expandable, the interface only requires a single row index, instead of being like the
WTable.TableModel
interface that uses a list of indexes.Row and column indices for all methods are zero-based, and TableModels are not expected to perform bounds-checking.
- Since:
- 1.0.0
- Author:
- Jonathan Austin
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
getRowCount()
Retrieves the number of rows.Object
getRowKey(int row)
Retrieves the key (ie bean) used to uniquely identify this row.Object
getValueAt(int row, int col)
Retrieves the value at the given row and column.boolean
isCellEditable(int row, int col)
Indicates whether the given cell is editable.boolean
isDisabled(int row)
Indicates whether the given row is disabled.boolean
isSelectable(int row)
Indicates whether the given row is selectable.boolean
isSortable(int col)
Indicates whether the model supports sorting by the given column.void
setValueAt(Object value, int row, int col)
Sets the value at the given row and column.int[]
sort(int col, boolean ascending)
Sorts the data by the given column.
-
-
-
Method Detail
-
getValueAt
Object getValueAt(int row, int col)
Retrieves the value at the given row and column.- Parameters:
row
- - the row index.col
- - the column index. Column of -1 indicates row has a renderer.- Returns:
- the value at the given row and column.
-
isCellEditable
boolean isCellEditable(int row, int col)
Indicates whether the given cell is editable.- Parameters:
row
- - the row index.col
- - the column index. Column of -1 indicates row has a renderer.- Returns:
- true if the given cell is editable, false otherwise.
-
setValueAt
void setValueAt(Object value, int row, int col)
Sets the value at the given row and column.- Parameters:
value
- the value to set.row
- - the row index.col
- - the column index.
-
isSortable
boolean isSortable(int col)
Indicates whether the model supports sorting by the given column.- Parameters:
col
- the column index.- Returns:
- true if the model is sortable by the given column, false otherwise.
-
sort
int[] sort(int col, boolean ascending)
Sorts the data by the given column. Any previous sorting should be disregarded.
Data models must implement sorting in one of two ways.
-
If the data is accessible locally by the data model (ie. a sort won't result in a service call to obtain sorted data), then this method should not sort the actual data, but return a row-index mapping which the table will use to access the data. Row selection and expansion will be updated to use the new row indices.
For example, if the data for the column is {"a", "b", "d", "c"}, then an ascending sort should return {0, 1, 3, 2}, and a descending sort {2, 3, 1, 0}.
-
If the data is not accessible locally by the data model, or the model is otherwise unable to perform a mapping between old and new row indices, then the model should sort the actual data, and return null. In this case, the table will reset any row selection or expansion.
- Parameters:
col
- the column to sort onascending
- true for an ascending sort, false for descending.- Returns:
- the row indices in sort order, or null if row mappings can not be determined.
-
-
isDisabled
boolean isDisabled(int row)
Indicates whether the given row is disabled.- Parameters:
row
- the row index- Returns:
- true if the row is disabled, false otherwise.
-
isSelectable
boolean isSelectable(int row)
Indicates whether the given row is selectable.- Parameters:
row
- the row index- Returns:
- true if the row is disabled, false otherwise.
-
getRowCount
int getRowCount()
Retrieves the number of rows.- Returns:
- the number of rows in the model for this level.
-
getRowKey
Object getRowKey(int row)
Retrieves the key (ie bean) used to uniquely identify this row.The usual implementation of this method would just return the row id passed in.
However, if you are required to dynamically add/remove rows in the model, which would change the row index, then the implementation of this method needs to return an object that uniquely identifies this row.
When rows have been added/removed to the model, the
WTable.handleDataChanged()
method on WTable needs to be called.- Parameters:
row
- the row index- Returns:
- the key (ie bean) used to uniquely identify this row
-
-