T - The generated ListRow classpublic class DefaultTableModel<T extends ListRow> extends Object implements TableModel<T>
ListRows. The selection model is set to
TableModel.SelectionModel.DEFAULT.TableModel.SelectionModel| Constructor and Description |
|---|
DefaultTableModel(DialogObjectConstant[] columns,
ViewModel viewModel)
Create a new table model based on the specified columns.
|
DefaultTableModel(List<DialogObjectConstant> columns,
ViewModel viewModel)
Create a new table model based on the specified columns.
|
| 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.
|
List<ListRowComparator<T>> |
getListRowComparator()
Get the current comparator list.
|
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.
|
protected RoleConstant |
getTableRole() |
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.
|
protected ViewModel |
getViewModel() |
int |
indexOf(ListRow 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.
|
public DefaultTableModel(List<DialogObjectConstant> columns, ViewModel viewModel)
columns - the column definition of this table modelviewModel - the view model for the tablepublic DefaultTableModel(DialogObjectConstant[] columns, ViewModel viewModel)
columns - the column definition of this table modelviewModel - the view model for the tablepublic List<T> getTableData()
TableModelNote that any changes made directly to this list will be detected by the table model and trigger and update of the table view list.
getTableData in interface TableModel<T extends ListRow>public List<T> getTableView()
TableModelNote 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.
getTableView in interface TableModel<T extends ListRow>public void addRowFilter(RowFilter<?,ListRow> rowFilter)
TableModeladdRowFilter in interface TableModel<T extends ListRow>rowFilter - row filter(s) to addpublic void addRowFilters(Collection<RowFilter<?,ListRow>> rowFilters)
TableModeladdRowFilters in interface TableModel<T extends ListRow>rowFilters - row filter(s) to addpublic void removeRowFilter(RowFilter<?,ListRow> rowFilter)
TableModelremoveRowFilter in interface TableModel<T extends ListRow>rowFilter - row filter(s) to removepublic void removeRowFilters(Collection<RowFilter<?,ListRow>> rowFilters)
TableModelremoveRowFilters in interface TableModel<T extends ListRow>rowFilters - row filters to removepublic void clearRowFilters()
TableModelclearRowFilters in interface TableModel<T extends ListRow>public Collection<RowFilter<?,ListRow>> getRowFilters()
TableModelgetRowFilters in interface TableModel<T extends ListRow>public void setSelectionModel(TableModel.SelectionModel selectionModel)
TableModelsetSelectionModel in interface TableModel<T extends ListRow>selectionModel - the selection model for the tablepublic TableModel.SelectionModel getSelectionModel()
TableModelgetSelectionModel in interface TableModel<T extends ListRow>public Object getValueAt(int rowIndex, DialogObjectConstant columnIdentifier)
TableModelgetValueAt in interface TableModel<T extends ListRow>rowIndex - table data's index of the rowcolumnIdentifier - constant denoting the columnpublic void setValueAt(int rowIndex,
DialogObjectConstant columnIdentifier,
Object value)
TableModelNote: The table view is not updated as a result of invoking this method.
setValueAt in interface TableModel<T extends ListRow>rowIndex - table data's index of the rowcolumnIdentifier - constant denoting the columnvalue - cell valueTableModel.filterTableView()public void filterTableView()
TableModelfilterTableView in interface TableModel<T extends ListRow>public int getTableDataRowCount()
TableModelgetTableDataRowCount in interface TableModel<T extends ListRow>public int getTableViewRowCount()
TableModelgetTableViewRowCount in interface TableModel<T extends ListRow>public int getColumnCount()
TableModelgetColumnCount in interface TableModel<T extends ListRow>public int indexOf(ListRow row)
TableModel-1 is returned.indexOf in interface TableModel<T extends ListRow>row - row to get index forpublic int toTableDataIndex(int tableViewIndex)
TableModeltoTableDataIndex in interface TableModel<T extends ListRow>tableViewIndex - displayed row indexpublic T get(int rowIndex)
TableModelget in interface TableModel<T extends ListRow>rowIndex - the table data's index of the row to getpublic void insert(int rowIndex,
T... row)
TableModelinsert in interface TableModel<T extends ListRow>rowIndex - table data's index at which the specified row is to be
insertedrow - row to be insertedpublic void insert(int rowIndex,
Collection<T> rows)
TableModelrows collection.insert in interface TableModel<T extends ListRow>rowIndex - table data's index at which the specified row is to be
insertedrows - rows to be insertedpublic void add(T... row)
TableModeladd in interface TableModel<T extends ListRow>row - the row or rows to appendpublic void add(Collection<T> rows)
TableModeladd in interface TableModel<T extends ListRow>rows - the rows appendpublic T remove(int rowIndex)
TableModelremove in interface TableModel<T extends ListRow>rowIndex - table data's index of the row to remove.public boolean remove(T... row)
TableModelremove in interface TableModel<T extends ListRow>row - the row or rows to remove.true if the table data changed as a result of the
callpublic boolean removeAll(Collection<T> rows)
TableModelTableModel.remove(ListRow...)removeAll in interface TableModel<T extends ListRow>rows - the rows to remove.true if the table data changed as a result
of the callpublic void clear()
TableModelclear in interface TableModel<T extends ListRow>public boolean isEmpty()
TableModelisEmpty in interface TableModel<T extends ListRow>true if this table model is empty (
TableModel.getTableDataRowCount() == 0)public void setSelected(int rowIndex,
boolean selected)
TableModelsetSelected in interface TableModel<T extends ListRow>rowIndex - table data's index of the rowselected - if true the row will be selectedTableModel.getSelectionModel()public void setSelected(T row, boolean selected)
TableModelsetSelected in interface TableModel<T extends ListRow>row - the row to selectselected - if true the row will be selectedTableModel.getSelectionModel()public void setSelected(boolean selected)
TableModelsetSelected in interface TableModel<T extends ListRow>selected - if true the row will be selectedTableModel.getSelectionModel()public boolean isSelected(int rowIndex)
TableModelisSelected in interface TableModel<T extends ListRow>rowIndex - table data's index of the row to testtrue if the specified row is selected.public List<T> getSelected()
TableModelgetSelected in interface TableModel<T extends ListRow>public int getSelectionCount()
TableModelgetSelectionCount in interface TableModel<T extends ListRow>protected RoleConstant getTableRole()
protected ViewModel getViewModel()
public void setEnabled(boolean enabled)
TableModelsetEnabled in interface TableModel<T extends ListRow>enabled - if true, all cells in the row will be enabledTableModel.isCellEnabled(int, DialogObjectConstant)public void setRowEnabled(int rowIndex,
boolean enabled)
TableModelsetRowEnabled in interface TableModel<T extends ListRow>rowIndex - table data's index of the row to set editableenabled - if true, all cells in the row will be enabledTableModel.isCellEnabled(int, DialogObjectConstant)public void setRowEnabled(T row, boolean enabled)
TableModelsetRowEnabled in interface TableModel<T extends ListRow>row - the row to set editableenabled - if true, all cells in the row will be enabledTableModel.isCellEnabled(int, DialogObjectConstant)public void setColumnEnabled(DialogObjectConstant columnIdentifier, boolean enabled)
TableModelsetColumnEnabled in interface TableModel<T extends ListRow>columnIdentifier - constant denoting the columnenabled - if true, all cells in the column will be enabledTableModel.isCellEnabled(int, DialogObjectConstant)public void setCellEnabled(int rowIndex,
DialogObjectConstant columnIdentifier,
boolean enabled)
TableModelsetCellEnabled in interface TableModel<T extends ListRow>rowIndex - table data's row indexcolumnIdentifier - constant denoting the columnenabled - if true, the cells will be editableTableModel.isCellEnabled(int, DialogObjectConstant)public boolean isCellEnabled(int rowIndex,
DialogObjectConstant columnIdentifier)
TableModelfalse the cell will not be able to
receive focus. If the cell is visible and enabled the
cell will be able to receive focus.isCellEnabled in interface TableModel<T extends ListRow>rowIndex - table data's row indexcolumnIdentifier - constant denoting the columntrue if the cell is enabledpublic void setShown(boolean shown)
TableModelsetShown in interface TableModel<T extends ListRow>shown - if true, all cells in the row will be renderedTableModel.isCellShown(int, DialogObjectConstant)public void setRowShown(int rowIndex,
boolean shown)
TableModelsetRowShown in interface TableModel<T extends ListRow>rowIndex - table data's row indexshown - if true, all cells in the row will be renderedTableModel.isCellShown(int, DialogObjectConstant)public void setRowShown(T row, boolean shown)
TableModelsetRowShown in interface TableModel<T extends ListRow>row - the row to set shownshown - if true, all cells in the row will be renderedTableModel.isCellShown(int, DialogObjectConstant)public void setColumnShown(DialogObjectConstant columnIdentifier, boolean shown)
TableModelsetColumnShown in interface TableModel<T extends ListRow>columnIdentifier - constant denoting the columnshown - if true, all cells in the column will be renderedTableModel.isCellEnabled(int, DialogObjectConstant)public void setCellShown(int rowIndex,
DialogObjectConstant columnIdentifier,
boolean shown)
TableModelsetCellShown in interface TableModel<T extends ListRow>rowIndex - table data's row indexcolumnIdentifier - constant denoting the columnshown - if true, the cell will be renderedTableModel.isCellEnabled(int, DialogObjectConstant)public boolean isCellShown(int rowIndex,
DialogObjectConstant columnIdentifier)
TableModeltrue the cell will be rendered.isCellShown in interface TableModel<T extends ListRow>rowIndex - table data's row indexcolumnIdentifier - constant denoting the columntrue if the cell is shownpublic <U> void setProperty(Property<U> property, U propertyValue)
TableModelsetProperty in interface TableModel<T extends ListRow>U - The property value typeproperty - the propertypropertyValue - value of the propertypublic <U> void setRowProperty(int rowIndex,
Property<U> property,
U propertyValue)
TableModelsetRowProperty in interface TableModel<T extends ListRow>U - The property value typerowIndex - table data's row indexproperty - the propertypropertyValue - value of the propertypublic <U> void setRowProperty(T row, Property<U> property, U propertyValue)
TableModelsetRowProperty in interface TableModel<T extends ListRow>U - The property value typerow - table row to set the property onproperty - the propertypropertyValue - value of the propertypublic <U> void setColumnProperty(DialogObjectConstant columnIdentifier, Property<U> propertyName, U value)
TableModelsetColumnProperty in interface TableModel<T extends ListRow>U - The property value typecolumnIdentifier - constant denoting the columnpropertyName - name identifying the propertyvalue - value of the propertypublic <U> void setCellProperty(int rowIndex,
DialogObjectConstant columnIdentifier,
Property<U> propertyName,
U propertyValue)
TableModelsetCellProperty in interface TableModel<T extends ListRow>U - The property value typerowIndex - table data's row indexcolumnIdentifier - constant denoting the columnpropertyName - name identifying the propertypropertyValue - value of the propertypublic <U> U getCellProperty(int rowIndex,
DialogObjectConstant columnIdentifier,
Property<U> propertyName)
TableModelgetCellProperty in interface TableModel<T extends ListRow>U - The property value typerowIndex - table data's row indexcolumnIdentifier - constant denoting the columnpropertyName - name identifying the propertypublic DialogObjectConstant getFirstSortingColumn()
TableModelgetFirstSortingColumn in interface TableModel<T extends ListRow>public void setFirstSortingColumn(DialogObjectConstant column)
TableModelsetFirstSortingColumn in interface TableModel<T extends ListRow>column - first column to use when sortingpublic void sortTableView()
TableModelsortTableView in interface TableModel<T extends ListRow>TableModel.setListRowComparator(List)public List<ListRowComparator<T>> getListRowComparator()
TableModel.public void setListRowComparator(List<ListRowComparator<T>> comparatorList)
TableModelsetListRowComparator in interface TableModel<T extends ListRow>comparatorList - list of comparators to use, one for each sortable columnpublic void toggleSorting()
TableModeltoggleSorting in interface TableModel<T extends ListRow>ListRowComparator.toggleSorting()public ListRowComparator.Sorting getSorting()
TableModelgetSorting in interface TableModel<T extends ListRow>ListRowComparator.getSorting()public void setSorting(ListRowComparator.Sorting sortDirection)
TableModelsetSorting in interface TableModel<T extends ListRow>sortDirection - the sort directionListRowComparator.setSorting(Sorting)public void prettyPrint(PrintStream out)
TableModel
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).
prettyPrint in interface TableModel<T extends ListRow>out - the print stream to write to.Copyright © 2006–2020 Esito AS. All rights reserved.