T - The actual implementing ListRow classpublic interface TableModel<T extends ListRow>
ListRow is used to represents rows. Rows are referenced using a
zero-based rowIndex. When setting a property, the property is
propagated to the ListRow's PropertyManager.
The table model maintains two lists of ListRows:
getTableData() method.
getTableView() method.
| Modifier and Type | Interface and Description |
|---|---|
static class |
TableModel.SelectionModel
Enumerates the various row selection models.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Collection<T> rows)
Appends the specified rows to this table data's list.
|
void |
add(T... row)
Appends the specified rows to this table data's list.
|
void |
addRowFilter(RowFilter<?,ListRow> rowFilter)
Add the row filter to this table model.
|
void |
addRowFilters(Collection<RowFilter<?,ListRow>> rowFilters)
Add the row filters to this table model.
|
void |
clear()
Clears this table model by removing all ListRows.
|
void |
clearRowFilters()
Removes all row filters used by this table model.
|
void |
filterTableView()
Update the table view list according to the defined filters.
|
T |
get(int rowIndex)
Get the list row at the specified table data's index (zero-based).
|
<U> U |
getCellProperty(int rowIndex,
DialogObjectConstant columnIdentifier,
Property<U> propertyName)
Get the property value for the specified cell.
|
int |
getColumnCount()
Get the number of columns in this table model.
|
DialogObjectConstant |
getFirstSortingColumn()
Get the column that is first in the sorting sequence.
|
Collection<RowFilter<?,ListRow>> |
getRowFilters()
Get the registered row filters for this table model.
|
List<T> |
getSelected()
Get the list of selected rows.
|
int |
getSelectionCount()
Get the number of selected rows.
|
TableModel.SelectionModel |
getSelectionModel()
Get the tables selection model.
|
ListRowComparator.Sorting |
getSorting()
Get the sort direction used by the first sorting column.
|
List<T> |
getTableData()
Get the table data list.
|
int |
getTableDataRowCount()
Get the number of rows in this table's data list.
|
List<T> |
getTableView()
Get the table view list.
|
int |
getTableViewRowCount()
Get the number of rows in this table's view list.
|
Object |
getValueAt(int rowIndex,
DialogObjectConstant columnIdentifier)
Get the cell value at the specified row and column.
|
int |
indexOf(T row)
Get the index of the specified row.
|
void |
insert(int rowIndex,
Collection<T> rows)
Inserts a row or rows at the specified position in the table data list.
|
void |
insert(int rowIndex,
T... row)
Inserts a row or rows at the specified position in the table data list .
|
boolean |
isCellEnabled(int rowIndex,
DialogObjectConstant columnIdentifier)
Get the enabled property value of the specified cell.
|
boolean |
isCellShown(int rowIndex,
DialogObjectConstant columnIdentifier)
Get the shown property value of the specified cell.
|
boolean |
isEmpty()
Test if this table model contains any rows.
|
boolean |
isSelected(int rowIndex)
Test if the specified row is selected.
|
void |
prettyPrint(PrintStream out)
Debug print the table contents to specified print stream.
|
T |
remove(int rowIndex)
Removes the row at the specified table data index.
|
boolean |
remove(T... row)
Removes specified row or rows from the table data list.
|
boolean |
removeAll(Collection<T> rows)
Removes specified row or rows from the table data list.
|
void |
removeRowFilter(RowFilter<?,ListRow> rowFilter)
Remove the row filter from this table model.
|
void |
removeRowFilters(Collection<RowFilter<?,ListRow>> rowFilters)
Remove the row filters from this table model.
|
void |
setCellEnabled(int rowIndex,
DialogObjectConstant columnIdentifier,
boolean enabled)
Set the enabled property the specified cell.
|
<U> void |
setCellProperty(int rowIndex,
DialogObjectConstant columnIdentifier,
Property<U> propertyName,
U propertyValue)
Set the specified property on the specified cell.
|
void |
setCellShown(int rowIndex,
DialogObjectConstant columnIdentifier,
boolean shown)
Set the shown property the specified cell.
|
void |
setColumnEnabled(DialogObjectConstant columnIdentifier,
boolean enabled)
Set the enabled property for all cells in the specified column.
|
<U> void |
setColumnProperty(DialogObjectConstant columnIdentifier,
Property<U> propertyName,
U value)
Set the specified property on all cells in the column.
|
void |
setColumnShown(DialogObjectConstant columnIdentifier,
boolean shown)
Set the shown property for all cells in the specified column.
|
void |
setEnabled(boolean enabled)
Set the enabled property for all cells in the entire table.
|
void |
setFirstSortingColumn(DialogObjectConstant column)
Use the specified column first when comparing list rows.
|
void |
setListRowComparator(List<ListRowComparator<T>> comparatorList)
Set the list of ListRowComparators to use when sorting this table model.
|
<U> void |
setProperty(Property<U> property,
U propertyValue)
Set the specified property on all cells in the table.
|
void |
setRowEnabled(int rowIndex,
boolean enabled)
Set the enabled property for all cells in the specified row.
|
void |
setRowEnabled(T row,
boolean enabled)
Set the enabled property for all cells in the specified row.
|
<U> void |
setRowProperty(int rowIndex,
Property<U> property,
U propertyValue)
Set the specified property on all cells in the row.
|
<U> void |
setRowProperty(T row,
Property<U> property,
U propertyValue)
Set the specified property on all cells in the row.
|
void |
setRowShown(int rowIndex,
boolean shown)
Set the shown property for all cells in the specified row.
|
void |
setRowShown(T row,
boolean shown)
Set the shown property for all cells in the specified row.
|
void |
setSelected(boolean selected)
Set the selected property of all rows.
|
void |
setSelected(int rowIndex,
boolean selected)
Set the selected property of the specified row.
|
void |
setSelected(T row,
boolean selected)
Set the selected property of the specified row.
|
void |
setSelectionModel(TableModel.SelectionModel selectionModel)
Set the table's selection model.
|
void |
setShown(boolean shown)
Set the shown property for all cells in the table.
|
void |
setSorting(ListRowComparator.Sorting sortDirection)
Set the sort direction used by the first sorting column.
|
void |
setValueAt(int rowIndex,
DialogObjectConstant columnIdentifier,
Object value)
Set the specified cell value.
|
void |
sortTableView()
Sort the table view.
|
void |
toggleSorting()
Toggle the sorting used by the first sorting column.
|
int |
toTableDataIndex(int tableViewIndex)
Transform the given tableViewIndex to the corresponding table model
index.
|
void setListRowComparator(List<ListRowComparator<T>> comparatorList)
comparatorList - list of comparators to use, one for each sortable columnvoid toggleSorting()
ListRowComparator.toggleSorting()ListRowComparator.Sorting getSorting()
ListRowComparator.getSorting()void setSorting(ListRowComparator.Sorting sortDirection)
sortDirection - the sort directionListRowComparator.setSorting(Sorting)void setFirstSortingColumn(DialogObjectConstant column)
column - first column to use when sortingvoid sortTableView()
setListRowComparator(List)DialogObjectConstant getFirstSortingColumn()
void addRowFilter(RowFilter<?,ListRow> rowFilter)
rowFilter - row filter(s) to addvoid addRowFilters(Collection<RowFilter<?,ListRow>> rowFilters)
rowFilters - row filter(s) to addvoid removeRowFilter(RowFilter<?,ListRow> rowFilter)
rowFilter - row filter(s) to removevoid removeRowFilters(Collection<RowFilter<?,ListRow>> rowFilters)
rowFilters - row filters to removevoid clearRowFilters()
Collection<RowFilter<?,ListRow>> getRowFilters()
void filterTableView()
List<T> getTableData()
Note that any changes made directly to this list will be detected by the table model and trigger and update of the table view list.
List<T> getTableView()
Note that any changes made directly to this list will not be detected by the table model. Thus adding or removing rows to this list might not yield the desired result.
void setSelectionModel(TableModel.SelectionModel selectionModel)
selectionModel - the selection model for the tableTableModel.SelectionModel getSelectionModel()
Object getValueAt(int rowIndex, DialogObjectConstant columnIdentifier)
rowIndex - table data's index of the rowcolumnIdentifier - constant denoting the columnIndexOutOfBoundsException - if the specified row index is out of range (
rowIndex < 0 || rowIndex > getRowCount())NoSuchElementException - if the specified column is not part of this table datavoid setValueAt(int rowIndex,
DialogObjectConstant columnIdentifier,
Object value)
Note: The table view is not updated as a result of invoking this method.
rowIndex - table data's index of the rowcolumnIdentifier - constant denoting the columnvalue - cell valueIndexOutOfBoundsException - if the specified row index is out of range (
rowIndex < 0 || rowIndex > getRowCount())NoSuchElementException - if the specified column is not part of this table model datafilterTableView()int getTableDataRowCount()
int getTableViewRowCount()
int getColumnCount()
int indexOf(T row)
-1 is returned.row - row to get index forNullPointerException - if the specified row is nullint toTableDataIndex(int tableViewIndex)
tableViewIndex - displayed row indexT get(int rowIndex)
rowIndex - the table data's index of the row to getIndexOutOfBoundsException - if the specified index is out of range (
rowIndex < 0 || rowIndex %gt;= getRowCount())void insert(int rowIndex,
T... row)
rowIndex - table data's index at which the specified row is to be
insertedrow - row to be insertedIndexOutOfBoundsException - if the specified row index is out of range (
rowIndex < 0 || rowIndex > getTableDataRowCount()
)NullPointerException - if the specified row is nullIllegalArgumentException - if the rows does not match the column definitionsvoid insert(int rowIndex,
Collection<T> rows)
rows collection.rowIndex - table data's index at which the specified row is to be
insertedrows - rows to be insertedIndexOutOfBoundsException - if the specified row index is out of range (
rowIndex < 0 || rowIndex > getTableDataRowCount()
)NullPointerException - if the specified row is nullIllegalArgumentException - if the rows does not match the column definitionsvoid add(T... row)
row - the row or rows to appendNullPointerException - if rows is null or contains a null
referenceIllegalArgumentException - if the rows does not match the column definitionsvoid add(Collection<T> rows)
rows - the rows appendNullPointerException - if rows is null or contains a null
referenceIllegalArgumentException - if the rows does not match the column definitionsT remove(int rowIndex)
rowIndex - table data's index of the row to remove.IndexOutOfBoundsException - if the specified index is out of range (
rowIndex < 0 || rowIndex >= getRowCount())boolean remove(T... row)
row - the row or rows to remove.true if the table data changed as a result of the
callboolean removeAll(Collection<T> rows)
remove(ListRow...)rows - the rows to remove.true if the table data changed as a result
of the callvoid clear()
boolean isEmpty()
true if this table model is empty (
getTableDataRowCount() == 0)void setSelected(int rowIndex,
boolean selected)
rowIndex - table data's index of the rowselected - if true the row will be selectedIndexOutOfBoundsException - if the specified index is out of range (
rowIndex < 0 || rowIndex >= getTableDataRowCount()
)IllegalStateException - if the selection model prohibits the selectiongetSelectionModel()void setSelected(T row, boolean selected)
row - the row to selectselected - if true the row will be selectedIllegalStateException - if the selection model prohibits the selectiongetSelectionModel()void setSelected(boolean selected)
selected - if true the row will be selectedIllegalStateException - if the selection model prohibits the selectiongetSelectionModel()boolean isSelected(int rowIndex)
rowIndex - table data's index of the row to testtrue if the specified row is selected.IndexOutOfBoundsException - if the specified index is out of range (
rowIndex < 0 || rowIndex >= getTableDataRowCount()
)List<T> getSelected()
int getSelectionCount()
void setEnabled(boolean enabled)
enabled - if true, all cells in the row will be enabledisCellEnabled(int, DialogObjectConstant)void setRowEnabled(int rowIndex,
boolean enabled)
rowIndex - table data's index of the row to set editableenabled - if true, all cells in the row will be enabledIndexOutOfBoundsException - if the specified index is out of range (
rowIndex < 0 || rowIndex >= getTableDataRowCount()
)isCellEnabled(int, DialogObjectConstant)void setRowEnabled(T row, boolean enabled)
row - the row to set editableenabled - if true, all cells in the row will be enabledisCellEnabled(int, DialogObjectConstant)void setColumnEnabled(DialogObjectConstant columnIdentifier, boolean enabled)
columnIdentifier - constant denoting the columnenabled - if true, all cells in the column will be enabledNoSuchElementException - if the specified column is not part of this table modelisCellEnabled(int, DialogObjectConstant)void setCellEnabled(int rowIndex,
DialogObjectConstant columnIdentifier,
boolean enabled)
rowIndex - table data's row indexcolumnIdentifier - constant denoting the columnenabled - if true, the cells will be editableIndexOutOfBoundsException - if the specified index is out of range (
rowIndex < 0 || rowIndex >= getTableDataRowCount()
)NoSuchElementException - if the specified column is not part of this table modelisCellEnabled(int, DialogObjectConstant)boolean isCellEnabled(int rowIndex,
DialogObjectConstant columnIdentifier)
false the cell will not be able to
receive focus. If the cell is visible and enabled the
cell will be able to receive focus.rowIndex - table data's row indexcolumnIdentifier - constant denoting the columntrue if the cell is enabledIndexOutOfBoundsException - if the specified index is out of range (
rowIndex < 0 || rowIndex >= getTableDataRowCount()
)NoSuchElementException - if the specified column is not part of this table modelvoid setShown(boolean shown)
shown - if true, all cells in the row will be renderedisCellShown(int, DialogObjectConstant)void setRowShown(int rowIndex,
boolean shown)
rowIndex - table data's row indexshown - if true, all cells in the row will be renderedIndexOutOfBoundsException - if the specified index is out of range (
rowIndex < 0 || rowIndex >= getTableDataRowCount()
)isCellShown(int, DialogObjectConstant)void setRowShown(T row, boolean shown)
row - the row to set shownshown - if true, all cells in the row will be renderedisCellShown(int, DialogObjectConstant)void setColumnShown(DialogObjectConstant columnIdentifier, boolean shown)
columnIdentifier - constant denoting the columnshown - if true, all cells in the column will be renderedNoSuchElementException - if the specified column is not part of this table modelisCellEnabled(int, DialogObjectConstant)void setCellShown(int rowIndex,
DialogObjectConstant columnIdentifier,
boolean shown)
rowIndex - table data's row indexcolumnIdentifier - constant denoting the columnshown - if true, the cell will be renderedIndexOutOfBoundsException - if the specified index is out of range (
rowIndex < 0 || rowIndex >= getTableDataRowCount()
)NoSuchElementException - if the specified column is not part of this table modelisCellEnabled(int, DialogObjectConstant)boolean isCellShown(int rowIndex,
DialogObjectConstant columnIdentifier)
true the cell will be rendered.rowIndex - table data's row indexcolumnIdentifier - constant denoting the columntrue if the cell is shownIndexOutOfBoundsException - if the specified index is out of range (
rowIndex < 0 || rowIndex >= getTableDataRowCount()
)NoSuchElementException - if the specified column is not part of this table model<U> void setProperty(Property<U> property, U propertyValue)
U - The property value typeproperty - the propertypropertyValue - value of the property<U> void setRowProperty(int rowIndex,
Property<U> property,
U propertyValue)
U - The property value typerowIndex - table data's row indexproperty - the propertypropertyValue - value of the propertyIndexOutOfBoundsException - if the specified index is out of range (
rowIndex < 0 || rowIndex >= getTableDataRowCount()
)<U> void setRowProperty(T row, Property<U> property, U propertyValue)
U - The property value typerow - table row to set the property onproperty - the propertypropertyValue - value of the property<U> void setColumnProperty(DialogObjectConstant columnIdentifier, Property<U> propertyName, U value)
U - The property value typecolumnIdentifier - constant denoting the columnpropertyName - name identifying the propertyvalue - value of the propertyNoSuchElementException - if the specified column is not part of this table model<U> void setCellProperty(int rowIndex,
DialogObjectConstant columnIdentifier,
Property<U> propertyName,
U propertyValue)
U - The property value typerowIndex - table data's row indexcolumnIdentifier - constant denoting the columnpropertyName - name identifying the propertypropertyValue - value of the propertyIndexOutOfBoundsException - if the specified index is out of range (
rowIndex < 0 || rowIndex >= getTableDataRowCount()
)NoSuchElementException - if the specified column is not part of this table model<U> U getCellProperty(int rowIndex,
DialogObjectConstant columnIdentifier,
Property<U> propertyName)
U - The property value typerowIndex - table data's row indexcolumnIdentifier - constant denoting the columnpropertyName - name identifying the propertyIndexOutOfBoundsException - if the specified index is out of range (
rowIndex < 0 || rowIndex >= getTableDataRowCount()
)NoSuchElementException - if the specified column is not part of this table modelvoid prettyPrint(PrintStream out)
This method is intended for debug purposes only and should be
considered as an advanced variant of the general toString()
method. The exact format of the printed text may vary between releases
(even patches).
out - the print stream to write to.Copyright © 2006–2017 Esito AS. All rights reserved.