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:
EntityEditModel
A Swing implementation of
EntityEditModel
.-
Nested Class Summary
Nested classes/interfaces inherited from interface is.codion.framework.model.EntityEditModel
EntityEditModel.Delete, EntityEditModel.EditableEntity, EntityEditModel.EditableValue<T>, EntityEditModel.Insert, EntityEditModel.Update
-
Field Summary
Fields inherited from interface is.codion.framework.model.EntityEditModel
PERSIST_FOREIGN_KEYS, POST_EDIT_EVENTS
-
Constructor Summary
ConstructorDescriptionSwingEntityEditModel
(EntityType entityType, EntityConnectionProvider connectionProvider) Instantiates a newSwingEntityEditModel
based on the given entity type. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
add
(ForeignKey foreignKey, Collection<Entity> entities) Adds the given entities to all foreign key models based on that entity typefinal void
Clears all combobox modelsfinal <T> FilterComboBoxModel<T>
comboBoxModel
(Column<T> column) Returns theFilterComboBoxModel
for the given column.<T> FilterComboBoxModel<T>
createComboBoxModel
(Column<T> column) Creates a combo box model containing the current values of the given column.createForeignKeyComboBoxModel
(ForeignKey foreignKey) Creates aEntityComboBoxModel
for the given foreign key, override to provide a customEntityComboBoxModel
implementation.final EntityComboBoxModel
foreignKeyComboBoxModel
(ForeignKey foreignKey) Returns theEntityComboBoxModel
for the given foreign key attribute.final void
initializeComboBoxModels
(Attribute<?>... attributes) Creates and refreshes combo box models for the given attributes.final void
Refreshes all combobox modelsfinal void
Refreshes all foreign key combobox modelsfinal void
remove
(ForeignKey foreignKey, Collection<Entity> entities) Removes the given entities from all foreign key models based on that entity type and clears any foreign key values referencing them.protected void
replaceForeignKey
(ForeignKey foreignKey, Collection<Entity> entities) For every field referencing the given foreign key values, replaces that foreign key instance with the corresponding entity fromvalues
, useful when attribute values have been changed in the referenced entity that must be reflected in the edit model.Methods inherited from class is.codion.framework.model.AbstractEntityEditModel
afterDelete, afterInsert, afterInsertUpdateOrDelete, afterUpdate, beforeDelete, beforeInsert, beforeUpdate, connection, connectionProvider, createDelete, createDelete, createForeignKeySearchModel, createInsert, createInsert, createUpdate, createUpdate, delete, delete, delete, deleteEnabled, entities, entity, entityDefinition, entityType, foreignKeySearchModel, insert, insert, insert, insertEnabled, notifyAfterDelete, notifyAfterInsert, notifyAfterUpdate, notifyBeforeDelete, notifyBeforeInsert, notifyBeforeUpdate, postEditEvents, readOnly, replace, toString, update, update, update, updateEnabled, updateMultipleEnabled, validate, validate, validate, value
-
Constructor Details
-
SwingEntityEditModel
Instantiates a newSwingEntityEditModel
based on the given entity type.- Parameters:
entityType
- the type of the entity to base thisSwingEntityEditModel
onconnectionProvider
- theEntityConnectionProvider
instance
-
-
Method Details
-
initializeComboBoxModels
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 ofForeignKey
a foreign key combo box model and in case of aAttribute
a 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
Returns theEntityComboBoxModel
for the given foreign key attribute. If one does not exist one is created.- Parameters:
foreignKey
- the foreign key attribute- Returns:
- a
EntityComboBoxModel
based on the entity referenced by the given foreign key attribute - See Also:
-
comboBoxModel
Returns theFilterComboBoxModel
for the given column. If one does not exist one is created.- Type Parameters:
T
- the value type- Parameters:
column
- the column- Returns:
- a
FilterComboBoxModel
for the given column - See Also:
-
createForeignKeyComboBoxModel
Creates aEntityComboBoxModel
for the given foreign key, override to provide a customEntityComboBoxModel
implementation. This method is called when creating a foreign keyEntityComboBoxModel
for the edit fields used when editing a single record. This default implementation returns a sortedEntityComboBoxModel
with the default null item caption 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
EntityComboBoxModel
for the given foreign key - See Also:
-
createComboBoxModel
Creates a combo box model containing the current values of the given column. This default implementation returns a sortedFilterComboBoxModel
with 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
Description copied from interface:EntityEditModel
Adds the given entities to all foreign key models based on that entity type- Parameters:
foreignKey
- the foreign keyentities
- the values
-
remove
Description copied from interface:EntityEditModel
Removes the given entities from all foreign key models based on that entity type and clears any foreign key values referencing them.- Parameters:
foreignKey
- the foreign keyentities
- the values
-
replaceForeignKey
Description copied from class:AbstractEntityEditModel
For every field referencing the given foreign key values, replaces that foreign key instance with the corresponding entity fromvalues
, useful when attribute values have been changed in the referenced entity that must be reflected in the edit model.- Overrides:
replaceForeignKey
in classAbstractEntityEditModel
- Parameters:
foreignKey
- the foreign key attributeentities
- the foreign key entities
-