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

    Constructors
    Constructor
    Description
    SwingEntityEditModel(is.codion.framework.domain.entity.EntityType entityType, is.codion.framework.db.EntityConnectionProvider connectionProvider)
    Instantiates a new SwingEntityEditModel based on the given entity type.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    add(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey, Collection<is.codion.framework.domain.entity.Entity> entities)
     
    final void
    Clears all combobox models
    final <T> is.codion.swing.common.model.component.combobox.FilteredComboBoxModel<T>
    comboBoxModel(is.codion.framework.domain.entity.attribute.Column<T> column)
    Returns the FilteredComboBoxModel for 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 a EntityComboBoxModel for the given foreign key, override to provide a custom EntityComboBoxModel implementation.
    foreignKeyComboBoxModel(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey)
    Returns the EntityComboBoxModel for the given foreign key attribute.
    final void
    initializeComboBoxModels(is.codion.framework.domain.entity.attribute.Attribute<?>... attributes)
    Creates and refreshes combo box models for the given attributes.
    final void
    Refreshes all combobox models
    final void
    Refreshes all foreign key combobox models
    final void
    remove(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey, Collection<is.codion.framework.domain.entity.Entity> entities)
     
    protected void
    replaceForeignKey(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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SwingEntityEditModel

      public SwingEntityEditModel(is.codion.framework.domain.entity.EntityType entityType, is.codion.framework.db.EntityConnectionProvider connectionProvider)
      Instantiates a new SwingEntityEditModel based on the given entity type.
      Parameters:
      entityType - the type of the entity to base this SwingEntityEditModel on
      connectionProvider - the EntityConnectionProvider instance
  • 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 of ForeignKey a foreign key combo box model and in case of a Attribute 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

      public final EntityComboBoxModel foreignKeyComboBoxModel(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey)
      Returns the EntityComboBoxModel 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

      public final <T> is.codion.swing.common.model.component.combobox.FilteredComboBoxModel<T> comboBoxModel(is.codion.framework.domain.entity.attribute.Column<T> column)
      Returns the FilteredComboBoxModel for the given column. If one does not exist one is created.
      Type Parameters:
      T - the value type
      Parameters:
      column - the column
      Returns:
      a FilteredComboBoxModel for the given column
      See Also:
    • createForeignKeyComboBoxModel

      public EntityComboBoxModel createForeignKeyComboBoxModel(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey)
      Creates a EntityComboBoxModel for the given foreign key, override to provide a custom EntityComboBoxModel implementation. This method is called when creating a foreign key EntityComboBoxModel for the edit fields used when editing a single record. This default implementation returns a sorted EntityComboBoxModel with 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 a EntityComboBoxModel
      Returns:
      a EntityComboBoxModel for the given foreign key
      See Also:
    • 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 sorted FilteredComboBoxModel 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

      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:
      replaceForeignKey in class is.codion.framework.model.AbstractEntityEditModel