Class SimpleTableModel
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractBasicTableModel
-
- com.github.bordertech.wcomponents.SimpleTableModel
-
- All Implemented Interfaces:
AdapterBasicTableModel.BasicTableModel
,Serializable
public class SimpleTableModel extends AbstractBasicTableModel
A simple table data model, that takes in tabular data in its constructor. Note that use of this data model is discouraged, as the table data will be stored in the user's session.Used in conjunction with the
AdapterBasicTableModel
forWTable
.- Since:
- 1.0.0
- Author:
- Jonathan Austin
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static ComparableComparator
COMPARABLE_COMPARATOR
A simple comparator that compares comparables, for use in sorting e.g. columns containing Strings.
-
Constructor Summary
Constructors Constructor Description SimpleTableModel(Serializable[][] data)
Creates a SimpleTableDataModel containing the given data.SimpleTableModel(List<? extends List<? extends Serializable>> data)
Creates a SimpleTableDataModel containing the given data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Serializable[][]
getData()
int
getRowCount()
Retrieves the number of rows.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
isEditable()
Indicates whether the data in this model is editable.boolean
isSortable(int col)
This model does not support the concept of sorting by default.void
setComparator(int col, Comparator comparator)
Sets the comparator for the given column, to enable sorting.void
setEditable(boolean editable)
Sets whether the data in this model is editable.void
setValueAt(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.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractBasicTableModel
getRowKey, isDisabled, isSelectable, sort
-
-
-
-
Field Detail
-
COMPARABLE_COMPARATOR
public static final ComparableComparator COMPARABLE_COMPARATOR
A simple comparator that compares comparables, for use in sorting e.g. columns containing Strings.
-
-
Constructor Detail
-
SimpleTableModel
public SimpleTableModel(List<? extends List<? extends Serializable>> data)
Creates a SimpleTableDataModel containing the given data.- Parameters:
data
- the table data, the outer list containing rows.
-
SimpleTableModel
public SimpleTableModel(Serializable[][] data)
Creates a SimpleTableDataModel containing the given data.- Parameters:
data
- the table data, the outer array containing rows.
-
-
Method Detail
-
getData
public Serializable[][] getData()
- Returns:
- the data for this model
-
isSortable
public boolean isSortable(int col)
This model does not support the concept of sorting by default. Subclasses will need to override this method andAbstractBasicTableModel.sort(int, boolean)
to support sorting.- Specified by:
isSortable
in interfaceAdapterBasicTableModel.BasicTableModel
- Overrides:
isSortable
in classAbstractBasicTableModel
- Parameters:
col
- ignored.- Returns:
- false.
-
setComparator
public void setComparator(int col, Comparator comparator)
Sets the comparator for the given column, to enable sorting.- Parameters:
col
- the column to set the comparator on.comparator
- the comparator to set.
-
getRowCount
public int getRowCount()
Retrieves the number of rows.- Returns:
- the number of rows in the model for this level.
-
getValueAt
public 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
public boolean isCellEditable(int row, int col)
Indicates whether the given cell is editable. This model only supports editability at a global level. SeesetEditable(boolean)
.- Specified by:
isCellEditable
in interfaceAdapterBasicTableModel.BasicTableModel
- Overrides:
isCellEditable
in classAbstractBasicTableModel
- Parameters:
row
- ignored.col
- ignored.- Returns:
- true if the given cell is editable, false otherwise.
-
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 andAbstractBasicTableModel.isCellEditable(int, int)
to support cell editing.- Specified by:
setValueAt
in interfaceAdapterBasicTableModel.BasicTableModel
- Overrides:
setValueAt
in classAbstractBasicTableModel
- Parameters:
value
- ignored.row
- ignored.col
- ignored.
-
isEditable
public boolean isEditable()
Indicates whether the data in this model is editable.- Returns:
- true if the data in this model is editable, false otherwise.
-
setEditable
public void setEditable(boolean editable)
Sets whether the data in this model is editable. By default, the data is not editable.- Parameters:
editable
- true if the data is editable, false if it is read-only.
-
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 andAbstractBasicTableModel.isSortable(int)
to support sorting.- Specified by:
sort
in interfaceAdapterBasicTableModel.BasicTableModel
- Overrides:
sort
in classAbstractBasicTableModel
- Parameters:
col
- ignored.ascending
- ignored.- Returns:
- null
-
-