Class SwingEntityEditModel

java.lang.Object
is.codion.framework.model.AbstractEntityEditModel
is.codion.swing.framework.model.SwingEntityEditModel
All Implemented Interfaces:
EntityEditModel

public class SwingEntityEditModel extends AbstractEntityEditModel
A Swing implementation of EntityEditModel.
  • Constructor Details

  • Method Details

    • initializeComboBoxModels

      public final void initializeComboBoxModels(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(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> FilterComboBoxModel<T> comboBoxModel(Column<T> column)
      Returns the FilterComboBoxModel 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

      public EntityComboBoxModel createForeignKeyComboBoxModel(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> FilterComboBoxModel<T> createComboBoxModel(Column<T> column)
      Creates a combo box model containing the current values of the given column. This default implementation returns a sorted FilterComboBoxModel 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(ForeignKey foreignKey, Collection<Entity> entities)
      Description copied from interface: EntityEditModel
      Adds the given entities to all foreign key models based on that entity type
      Parameters:
      foreignKey - the foreign key
      entities - the values
    • remove

      public final void remove(ForeignKey foreignKey, Collection<Entity> entities)
      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 key
      entities - the values
    • replaceForeignKey

      protected void replaceForeignKey(ForeignKey foreignKey, Collection<Entity> entities)
      Description copied from class: AbstractEntityEditModel
      For every field referencing the given foreign key values, replaces that foreign key instance with the corresponding entity from values, useful when attribute values have been changed in the referenced entity that must be reflected in the edit model.
      Overrides:
      replaceForeignKey in class AbstractEntityEditModel
      Parameters:
      foreignKey - the foreign key attribute
      entities - the foreign key entities