Module is.codion.framework.model
Package is.codion.framework.model
Class AbstractEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>>
java.lang.Object
is.codion.framework.model.AbstractEntityTableModel<E,R>
- Type Parameters:
E- theEntityEditModeltypeR- theEntityEditortype
- All Implemented Interfaces:
FilterTableModel<Entity,,Attribute<?>> FilterModel<Entity>,EntityTableModel<E,R>
- Direct Known Subclasses:
SwingEntityTableModel
public abstract class AbstractEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>>
extends Object
implements EntityTableModel<E,R>
An abstract
EntityTableModel implementation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classAn abstractEntityTableModel.EntityRowEditorimplementation.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.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> -
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
ConstructorsModifierConstructorDescriptionprotectedAbstractEntityTableModel(E editModel, FilterTableModel<Entity, Attribute<?>> filterModel) protectedAbstractEntityTableModel(E editModel, EntityQueryModel queryModel, FilterTableModel<Entity, Attribute<?>> filterModel) -
Method Summary
Modifier and TypeMethodDescriptionfinal FilterTableModel.TableColumns<Entity, Attribute<?>> columns()final EntityConnectionDo not cache or keep the connection returned by this method in a long living field, since it may become invalid and thereby unusable.final EntityConnectionProviderfinal EReturns theEntityEditModelassociated with this table modelfinal Reditor()Returns theEntityEditorassociated with this table modelfinal Entitiesentities()final EntityDefinitionfinal EntityTypefinal FilterTableModel.Export<Attribute<?>> export()protected static Supplier<Map<Attribute<?>, ConditionModel<?>>> filterConditions(EntityDefinition entityDefinition) protected FilterTableModel<Entity, Attribute<?>> final TableConditionModel<Attribute<?>> filters()final FilterModel.Items<Entity> items()itemValidator(EntityType entityType) final Value<EntityTableModel.OnInsert> onInsert()protected abstract voidonRowsUpdated(int fromIndex, int toIndex) Notifies all listeners that the given rows have changedfinal StateSpecifies whether the currentFilterTableModel.sort()order is used as a basis for theEntityQueryModelorder by clause.final EntityQueryModelquery()final Statefinal voidreplace(Collection<Entity> entities) Replaces the given entities in this table modelfinal voidselect(Collection<Entity.Key> keys) Selects entities according to the primary keys inprimaryKeysfinal FilterTableSort<Entity, Attribute<?>> sort()protected static FilterTableModel.TableColumns<Entity, Attribute<?>> tableColumns(EntityDefinition entityDefinition) final StringtoString()protected voidupdated(ForeignKey foreignKey, Map<Entity.Key, Entity> entities) Called when entities of the type referenced by the given foreign key are updated.final FilterTableModel.ColumnValues<Attribute<?>> values()Provides access to column valuesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface is.codion.framework.model.EntityTableModel
refresh, rowEditorMethods inherited from interface is.codion.common.model.component.table.FilterTableModel
selection
-
Constructor Details
-
AbstractEntityTableModel
- Parameters:
editModel- the edit modelfilterModel- the filter model
-
AbstractEntityTableModel
protected AbstractEntityTableModel(E editModel, EntityQueryModel queryModel, FilterTableModel<Entity, Attribute<?>> filterModel) - Parameters:
editModel- the edit modelqueryModel- the table query modelfilterModel- the filter model- Throws:
IllegalArgumentException- in case the edit and query model entity types do not match
-
-
Method Details
-
entities
- Specified by:
entitiesin interfaceEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the underlying domain entities
-
entityDefinition
- Specified by:
entityDefinitionin interfaceEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the definition of the underlying entity
-
toString
-
onInsert
- Specified by:
onInsertin interfaceEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the
Valuecontrolling the action to perform when entities are inserted via the associated edit model - See Also:
-
removeDeleted
- Specified by:
removeDeletedin interfaceEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the
Statecontrolling whether entities that are deleted via the associated edit model should be automatically removed from this table model
-
entityType
- Specified by:
entityTypein interfaceEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the type of the entity this table model is based on
-
editModel
Description copied from interface:EntityTableModelReturns theEntityEditModelassociated with this table model- Specified by:
editModelin interfaceEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the edit model associated with this table model
-
editor
Description copied from interface:EntityTableModelReturns theEntityEditorassociated with this table model- Specified by:
editorin interfaceEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the editor associated with this table model
-
connectionProvider
- Specified by:
connectionProviderin interfaceEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the connection provider used by this table model
-
connection
Description copied from interface:EntityTableModelDo 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:
connectionin interfaceEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the connection used by this table model
-
orderQuery
Description copied from interface:EntityTableModelSpecifies whether the currentFilterTableModel.sort()order is used as a basis for theEntityQueryModelorder by clause. Note that this only applies to column attributes.- Specified by:
orderQueryin interfaceEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the
Statecontrolling whether the current sort order should be used as a basis for the query order by clause
-
query
- Specified by:
queryin interfaceEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the underlying query model
-
replace
Description copied from interface:EntityTableModelReplaces the given entities in this table model- Specified by:
replacein interfaceEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Parameters:
entities- the entities to replace
-
select
Description copied from interface:EntityTableModelSelects entities according to the primary keys inprimaryKeys- Specified by:
selectin interfaceEntityTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Parameters:
keys- the primary keys of the entities to select
-
items
- Specified by:
itemsin interfaceFilterModel<E extends EntityEditModel<R>>- Returns:
- the model items
-
values
Description copied from interface:FilterTableModelProvides access to column values- Specified by:
valuesin interfaceFilterTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the
FilterTableModel.ColumnValues
-
columns
- Specified by:
columnsin interfaceFilterTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the table columns
-
filters
- Specified by:
filtersin interfaceFilterTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the
TableConditionModelused to filter this table model
-
sort
- Specified by:
sortin interfaceFilterModel<E extends EntityEditModel<R>>- Specified by:
sortin interfaceFilterTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- the sort
-
export
- Specified by:
exportin interfaceFilterTableModel<E extends EntityEditModel<R>,R extends EntityEditor<R>> - Returns:
- a
FilterTableModel.Exportinstance for exporting the table model data
-
filterModel
- Returns:
- the underlying model
-
tableColumns
protected static FilterTableModel.TableColumns<Entity,Attribute<?>> tableColumns(EntityDefinition entityDefinition) - Parameters:
entityDefinition- the entity definition- Returns:
FilterTableModel.TableColumnsbased on the visible attributes of the given entity definition
-
filterConditions
protected static Supplier<Map<Attribute<?>,ConditionModel<?>>> filterConditions(EntityDefinition entityDefinition) - Parameters:
entityDefinition- the entity definition- Returns:
- a
Supplierproviding the filter condition models based on the given entity definition
-
itemValidator
- Parameters:
entityType- the entity type- Returns:
- a
Predicatevalidating that items are of the given entity type
-
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
-
updated
Called when entities of the type referenced by the given foreign key are updated.The foreign key values are replaced in place on the affected rows, which are then repainted. Note that the rows are neither re-sorted nor re-filtered, so a table sorted or filtered by the given foreign key retains its order and membership until the next sort or refresh.
- Parameters:
foreignKey- the foreign keyentities- the updated entities, mapped to their original primary key
-