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:
is.codion.common.model.FilterModel<R>,TableModel
Specifies a table model supporting selection as well as filtering
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA builder for aFilterTableModel.static interfaceSpecifies the columns for a table modelstatic enumSpecifies how the data in a table model is refreshed. -
Field Summary
Fields inherited from interface is.codion.common.model.FilterModel
ASYNC_REFRESH -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given item to the bottom of this table model.voidvoidaddItems(Collection<R> items) Adds the given items to the bottom of this table model.voidaddItemsAt(int index, Collection<R> items) Adds the given items to this table model, non-filtered items are added at the given index.voidaddItemsAtSorted(int index, Collection<R> items) Adds the given items to this table model, non-filtered items are added at the given index.voidaddItemSorted(R item) Adds the given item to the bottom of this table model.voidaddItemsSorted(Collection<R> items) Adds the given items to the bottom of this table model.static <R,C> FilterTableModel.Builder<R, C> builder(FilterTableModel.Columns<R, C> columns) Instantiates a new table model builder.voidclear()Clears all items from this table modelis.codion.common.event.EventObserver<?>columns()is.codion.common.value.Value<Comparator<R>>is.codion.common.event.EventObserver<?>is.codion.common.model.table.TableConditionModel<C>voidNotifies all listeners that all cell values in the table's rows may have changed.voidfireTableRowsUpdated(int fromIndex, int toIndex) Notifies all listeners that the given rows have changedClass<?>getColumnClass(C columnIdentifier) Returns the class of the column with the given identifiergetStringAt(int rowIndex, C columnIdentifier) Returns a String representation of the value for the given row and column.intitemAt(int rowIndex) voidrefresh()
Retains the selection and filtering.is.codion.common.value.Value<FilterTableModel.RefreshStrategy>voidrefreshThen(Consumer<Collection<R>> afterRefresh)
Retains the selection and filtering.voidremoveItem(R item) Removes the given item from this table modelremoveItemAt(int index) Removes from this table model the visible element whose index is between indexremoveItems(int fromIndex, int toIndex) Removes from this table model all visible elements whose index is between fromIndex, inclusive and toIndex, exclusivevoidremoveItems(Collection<R> items) Removes the given items from this table model<T> Collection<T>selectedValues(C columnIdentifier) voidSets the item at the given index.voidSorts the visible items according tocomparator(), keeping the selected items.<T> Collection<T>Methods inherited from interface is.codion.common.model.FilterModel
containsItem, filtered, filteredCount, filteredItems, filterItems, includeCondition, items, refresher, visible, visibleCount, visibleItemsMethods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
-
Method Details
-
dataChangedEvent
is.codion.common.event.EventObserver<?> dataChangedEvent()- Returns:
- an observer notified each time the table data changes
-
clearedEvent
is.codion.common.event.EventObserver<?> clearedEvent()- Returns:
- an observer notified each time the table model is cleared
-
indexOf
- Parameters:
item- the item- Returns:
- the index of the item in the table model
-
itemAt
- Parameters:
rowIndex- the row index- Returns:
- the item at the given row index in the table model
-
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 indexcolumnIdentifier- the column identifier- Returns:
- the string value
-
addItems
Adds the given items to the bottom of this table model.- Parameters:
items- the items to add
-
addItemsSorted
Adds the given items to the bottom of this table model. If sorting is enabled this model is sorted after the items have been added.- Parameters:
items- the items to add
-
addItemsAt
Adds the given items to this table model, non-filtered items are added at the given index.- Parameters:
index- the index at which to add the itemsitems- the items to add
-
addItemsAtSorted
Adds the given items to this table model, non-filtered items are added at the given index. If acomparator()is specified this model is sorted after the items have been added.- Parameters:
index- the index at which to add the itemsitems- the items to add
-
addItem
Adds the given item to the bottom of this table model.- Parameters:
item- the item to add
-
addItemAt
- Parameters:
index- the indexitem- the item to add
-
addItemSorted
Adds the given item to the bottom of this table model. If sorting is enabled this model is sorted after the item has been added.- Parameters:
item- the item to add
-
setItemAt
Sets the item at the given index. If the item should be filtered calling this method has no effect.- Parameters:
index- the indexitem- the item- See Also:
-
FilterModel.includeCondition()
-
removeItems
Removes the given items from this table model- Parameters:
items- the items to remove from the model
-
removeItem
Removes the given item from this table model- Parameters:
item- the item to remove from the model
-
removeItemAt
Removes from this table model the visible element whose index is between index- Parameters:
index- the index of the row to be removed- Returns:
- the removed item
- Throws:
IndexOutOfBoundsException- in case the indexe is out of bounds
-
removeItems
Removes from this table model all visible elements whose index is between fromIndex, inclusive and toIndex, exclusive- Parameters:
fromIndex- index of first row to be removedtoIndex- index after last row to be removed- Returns:
- the removed items
- Throws:
IndexOutOfBoundsException- in case the indexes are out of bounds
-
values
- Type Parameters:
T- the value type- Parameters:
columnIdentifier- 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:
columnIdentifier- the column identifier- Returns:
- the Class representing the given column
-
selectedValues
- Type Parameters:
T- the value type- Parameters:
columnIdentifier- 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
is.codion.common.value.Value<FilterTableModel.RefreshStrategy> refreshStrategy()- Returns:
- the Value controlling the refresh strategy
-
comparator
is.codion.common.value.Value<Comparator<R>> comparator()- Returns:
- the value controlling the comparator to use when sorting
-
sortItems
void sortItems()Sorts the visible items according tocomparator(), keeping the selected items. Calling this method when no comparator is specified has no effect.- See Also:
-
selectionModel
FilterTableSelectionModel<R> selectionModel()- Returns:
- the selection model used by this table model
-
filterModel
is.codion.common.model.table.TableConditionModel<C> filterModel()- Returns:
- the filter model used by this table model
-
refresh
void 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:
refreshin interfaceis.codion.common.model.FilterModel<R>- See Also:
-
refreshThen
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:
refreshThenin interfaceis.codion.common.model.FilterModel<R>- See Also:
-
clear
void clear()Clears all items from this table model -
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 casecolumnValuesis null
-