Package is.codion.swing.framework.model
Class SwingEntityTableModel
java.lang.Object
is.codion.framework.model.AbstractEntityTableModel<SwingEntityModel,SwingEntityEditModel,SwingEntityTableModel,SwingEntityEditor>
is.codion.swing.framework.model.SwingEntityTableModel
- All Implemented Interfaces:
FilterTableModel<Entity,,Attribute<?>> FilterModel<Entity>,EntityTableModel<SwingEntityModel,,SwingEntityEditModel, SwingEntityTableModel, SwingEntityEditor> SwingFilterTableModel<Entity,,Attribute<?>> TableModel
public class SwingEntityTableModel
extends AbstractEntityTableModel<SwingEntityModel,SwingEntityEditModel,SwingEntityTableModel,SwingEntityEditor>
implements SwingFilterTableModel<Entity,Attribute<?>>
A TableModel implementation for displaying and working with entities.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA Swing specificEntityTableModel.EntityRowEditorimplementation.Nested classes/interfaces inherited from class is.codion.framework.model.AbstractEntityTableModel
AbstractEntityTableModel.AbstractEntityRowEditor<R extends EntityEditor<R>>Nested classes/interfaces inherited from interface is.codion.framework.model.EntityTableModel
EntityTableModel.EntityRowEditor, EntityTableModel.OnInsertNested classes/interfaces inherited from interface is.codion.common.model.filter.FilterModel
FilterModel.AbstractRefresher<T>, FilterModel.FilteredItems<T>, FilterModel.IncludedItems<T>, FilterModel.IncludePredicate<T>, FilterModel.Items<T>, FilterModel.Refresher<T>, FilterModel.Sort<T>Nested classes/interfaces inherited from interface is.codion.common.model.component.table.FilterTableModel
FilterTableModel.Builder<R,C>, FilterTableModel.ColumnValues<C>, FilterTableModel.Export<C>, FilterTableModel.TableColumns<R, C> Nested classes/interfaces inherited from interface is.codion.swing.common.model.component.table.SwingFilterTableModel
SwingFilterTableModel.Builder<R,C>, SwingFilterTableModel.RowEditor<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(EntityConditionModel conditionModel) Instantiates a new SwingEntityTableModel.SwingEntityTableModel(EntityQueryModel queryModel) 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) protected final SwingFilterTableModel<Entity, Attribute<?>> 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 intfinal StringgetColumnName(int columnIndex) final intgetValueAt(int rowIndex, int columnIndex) final booleanisCellEditable(int rowIndex, int modelColumnIndex) Returns true if the cell atrowIndexandmodelColumnIndexis editable.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.Methods inherited from class is.codion.framework.model.AbstractEntityTableModel
columns, connection, connectionProvider, editModel, editor, entities, entityDefinition, entityType, export, filterConditions, filters, items, itemValidator, onInsert, orderQuery, query, removeDeleted, replace, select, sort, tableColumns, toString, updated, valuesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface is.codion.common.model.filter.FilterModel
items
-
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- theEntityConditionModel
-
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:SwingFilterTableModelNotifies 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 interfaceSwingFilterTableModel<Entity,Attribute<?>>
-
fireTableRowsUpdated
public final void fireTableRowsUpdated(int fromIndex, int toIndex) Description copied from interface:SwingFilterTableModelNotifies all listeners that the given rows have changed- Specified by:
fireTableRowsUpdatedin interfaceSwingFilterTableModel<Entity,Attribute<?>> - Parameters:
fromIndex- the from indextoIndex- the to index
-
selection
- Specified by:
selectionin interfaceFilterModel<Entity>- Specified by:
selectionin interfaceFilterTableModel<Entity,Attribute<?>> - Specified by:
selectionin interfaceSwingFilterTableModel<Entity,Attribute<?>> - Returns:
- the
FilterListSelectioninstance used by this table model
-
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
-
rowEditor
- Specified by:
rowEditorin interfaceEntityTableModel<SwingEntityModel,SwingEntityEditModel, SwingEntityTableModel, SwingEntityEditor> - Specified by:
rowEditorin interfaceSwingFilterTableModel<Entity,Attribute<?>> - Returns:
- the
SwingFilterTableModel.RowEditorproviding 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<SwingEntityModel,SwingEntityEditModel, SwingEntityTableModel, SwingEntityEditor> - Parameters:
keys- the keys of the entities to refresh
-
filterModel
- Overrides:
filterModelin classAbstractEntityTableModel<SwingEntityModel,SwingEntityEditModel, SwingEntityTableModel, SwingEntityEditor> - 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<SwingEntityModel,SwingEntityEditModel, SwingEntityTableModel, SwingEntityEditor> - Parameters:
fromIndex- the from indextoIndex- the to index
-
orderBy
- Specified by:
orderByin classAbstractEntityTableModel<SwingEntityModel,SwingEntityEditModel, SwingEntityTableModel, SwingEntityEditor> - Returns:
- a
OrderByinstance based on the sort order according to theAbstractEntityTableModel.sort()model, an emptyOptionalif unsorted
-