Module is.codion.framework.model
Package is.codion.framework.model
Class AbstractEntityEditor<R extends AbstractEntityEditor<R>>
java.lang.Object
is.codion.framework.model.AbstractEntityEditor<R>
- Type Parameters:
R- the editor type
- All Implemented Interfaces:
EntityEditor<R>
- Direct Known Subclasses:
SwingEntityEditor
public abstract class AbstractEntityEditor<R extends AbstractEntityEditor<R>>
extends Object
implements EntityEditor<R>
An abstract
EntityEditor implementation.-
Nested Class Summary
Nested classes/interfaces inherited from interface is.codion.framework.model.EntityEditor
EntityEditor.ComponentModels, EntityEditor.DetailEditors<R extends EntityEditor<R>>, EntityEditor.EditorEntity, EntityEditor.EditorPersistence, EntityEditor.EditorTask<T>, EntityEditor.EditorTasks, EntityEditor.EditorValue<T>, EntityEditor.EditorValues, EntityEditor.Exists, EntityEditor.Modified, EntityEditor.PersistEvents, EntityEditor.Present, EntityEditor.SearchModels, EntityEditor.Settings -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PropertyValue<Boolean> Specifies whetherAbstractEntityEditorinstances load registered detail editors on a background thread when setting, replacing or refreshing the active entity.Fields inherited from interface is.codion.framework.model.EntityEditor
PERSIST_FOREIGN_KEYS, PUBLISH_PERSISTENCE_EVENTS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractEntityEditor(EntityType entityType, EntityConnectionProvider connectionProvider, EntityEditor.ComponentModels componentModels) Instantiates anAbstractEntityEditor -
Method Summary
Modifier and TypeMethodDescriptionfinal Stateasync()Controls whether registered detail editors are loaded on a background thread when the active entity is set, replaced or refreshed on the user interface thread.protected EntityEditor.ComponentModelsfinal EntityConnectionProviderfinal Entitydelete()Note: This method must be called on the UI thread in case a panel has been based on this model.final Collection<Entity> delete(Collection<Entity> entities) Note: This method must be called on the UI thread in case a panel has been based on this model.final EntityEditor.DetailEditors<R> detail()final Entitiesentities()entity()final EntityDefinitionevents()protected voidexecute(EntityEditor.EditorTask<Entity> task) Executes the given task, by default this is done synchronously, override to provide async executionfinal Entityinsert()Note: This method must be called on the UI thread in case a panel has been based on this model.final Collection<Entity> insert(Collection<Entity> entities) Note: This method must be called on the UI thread in case a panel has been based on this model.final EntityEditor.Settingssettings()protected voidSupersedes any ongoing asynchronous execution.final EntityEditor.EditorTaskstasks()final EntityEditor.EditorTaskstasks(EntityConnection connection) final StringtoString()final Entityupdate()Note: This method must be called on the UI thread in case a panel has been based on this model.final Collection<Entity> update(Collection<Entity> entities) Note: This method must be called on the UI thread in case a panel has been based on this model.final voidvalidate()Validates the current state of the entityfinal voidValidates the value associated with the given attribute, using the underlying validator.final voidValidates the given entity, using the underlying validator.final voidvalidate(Collection<Entity> entities) Validates the given entities, using the underlying validator.final Value<EntityValidator> Controls the validator used by this editor.final <T> EntityEditor.EditorValue<T> values()
-
Field Details
-
ASYNC
Specifies whetherAbstractEntityEditorinstances load registered detail editors on a background thread when setting, replacing or refreshing the active entity. The active entity's own values are always applied synchronously; this only governs the loading of detail editors.Subclasses are responsible for following this directive.
- Value type: Boolean
- Default value: true
- See Also:
-
-
Constructor Details
-
AbstractEntityEditor
protected AbstractEntityEditor(EntityType entityType, EntityConnectionProvider connectionProvider, EntityEditor.ComponentModels componentModels) Instantiates anAbstractEntityEditor- Parameters:
entityType- the entity typeconnectionProvider- the connection providercomponentModels- the editor component models
-
-
Method Details
-
entities
- Specified by:
entitiesin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the underlying domain entities
-
entityDefinition
- Specified by:
entityDefinitionin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the entity definition
-
connectionProvider
- Specified by:
connectionProviderin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the connection provider
-
settings
- Specified by:
settingsin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the editor settings
-
events
- Specified by:
eventsin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the
EntityEditor.PersistEvents
-
entity
- Specified by:
entityin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the
EntityEditor.EditorEntityinstance
-
values
- Specified by:
valuesin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the
EntityEditor.EditorValues
-
validator
Description copied from interface:EntityEditorControls the validator used by this editor.- Specified by:
validatorin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the
Valuecontrolling the validator - See Also:
-
validate
Description copied from interface:EntityEditorValidates the current state of the entity- Specified by:
validatein interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Throws:
EntityValidationException- in case the entity is invalid
-
validate
Description copied from interface:EntityEditorValidates the value associated with the given attribute, using the underlying validator.- Specified by:
validatein interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Parameters:
attribute- the attribute the value is associated with- Throws:
AttributeValidationException- if the given value is not valid for the given attribute
-
validate
Description copied from interface:EntityEditorValidates the given entities, using the underlying validator. For entities of a type other than this editor is based on, their respective validators are used.- Specified by:
validatein interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Parameters:
entities- the entities to validate- Throws:
EntityValidationException- on finding the first invalid entity- See Also:
-
validate
Description copied from interface:EntityEditorValidates the given entity, using the underlying validator. For entities of a type other than this editor is based on, their respective validators are used.- Specified by:
validatein interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Parameters:
entity- the entity to validate- Throws:
EntityValidationException- in case the entity is invalid
-
value
Description copied from interface:EntityEditor- Specified by:
valuein interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Type Parameters:
T- the value type- Parameters:
attribute- the attribute- Returns:
- the
EntityEditor.EditorValuerepresenting the given attribute
-
searchModels
- Specified by:
searchModelsin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the
EntityEditor.SearchModelsinstance
-
detail
- Specified by:
detailin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the
EntityEditor.DetailEditorsinstance
-
persistence
- Specified by:
persistencein interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the
EntityEditor.EditorPersistenceused by this editor
-
tasks
- Specified by:
tasksin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the
EntityEditor.EditorTasksinstance
-
tasks
- Specified by:
tasksin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Parameters:
connection- the connection to use when persisting- Returns:
- the
EntityEditor.EditorTasksinstance
-
insert
Description copied from interface:EntityEditorNote: This method must be called on the UI thread in case a panel has been based on this model. Performs an insert on the active entity, sets the primary key values of the active entity according to the primary key of the inserted entity- Specified by:
insertin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the inserted entity
- Throws:
EntityValidationException- in case validation fails- See Also:
-
insert
public final Collection<Entity> insert(Collection<Entity> entities) throws EntityValidationException Description copied from interface:EntityEditorNote: This method must be called on the UI thread in case a panel has been based on this model. Performs an insert on the given entities.- Specified by:
insertin interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Parameters:
entities- the entities to insert- Returns:
- a list containing the inserted entities
- Throws:
EntityValidationException- in case validation fails- See Also:
-
update
Description copied from interface:EntityEditorNote: This method must be called on the UI thread in case a panel has been based on this model. Performs an update on the active entity- Specified by:
updatein interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the updated entity
- Throws:
EntityValidationException- in case validation fails- See Also:
-
update
public final Collection<Entity> update(Collection<Entity> entities) throws EntityValidationException Description copied from interface:EntityEditorNote: This method must be called on the UI thread in case a panel has been based on this model. Updates the given entities.- Specified by:
updatein interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Parameters:
entities- the entities to update- Returns:
- the updated entities
- Throws:
EntityValidationException- in case validation fails- See Also:
-
delete
Description copied from interface:EntityEditorNote: This method must be called on the UI thread in case a panel has been based on this model.- Specified by:
deletein interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Returns:
- the deleted entity
- See Also:
-
delete
Description copied from interface:EntityEditorNote: This method must be called on the UI thread in case a panel has been based on this model.- Specified by:
deletein interfaceEntityEditor<R extends AbstractEntityEditor<R>>- Parameters:
entities- the entities to delete- Returns:
- the deleted entities
- See Also:
-
toString
-
async
Controls whether registered detail editors are loaded on a background thread when the active entity is set, replaced or refreshed on the user interface thread. The active entity's own values are always applied synchronously; this governs only the loading of detail editors. When enabled (the default), setting or replacing the active entity returns before the detail subtree is in place.
Disabling makes detail loading synchronous as well, so the full detail subtree is in place before the operation returns. This is useful in tests, or when subsequent logic must observe the loaded detail subtree immediately rather than after
changedfires.- Returns:
- the
Statecontrolling whether detail editors are loaded asynchronously - See Also:
-
componentModels
- Returns:
- the
EntityEditor.ComponentModelsinstance
-
execute
Executes the given task, by default this is done synchronously, override to provide async execution- Parameters:
task- the task to execute
-
supersede
protected void supersede()Supersedes any ongoing asynchronous execution. Called before applying a synchronous state change (defaults/clear) so that an in-flight asynchronous set or replace does not complete afterwards and clobber it. The default implementation does nothing.
-