Package is.codion.swing.framework.model
Class SwingEntityEditModel
java.lang.Object
is.codion.framework.model.AbstractEntityEditModel
is.codion.swing.framework.model.SwingEntityEditModel
- All Implemented Interfaces:
is.codion.framework.model.EntityEditModel
public class SwingEntityEditModel
extends is.codion.framework.model.AbstractEntityEditModel
A Swing implementation of
EntityEditModel.-
Nested Class Summary
Nested classes/interfaces inherited from interface is.codion.framework.model.EntityEditModel
is.codion.framework.model.EntityEditModel.Delete, is.codion.framework.model.EntityEditModel.Insert, is.codion.framework.model.EntityEditModel.Update -
Field Summary
Fields inherited from interface is.codion.framework.model.EntityEditModel
EDIT_EVENTS, PERSIST_FOREIGN_KEYS, WARN_ABOUT_UNSAVED_DATA -
Constructor Summary
ConstructorsConstructorDescriptionSwingEntityEditModel(is.codion.framework.domain.entity.EntityType entityType, is.codion.framework.db.EntityConnectionProvider connectionProvider) Instantiates a newSwingEntityEditModelbased on the given entity type. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidadd(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey, Collection<is.codion.framework.domain.entity.Entity> entities) final voidClears all combobox modelsfinal <T> is.codion.swing.common.model.component.combobox.FilteredComboBoxModel<T>comboBoxModel(is.codion.framework.domain.entity.attribute.Column<T> column) Returns theFilteredComboBoxModelfor the given column.<T> is.codion.swing.common.model.component.combobox.FilteredComboBoxModel<T>createComboBoxModel(is.codion.framework.domain.entity.attribute.Column<T> column) Creates a combo box model containing the current values of the given column.createForeignKeyComboBoxModel(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey) Creates aEntityComboBoxModelfor the given foreign key, override to provide a customEntityComboBoxModelimplementation.final EntityComboBoxModelforeignKeyComboBoxModel(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey) Returns theEntityComboBoxModelfor the given foreign key attribute.final voidinitializeComboBoxModels(is.codion.framework.domain.entity.attribute.Attribute<?>... attributes) Creates and refreshes combo box models for the given attributes.final voidRefreshes all combobox modelsfinal voidRefreshes all foreign key combobox modelsfinal voidremove(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey, Collection<is.codion.framework.domain.entity.Entity> entities) protected voidreplaceForeignKey(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey, Collection<is.codion.framework.domain.entity.Entity> entities) Methods inherited from class is.codion.framework.model.AbstractEntityEditModel
afterDeleteEvent, afterInsertEvent, afterUpdateEvent, beforeDeleteEvent, beforeInsertEvent, beforeUpdateEvent, confirmOverwriteEvent, connection, connectionProvider, createDelete, createDelete, createForeignKeySearchModel, createInsert, createInsert, createUpdate, createUpdate, defaults, defaultValue, delete, delete, delete, deleteEnabled, editEvent, editEvents, entities, entity, entityDefinition, entityEvent, entityType, exists, existsPredicate, foreignKeySearchModel, get, insert, insert, insert, insertEnabled, insertUpdateOrDeleteEvent, isNotNull, isNull, modified, modified, modifiedPredicate, notifyAfterDelete, notifyAfterInsert, notifyAfterUpdate, notifyBeforeDelete, notifyBeforeInsert, notifyBeforeUpdate, nullable, optional, overwriteWarning, persist, primaryKeyNull, put, readOnly, refresh, remove, replace, revert, revert, set, toString, update, update, update, updateEnabled, updateModifiedState, updateMultipleEnabled, valid, valid, validate, validate, validate, validate, validator, value, valueEvent, valueEvent
-
Constructor Details
-
SwingEntityEditModel
public SwingEntityEditModel(is.codion.framework.domain.entity.EntityType entityType, is.codion.framework.db.EntityConnectionProvider connectionProvider) Instantiates a newSwingEntityEditModelbased on the given entity type.- Parameters:
entityType- the type of the entity to base thisSwingEntityEditModelonconnectionProvider- theEntityConnectionProviderinstance
-
-
Method Details
-
initializeComboBoxModels
public final void initializeComboBoxModels(is.codion.framework.domain.entity.attribute.Attribute<?>... attributes) Creates and refreshes combo box models for the given attributes. Doing this avoids refreshing the data on the EDT when the actual combo boxes are initialized. In case ofForeignKeya foreign key combo box model and in case of aAttributea attribute combo box model.- Parameters:
attributes- the attributes for which to initialize combo box models- See Also:
-
refreshForeignKeyComboBoxModels
public final void refreshForeignKeyComboBoxModels()Refreshes all foreign key combobox models -
refreshComboBoxModels
public final void refreshComboBoxModels()Refreshes all combobox models -
clearComboBoxModels
public final void clearComboBoxModels()Clears all combobox models -
foreignKeyComboBoxModel
public final EntityComboBoxModel foreignKeyComboBoxModel(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey) Returns theEntityComboBoxModelfor the given foreign key attribute. If one does not exist one is created.- Parameters:
foreignKey- the foreign key attribute- Returns:
- a
EntityComboBoxModelbased on the entity referenced by the given foreign key attribute - See Also:
-
comboBoxModel
public final <T> is.codion.swing.common.model.component.combobox.FilteredComboBoxModel<T> comboBoxModel(is.codion.framework.domain.entity.attribute.Column<T> column) Returns theFilteredComboBoxModelfor the given column. If one does not exist one is created.- Type Parameters:
T- the value type- Parameters:
column- the column- Returns:
- a
FilteredComboBoxModelfor the given column - See Also:
-
createForeignKeyComboBoxModel
public EntityComboBoxModel createForeignKeyComboBoxModel(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey) Creates aEntityComboBoxModelfor the given foreign key, override to provide a customEntityComboBoxModelimplementation. This method is called when creating a foreign keyEntityComboBoxModelfor the edit fields used when editing a single record. This default implementation returns a sortedEntityComboBoxModelwith the default nullValueCaption if the underlying attribute is nullable. If the foreign key has select attributes defined, those are set in the combo box model.- Parameters:
foreignKey- the foreign key for which to create aEntityComboBoxModel- Returns:
- a
EntityComboBoxModelfor the given foreign key - See Also:
-
FilteredComboBoxModel.COMBO_BOX_NULL_CAPTIONAttributeDefinition.nullable()EntityComboBoxModel.attributes()ForeignKeyDefinition.attributes()
-
createComboBoxModel
public <T> is.codion.swing.common.model.component.combobox.FilteredComboBoxModel<T> createComboBoxModel(is.codion.framework.domain.entity.attribute.Column<T> column) Creates a combo box model containing the current values of the given column. This default implementation returns a sortedFilteredComboBoxModelwith the default nullValueItem if the underlying column is nullable- Type Parameters:
T- the value type- Parameters:
column- the column- Returns:
- a combo box model based on the given column
-
add
public final void add(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey, Collection<is.codion.framework.domain.entity.Entity> entities) -
remove
public final void remove(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey, Collection<is.codion.framework.domain.entity.Entity> entities) -
replaceForeignKey
protected void replaceForeignKey(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey, Collection<is.codion.framework.domain.entity.Entity> entities) - Overrides:
replaceForeignKeyin classis.codion.framework.model.AbstractEntityEditModel
-