Class AbstractBasicTableModel
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractBasicTableModel
-
- All Implemented Interfaces:
AdapterBasicTableModel.BasicTableModel,Serializable
- Direct Known Subclasses:
SimpleTableModel
public abstract class AbstractBasicTableModel extends Object implements AdapterBasicTableModel.BasicTableModel, Serializable
A skeleton implementation of a basic data model that does not support filtering, sorting, or editability.Used for data that is not in a tree like structure (ie not expandable).
- Since:
- 1.0.0
- Author:
- Jonathan Austin
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractBasicTableModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectgetRowKey(int row)Retrieves the key (ie bean) used to uniquely identify this row.booleanisCellEditable(int row, int col)This model does not support the concept of editable cells by default.booleanisDisabled(int row)This model does not support the concept of row disabling by default.booleanisSelectable(int row)This model does not support the concept of row selectability by default.booleanisSortable(int col)This model does not support the concept of sorting by default.voidsetValueAt(Object value, int row, int col)This model does not support the concept of editable cells by default.int[]sort(int col, boolean ascending)This model does not support the concept of sorting by default.protected int[]sort(Comparator<Object> comparator, int col, boolean ascending)Calculates the sort order for the data, using the given column and comparator.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.bordertech.wcomponents.AdapterBasicTableModel.BasicTableModel
getRowCount, getValueAt
-
-
-
-
Method Detail
-
getRowKey
public Object getRowKey(int row)
Description copied from interface:AdapterBasicTableModel.BasicTableModelRetrieves 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.- Specified by:
getRowKeyin interfaceAdapterBasicTableModel.BasicTableModel- Parameters:
row- the row index- Returns:
- the row index as the unique key for the row
-
sort
public int[] sort(int col, boolean ascending)This model does not support the concept of sorting by default. Subclasses will need to override this method andisSortable(int)to support sorting.- Specified by:
sortin interfaceAdapterBasicTableModel.BasicTableModel- Parameters:
col- ignored.ascending- ignored.- Returns:
- null
-
setValueAt
public void setValueAt(Object value, int row, int col)
This model does not support the concept of editable cells by default. Subclasses will need to override this method andisCellEditable(int, int)to support cell editing.- Specified by:
setValueAtin interfaceAdapterBasicTableModel.BasicTableModel- Parameters:
value- ignored.row- ignored.col- ignored.
-
isSortable
public boolean isSortable(int col)
This model does not support the concept of sorting by default. Subclasses will need to override this method andsort(int, boolean)to support sorting.- Specified by:
isSortablein interfaceAdapterBasicTableModel.BasicTableModel- Parameters:
col- ignored.- Returns:
- false.
-
isDisabled
public boolean isDisabled(int row)
This model does not support the concept of row disabling by default. Subclasses will need to override this method to support row disabling.- Specified by:
isDisabledin interfaceAdapterBasicTableModel.BasicTableModel- Parameters:
row- ignored.- Returns:
- false.
-
isSelectable
public boolean isSelectable(int row)
This model does not support the concept of row selectability by default. Subclasses will need to override this method disable selection of specific rows.- Specified by:
isSelectablein interfaceAdapterBasicTableModel.BasicTableModel- Parameters:
row- ignored.- Returns:
- true.
-
isCellEditable
public boolean isCellEditable(int row, int col)This model does not support the concept of editable cells by default. Subclasses will need to override this method andsetValueAt(Object, int, int)to support cell editing.- Specified by:
isCellEditablein interfaceAdapterBasicTableModel.BasicTableModel- Parameters:
row- ignored.col- ignored.- Returns:
- false.
-
sort
protected int[] sort(Comparator<Object> comparator, int col, boolean ascending)
Calculates the sort order for the data, using the given column and comparator.- Parameters:
comparator- the comparator to use for sortingcol- the column to sort onascending- true for an ascending sort, false for descending.- Returns:
- the row indices in sort order.
-
-