Class AbstractTableModel
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractTableModel
-
- All Implemented Interfaces:
WTable.TableModel
,Serializable
- Direct Known Subclasses:
AbstractBeanBoundTableModel
,EmptyTableModel
public abstract class AbstractTableModel extends Object implements WTable.TableModel, Serializable
A skeleton implementation of a simple data model that does not support sorting, selectability, expandability or editability.- Since:
- 1.0.0
- Author:
- Jonathan Austin
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractTableModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<? extends WComponent>
getRendererClass(List<Integer> row)
This model does not support the concept of rows being expandable by default.Object
getRowKey(List<Integer> row)
Retrieves the key (ie bean) used to uniquely identify this row.boolean
hasChildren(List<Integer> row)
Allows the model to report if the row has children without actually having to determine the number of children (as it might not be known).boolean
isCellEditable(List<Integer> row, int col)
This model does not support the concept of editable cells by default.boolean
isDisabled(List<Integer> row)
This model does not support the concept of row disabling by default.boolean
isExpandable(List<Integer> row)
This model does not support the concept of rows being expandable by default.boolean
isSelectable(List<Integer> row)
This model does not support the concept of row selectability by default.boolean
isSortable(int col)
This model does not support the concept of sorting by default.void
setValueAt(Object value, List<Integer> 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.WTable.TableModel
getChildCount, getRowCount, getValueAt
-
-
-
-
Method Detail
-
getRowKey
public Object getRowKey(List<Integer> 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, the
WTable.handleDataChanged()
method on WTable needs to be called.- Specified by:
getRowKey
in interfaceWTable.TableModel
- Parameters:
row
- the row index- Returns:
- the key (ie bean) used to uniquely identify this row
-
hasChildren
public boolean hasChildren(List<Integer> row)
Allows the model to report if the row has children without actually having to determine the number of children (as it might not be known).- Specified by:
hasChildren
in interfaceWTable.TableModel
- Parameters:
row
- the row index- Returns:
- true if the row has children
-
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:
sort
in interfaceWTable.TableModel
- Parameters:
col
- ignored.ascending
- ignored.- Returns:
- null
-
setValueAt
public void setValueAt(Object value, List<Integer> row, int col)
This model does not support the concept of editable cells by default. Subclasses will need to override this method andisCellEditable(java.util.List, int)
to support cell editing.- Specified by:
setValueAt
in interfaceWTable.TableModel
- 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:
isSortable
in interfaceWTable.TableModel
- Parameters:
col
- ignored.- Returns:
- false.
-
isDisabled
public boolean isDisabled(List<Integer> 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:
isDisabled
in interfaceWTable.TableModel
- Parameters:
row
- ignored.- Returns:
- false.
-
isSelectable
public boolean isSelectable(List<Integer> row)
This model does not support the concept of row selectability by default. Subclasses will need to override this method for selection of specific rows.- Specified by:
isSelectable
in interfaceWTable.TableModel
- Parameters:
row
- ignored.- Returns:
- false
-
isExpandable
public boolean isExpandable(List<Integer> row)
This model does not support the concept of rows being expandable by default. Subclasses will need to override this method for expansion of specific rows.- Specified by:
isExpandable
in interfaceWTable.TableModel
- Parameters:
row
- ignored- Returns:
- false
-
isCellEditable
public boolean isCellEditable(List<Integer> row, int col)
This model does not support the concept of editable cells by default. Subclasses will need to override this method andsetValueAt(java.lang.Object, java.util.List, int)
to support cell editing.- Specified by:
isCellEditable
in interfaceWTable.TableModel
- Parameters:
row
- ignored.col
- ignored.- Returns:
- false.
-
getRendererClass
public Class<? extends WComponent> getRendererClass(List<Integer> row)
This model does not support the concept of rows being expandable by default. Subclasses will need to override this method for expansion of specific rows.- Specified by:
getRendererClass
in interfaceWTable.TableModel
- Parameters:
row
- ignored- Returns:
- null
-
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.
-
-