Interface EntityComboBoxModel

All Superinterfaces:
FilterComboBoxModel<Entity>, FilterModel<Entity>
All Known Subinterfaces:
SwingEntityComboBoxModel

public interface EntityComboBoxModel extends FilterComboBoxModel<Entity>

A ComboBoxModel based on an Entity, showing by default all the entities in the underlying table.

To filter a EntityComboBoxModel use filter() to set a Predicate or configure ForeignKey based filtering.

See Also:
  • Field Details

    • PERSISTENCE_AWARE

      static final PropertyValue<Boolean> PERSISTENCE_AWARE
      Specifies whether entity combo box models respond to entity persistence events, by adding new entities, replacing updated and removing deleted ones.

      A model with a condition() adds only the inserted entities passing it, and keeps only the updated ones still passing it, adding those now passing it, both selected by their primary keys, asynchronously when refreshing is. An updated entity no longer passing it is removed, unless selected, in which case it stays until the next refresh.

      • Value type: Boolean
      • Default value: true
      See Also:
  • Method Details

    • connection

      EntityConnection connection()
      Returns:
      the connection used by this combo box model
    • entityDefinition

      EntityDefinition entityDefinition()
      Returns:
      the underlying EntityDefinition
    • select

      void select(Entity.Key primaryKey)
      Selects the entity with the given primary key, whether included or excluded. If the entity is not available in the model this method returns silently without changing the selection.
      Parameters:
      primaryKey - the primary key of the entity to select
    • condition

      Value<Supplier<Condition>> condition()

      Controls the condition supplier used when querying data, setting this to null reverts to the condition specifying all underlying entities.

      The condition supplier may not return null, doing so will cause an exception when refreshing the model items.

      Returns:
      a value controlling the condition supplier
    • filter

      Returns:
      the EntityComboBoxModel.Filter instance
    • selector

      <T> Value<T> selector(Attribute<T> attribute)
      Creates a Value linked to the selected entity via the value of the given attribute.
      Type Parameters:
      T - the attribute type
      Parameters:
      attribute - the attribute
      Returns:
      a new Value for selecting items by attribute value
    • builder

      Returns:
      a EntityComboBoxModel.Builder.EntityTypeStep instance