Module is.codion.swing.common.model
Interface FilterTableModel<R,C>
- Type Parameters:
R
- the type representing the rows in this table modelC
- the type used to identify columns in this table model, Integer for indexed identification for example
- All Superinterfaces:
FilterModel<R>
,TableModel
- All Known Implementing Classes:
SwingEntityTableModel
Specifies a table model supporting selection as well as filtering.
A
FilterTableModel
can not contain null items.- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A builder for aFilterTableModel
.static interface
Specifies the columns for a table modelstatic enum
Specifies how the data in a table model is refreshed.static interface
A selection model for aFilterTableModel
.Nested classes/interfaces inherited from interface is.codion.common.model.FilterModel
FilterModel.AbstractRefresher<T>, FilterModel.FilteredItems<T>, FilterModel.Items<T>, FilterModel.Refresher<T>, FilterModel.VisibleItems<T>
-
Field Summary
Fields inherited from interface is.codion.common.model.FilterModel
ASYNC_REFRESH
-
Method Summary
Modifier and TypeMethodDescriptionstatic <R,
C> FilterTableModel.Builder<R, C> builder
(FilterTableModel.Columns<R, C> columns) Instantiates a new table model builder.columns()
filters()
void
Notifies all listeners that all cell values in the table's rows may have changed.void
fireTableRowsUpdated
(int fromIndex, int toIndex) Notifies all listeners that the given rows have changedClass<?>
getColumnClass
(C identifier) Returns the class of the column with the given identifiergetStringAt
(int rowIndex, C identifier) Returns a String representation of the value for the given row and column.void
refresh()
Refreshes the items in this model using itsFilterModel.Refresher
.void
refresh
(Consumer<Collection<R>> onRefresh) Refreshes the data in this filter model using itsFilterModel.Refresher
.<T> Collection<T>
selectedValues
(C identifier) sorter()
<T> Collection<T>
Methods inherited from interface is.codion.common.model.FilterModel
items, refresher
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
-
Method Details
-
columns
FilterTableModel.Columns<R,C> columns()- Returns:
- the table columns
-
getStringAt
Returns a String representation of the value for the given row and column.- Parameters:
rowIndex
- the row indexidentifier
- the column identifier- Returns:
- the string value
-
values
- Type Parameters:
T
- the value type- Parameters:
identifier
- the identifier of the column for which to retrieve the values- Returns:
- the values (including nulls) of the column identified by the given identifier from the visible rows in the table model
-
getColumnClass
Returns the class of the column with the given identifier- Parameters:
identifier
- the column identifier- Returns:
- the Class representing the given column
-
selectedValues
- Type Parameters:
T
- the value type- Parameters:
identifier
- the identifier of the column for which to retrieve the values- Returns:
- the values (including nulls) of the column identified by the given identifier from the selected rows in the table model
-
refreshStrategy
Value<FilterTableModel.RefreshStrategy> refreshStrategy()- Returns:
- the
Value
controlling the refresh strategy
-
selection
FilterTableModel.TableSelection<R> selection()- Specified by:
selection
in interfaceFilterModel<R>
- Returns:
- the
FilterTableModel.TableSelection
instance used by this table model
-
filters
TableConditionModel<C> filters()- Returns:
- the
TableConditionModel
used to filter this table model
-
sorter
FilterTableSortModel<R,C> sorter()- Returns:
- the sort model
-
refresh
void refresh()Refreshes the items in this model using itsFilterModel.Refresher
.
Retains the selection and filtering. Sorts the refreshed data unless merging on refresh is enabled. Note that an empty selection event will be triggered during a normal refresh, since the model is cleared before it is repopulated, during which the selection is cleared as well. Using merge on refresh (refreshStrategy()
) will prevent that at a considerable performance cost.- Specified by:
refresh
in interfaceFilterModel<R>
- See Also:
-
refresh
Refreshes the data in this filter model using itsFilterModel.Refresher
. Note that this method only throws exceptions when run synchronously off the user interface thread. UseFilterModel.Refresher.failure()
to listen for exceptions that happen during asynchronous refresh.
Retains the selection and filtering. Sorts the refreshed data unless merging on refresh is enabled. Note that an empty selection event will be triggered during a normal refresh, since the model is cleared before it is repopulated, during which the selection is cleared as well. Using merge on refresh (refreshStrategy()
) will prevent that at a considerable performance cost.- Specified by:
refresh
in interfaceFilterModel<R>
- Parameters:
onRefresh
- called after a successful refresh, may be null- See Also:
-
fireTableDataChanged
void fireTableDataChanged()Notifies all listeners that all cell values in the table's rows may have changed. The number of rows may also have changed and the JTable should redraw the table from scratch. The structure of the table (as in the order of the columns) is assumed to be the same. -
fireTableRowsUpdated
void fireTableRowsUpdated(int fromIndex, int toIndex) Notifies all listeners that the given rows have changed- Parameters:
fromIndex
- the from indextoIndex
- the to index
-
builder
Instantiates a new table model builder.- Type Parameters:
R
- the row typeC
- the column identifier type- Parameters:
columns
- the columns- Returns:
- a new builder instance
- Throws:
NullPointerException
- in casecolumnValues
is null
-