Package is.codion.swing.framework.model
Class SwingEntityTableModel
java.lang.Object
is.codion.framework.model.AbstractEntityTableModel<SwingEntityEditModel>
is.codion.swing.framework.model.SwingEntityTableModel
- All Implemented Interfaces:
FilterModel<Entity>,EntityTableModel<SwingEntityEditModel>,FilterTableModel<Entity,,Attribute<?>> TableModel
public class SwingEntityTableModel
extends AbstractEntityTableModel<SwingEntityEditModel>
implements FilterTableModel<Entity,Attribute<?>>
A TableModel implementation for displaying and working with entities.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA Swing specificEntityTableModel.EntityTableEditorimplementation.Nested classes/interfaces inherited from class is.codion.framework.model.AbstractEntityTableModel
AbstractEntityTableModel.AbstractEntityTableEditorNested classes/interfaces inherited from interface is.codion.framework.model.EntityTableModel
EntityTableModel.EntityTableEditor, EntityTableModel.OnInsert, EntityTableModel.RefreshTaskNested classes/interfaces inherited from interface is.codion.common.model.filter.FilterModel
FilterModel.AbstractRefresher<T>, FilterModel.FilteredItems<T>, FilterModel.IncludedItems<T>, FilterModel.IncludedPredicate<T>, FilterModel.Items<T>, FilterModel.Refresher<T>, FilterModel.Sort<T>Nested classes/interfaces inherited from interface is.codion.swing.common.model.component.table.FilterTableModel
FilterTableModel.Builder<R,C>, FilterTableModel.ColumnValues<C>, FilterTableModel.Editor<R, C>, FilterTableModel.Export<C>, FilterTableModel.TableColumns<R, C> -
Field Summary
Fields inherited from interface is.codion.framework.model.EntityTableModel
ON_INSERT, ORDER_QUERYFields inherited from interface is.codion.common.model.filter.FilterModel
ASYNC -
Constructor Summary
ConstructorsConstructorDescriptionSwingEntityTableModel(EntityType entityType, EntityConnectionProvider connectionProvider) Instantiates a new SwingEntityTableModel.SwingEntityTableModel(EntityType entityType, Collection<Entity> entities, EntityConnectionProvider connectionProvider) Instantiates a new SwingEntityTableModel containing the given entites.SwingEntityTableModel(EntityQueryModel queryModel) Instantiates a new SwingEntityTableModel.SwingEntityTableModel(EntityTableConditionModel conditionModel) Instantiates a new SwingEntityTableModel.SwingEntityTableModel(SwingEntityEditModel editModel) Instantiates a new SwingEntityTableModel.SwingEntityTableModel(SwingEntityEditModel editModel, EntityQueryModel queryModel) Instantiates a new SwingEntityTableModel.SwingEntityTableModel(Collection<Entity> entities, EntityConnectionProvider connectionProvider) Instantiates a new SwingEntityTableModel containing the given entites. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddTableModelListener(TableModelListener listener) final FilterTableModel.TableColumns<Entity, Attribute<?>> columns()editor()final FilterTableModel.Export<Attribute<?>> export()protected final FilterTableModel<Entity, Attribute<?>> final TableConditionModel<Attribute<?>> filters()final voidNotifies all listeners that all cell values in the table's rows may have changed.final voidfireTableRowsUpdated(int fromIndex, int toIndex) Notifies all listeners that the given rows have changedfinal Class<?> getColumnClass(int columnIndex) final Class<?> getColumnClass(Attribute<?> attribute) Returns the class of the column with the given identifierfinal intfinal StringgetColumnName(int columnIndex) final intgetValueAt(int rowIndex, int columnIndex) final booleanisCellEditable(int rowIndex, int modelColumnIndex) Returns true if the cell atrowIndexandmodelColumnIndexis editable.final FilterModel.Items<Entity> items()protected final voidonRowsUpdated(int fromIndex, int toIndex) Notifies all listeners that the given rows have changedorderBy()final voidrefresh(Collection<Entity.Key> keys) Refreshes the entities with the given keys by re-selecting them from the underlying database.final voidremoveTableModelListener(TableModelListener listener) final FilterListSelection<Entity> final voidsetValueAt(@Nullable Object value, int rowIndex, int modelColumnIndex) Sets the value in the given cell and updates the underlying Entity.final FilterTableSort<Entity, Attribute<?>> sort()final FilterTableModel.ColumnValues<Attribute<?>> values()Provides access to column valuesMethods inherited from class is.codion.framework.model.AbstractEntityTableModel
connection, connectionProvider, deleteSelected, editModel, entities, entityDefinition, entityType, onInsert, orderQuery, queryModel, refreshTask, removeDeleted, replace, select, toString, updated
-
Constructor Details
-
SwingEntityTableModel
Instantiates a new SwingEntityTableModel.- Parameters:
entityType- the entityTypeconnectionProvider- the connection provider
-
SwingEntityTableModel
public SwingEntityTableModel(Collection<Entity> entities, EntityConnectionProvider connectionProvider) Instantiates a new SwingEntityTableModel containing the given entites.- Parameters:
entities- the entities to populate with model withconnectionProvider- the connection provider- Throws:
IllegalArgumentException- in caseentitiesis empty
-
SwingEntityTableModel
public SwingEntityTableModel(EntityType entityType, Collection<Entity> entities, EntityConnectionProvider connectionProvider) Instantiates a new SwingEntityTableModel containing the given entites.- Parameters:
entityType- the entity typeentities- the entities to populate with model withconnectionProvider- the connection provider- Throws:
IllegalArgumentException- in caseentitiesis empty
-
SwingEntityTableModel
Instantiates a new SwingEntityTableModel.- Parameters:
conditionModel- theEntityTableConditionModel
-
SwingEntityTableModel
Instantiates a new SwingEntityTableModel.- Parameters:
queryModel- the table query model
-
SwingEntityTableModel
Instantiates a new SwingEntityTableModel.- Parameters:
editModel- the edit model
-
SwingEntityTableModel
Instantiates a new SwingEntityTableModel.- Parameters:
editModel- the edit modelqueryModel- the table query model- Throws:
IllegalArgumentException- in case the edit model and query model entity type is not the same
-
-
Method Details
-
isCellEditable
public final boolean isCellEditable(int rowIndex, int modelColumnIndex) Returns true if the cell atrowIndexandmodelColumnIndexis editable.- Specified by:
isCellEditablein interfaceTableModel- Parameters:
rowIndex- the row to editmodelColumnIndex- the model index of the column to edit- Returns:
- true if the cell is editable
-
setValueAt
Sets the value in the given cell and updates the underlying Entity.- Specified by:
setValueAtin interfaceTableModel- Parameters:
value- the new valuerowIndex- the row whose value is to be changedmodelColumnIndex- the model index of the column to be changed
-
getRowCount
public final int getRowCount()- Specified by:
getRowCountin interfaceTableModel
-
getValueAt
- Specified by:
getValueAtin interfaceTableModel
-
fireTableDataChanged
public final void fireTableDataChanged()Description copied from interface:FilterTableModelNotifies 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.- Specified by:
fireTableDataChangedin interfaceFilterTableModel<Entity,Attribute<?>>
-
fireTableRowsUpdated
public final void fireTableRowsUpdated(int fromIndex, int toIndex) Description copied from interface:FilterTableModelNotifies all listeners that the given rows have changed- Specified by:
fireTableRowsUpdatedin interfaceFilterTableModel<Entity,Attribute<?>> - Parameters:
fromIndex- the from indextoIndex- the to index
-
items
- Specified by:
itemsin interfaceFilterModel<Entity>- Returns:
- the model items
-
values
Description copied from interface:FilterTableModelProvides access to column values- Specified by:
valuesin interfaceFilterTableModel<Entity,Attribute<?>> - Returns:
- the
FilterTableModel.ColumnValues
-
getColumnClass
Description copied from interface:FilterTableModelReturns the class of the column with the given identifier- Specified by:
getColumnClassin interfaceFilterTableModel<Entity,Attribute<?>> - Parameters:
attribute- the column identifier- Returns:
- the Class representing the given column
-
selection
- Specified by:
selectionin interfaceEntityTableModel<SwingEntityEditModel>- Specified by:
selectionin interfaceFilterModel<Entity>- Specified by:
selectionin interfaceFilterTableModel<Entity,Attribute<?>> - Returns:
- the
FilterListSelectioninstance used by this table model
-
filters
- Specified by:
filtersin interfaceFilterTableModel<Entity,Attribute<?>> - Returns:
- the
TableConditionModelused to filter this table model
-
sort
- Specified by:
sortin interfaceFilterModel<Entity>- Specified by:
sortin interfaceFilterTableModel<Entity,Attribute<?>> - Returns:
- the sort
-
getColumnCount
public final int getColumnCount()- Specified by:
getColumnCountin interfaceTableModel
-
getColumnName
- Specified by:
getColumnNamein interfaceTableModel
-
getColumnClass
- Specified by:
getColumnClassin interfaceTableModel
-
addTableModelListener
- Specified by:
addTableModelListenerin interfaceTableModel
-
removeTableModelListener
- Specified by:
removeTableModelListenerin interfaceTableModel
-
columns
- Specified by:
columnsin interfaceFilterTableModel<Entity,Attribute<?>> - Returns:
- the table columns
-
export
- Specified by:
exportin interfaceFilterTableModel<Entity,Attribute<?>> - Returns:
- a
FilterTableModel.Exportinstance for exporting the table model data
-
editor
- Specified by:
editorin interfaceEntityTableModel<SwingEntityEditModel>- Specified by:
editorin interfaceFilterTableModel<Entity,Attribute<?>> - Returns:
- the
FilterTableModel.Editorproviding the row editing functionality
-
refresh
Description copied from interface:EntityTableModelRefreshes the entities with the given keys by re-selecting them from the underlying database.- Specified by:
refreshin interfaceEntityTableModel<SwingEntityEditModel>- Parameters:
keys- the keys of the entities to refresh
-
filterModel
- Overrides:
filterModelin classAbstractEntityTableModel<SwingEntityEditModel>- Returns:
- the underlying model
-
onRowsUpdated
protected final void onRowsUpdated(int fromIndex, int toIndex) Description copied from class:AbstractEntityTableModelNotifies all listeners that the given rows have changed- Specified by:
onRowsUpdatedin classAbstractEntityTableModel<SwingEntityEditModel>- Parameters:
fromIndex- the from indextoIndex- the to index
-
orderBy
- Specified by:
orderByin classAbstractEntityTableModel<SwingEntityEditModel>- Returns:
- a
OrderByinstance based on the sort order according to theFilterModel.sort()model, an emptyOptionalif unsorted
-