Module is.codion.framework.model
Package is.codion.framework.model
Class AbstractEntityTableModel<E extends EntityEditModel>
java.lang.Object
is.codion.framework.model.AbstractEntityTableModel<E>
- Type Parameters:
E
- theEntityEditModel
type
- All Implemented Interfaces:
FilterModel<Entity>
,EntityTableModel<E>
- Direct Known Subclasses:
SwingEntityTableModel
public abstract class AbstractEntityTableModel<E extends EntityEditModel>
extends Object
implements EntityTableModel<E>
An abstract
EntityTableModel
implementation-
Nested Class Summary
Nested classes/interfaces inherited from interface is.codion.framework.model.EntityTableModel
EntityTableModel.OnInsert
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.framework.model.EntityTableModel
HANDLE_EDIT_EVENTS, ON_INSERT
Fields inherited from interface is.codion.common.model.FilterModel
ASYNC_REFRESH
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractEntityTableModel
(E editModel, FilterModel<Entity> filterModel) protected
AbstractEntityTableModel
(E editModel, FilterModel<Entity> filterModel, EntityQueryModel queryModel) -
Method Summary
Modifier and TypeMethodDescriptionfinal EntityConnection
Do not cache or keep the connection returned by this method in a long living field, since it may become invalid and thereby unusable.final EntityConnectionProvider
final Collection<Entity>
Deletes the selected entitiesfinal State
editable()
final <C extends E>
Cfinal Entities
entities()
final EntityDefinition
final EntityType
protected FilterModel<Entity>
final State
final FilterModel.Items<Entity>
items()
final Value<EntityTableModel.OnInsert>
onInsert()
protected abstract void
onRowsUpdated
(int fromIndex, int toIndex) Notifies all listeners that the given rows have changedfinal EntityQueryModel
final void
refresh()
Refreshes the items in this model using itsFilterModel.Refresher
.final void
refresh
(Collection<Entity.Key> keys) Refreshes the entities with the given keys by re-selecting them from the underlying database.final void
refresh
(Consumer<Collection<Entity>> onRefresh) Refreshes the data in this filter model using itsFilterModel.Refresher
.final FilterModel.Refresher<Entity>
final State
final void
replace
(ForeignKey foreignKey, Collection<Entity> foreignKeyValues) For every entity in this table model, replaces the foreign key instance bearing the primary key with the corresponding entity fromforeignKeyValues
, useful when attribute values have been changed in the referenced entity that must be reflected in the table model.final void
replace
(Collection<Entity> entities) Replaces the given entities in this table modelfinal void
select
(Collection<Entity.Key> keys) Selects entities according to the primary keys inprimaryKeys
final String
toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface is.codion.framework.model.EntityTableModel
selection
-
Constructor Details
-
AbstractEntityTableModel
- Parameters:
editModel
- the edit modelfilterModel
- the filter model
-
AbstractEntityTableModel
protected AbstractEntityTableModel(E editModel, FilterModel<Entity> filterModel, EntityQueryModel queryModel) - Parameters:
editModel
- the edit modelfilterModel
- the filter modelqueryModel
- the table query model- Throws:
IllegalArgumentException
- in case the edit and query model entity types do not match
-
-
Method Details
-
entities
- Specified by:
entities
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the underlying domain entities
-
entityDefinition
- Specified by:
entityDefinition
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the definition of the underlying entity
-
toString
-
onInsert
- Specified by:
onInsert
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the
Value
controlling the action to perform when entities are inserted via the associated edit model - See Also:
-
removeDeleted
- Specified by:
removeDeleted
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the
State
controlling whether entities that are deleted via the associated edit model should be automatically removed from this table model
-
handleEditEvents
- Specified by:
handleEditEvents
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the
State
controlling whether this table model handles entity edit events, by replacing updated entities - See Also:
-
entityType
- Specified by:
entityType
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the type of the entity this table model is based on
-
editModel
- Specified by:
editModel
in interfaceEntityTableModel<E extends EntityEditModel>
- Type Parameters:
C
- the edit model type Returns theEntityEditModel
associated with this table model- Returns:
- the edit model associated with this table model
-
connectionProvider
- Specified by:
connectionProvider
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the connection provider used by this table model
-
connection
Description copied from interface:EntityTableModel
Do not cache or keep the connection returned by this method in a long living field, since it may become invalid and thereby unusable.- Specified by:
connection
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the connection used by this table model
-
queryModel
- Specified by:
queryModel
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the underlying query model
-
editable
- Specified by:
editable
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the
State
controlling whether this table model is editable
-
replace
Description copied from interface:EntityTableModel
Replaces the given entities in this table model- Specified by:
replace
in interfaceEntityTableModel<E extends EntityEditModel>
- Parameters:
entities
- the entities to replace
-
refresh
Description copied from interface:EntityTableModel
Refreshes the entities with the given keys by re-selecting them from the underlying database.- Specified by:
refresh
in interfaceEntityTableModel<E extends EntityEditModel>
- Parameters:
keys
- the keys of the entities to refresh
-
select
Description copied from interface:EntityTableModel
Selects entities according to the primary keys inprimaryKeys
- Specified by:
select
in interfaceEntityTableModel<E extends EntityEditModel>
- Parameters:
keys
- the primary keys of the entities to select
-
deleteSelected
Description copied from interface:EntityTableModel
Deletes the selected entities- Specified by:
deleteSelected
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the deleted entities
- Throws:
DatabaseException
- in case of a database exception
-
items
- Specified by:
items
in interfaceFilterModel<E extends EntityEditModel>
- Returns:
- the model items
-
refresher
- Specified by:
refresher
in interfaceFilterModel<E extends EntityEditModel>
- Returns:
- this models Refresher instance
-
refresh
public final void refresh()Description copied from interface:FilterModel
Refreshes the items in this model using itsFilterModel.Refresher
.- Specified by:
refresh
in interfaceFilterModel<E extends EntityEditModel>
- See Also:
-
refresh
Description copied from interface:FilterModel
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.- Specified by:
refresh
in interfaceFilterModel<E extends EntityEditModel>
- Parameters:
onRefresh
- called after a successful refresh, may be null- See Also:
-
replace
Description copied from interface:EntityTableModel
For every entity in this table model, replaces the foreign key instance bearing the primary key with the corresponding entity fromforeignKeyValues
, useful when attribute values have been changed in the referenced entity that must be reflected in the table model.- Specified by:
replace
in interfaceEntityTableModel<E extends EntityEditModel>
- Parameters:
foreignKey
- the foreign keyforeignKeyValues
- the foreign key entities
-
filterModel
- Returns:
- the underlying filter model
-
onRowsUpdated
protected abstract void onRowsUpdated(int fromIndex, int toIndex) Notifies all listeners that the given rows have changed- Parameters:
fromIndex
- the from indextoIndex
- the to index
-