Class EntitySearchField

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextField
is.codion.swing.common.ui.component.text.HintTextField
is.codion.swing.framework.ui.component.EntitySearchField
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, SwingConstants

public final class EntitySearchField extends is.codion.swing.common.ui.component.text.HintTextField
A UI component based on the EntitySearchModel. The search is triggered by the ENTER key and behaves in the following way: If the search result is empty a message is shown, if a single entity fits the condition then that entity is selected, otherwise a component displaying the entities fitting the condition is shown in a dialog allowing either a single or multiple selection based on the search model settings. EntitySearchField.ListSelector is the default EntitySearchField.Selector. Use builder(EntitySearchModel) or builder(EntityType, EntityConnectionProvider) for a builder instance.
See Also:
  • Field Details

  • Method Details

    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JTextComponent
    • model

      public is.codion.framework.model.EntitySearchModel model()
      Returns:
      the search model this search field is based on
    • transferFocusOnEnter

      public void transferFocusOnEnter(boolean transferFocusOnEnter)
      Parameters:
      transferFocusOnEnter - true if this component should transfer focus on Enter
    • searchIndicator

      public void searchIndicator(EntitySearchField.SearchIndicator searchIndicator)
      Parameters:
      searchIndicator - the search indicator type
      See Also:
    • selectorFactory

      public void selectorFactory(Function<is.codion.framework.model.EntitySearchModel,EntitySearchField.Selector> selectorFactory)
      Sets the factory for the EntitySearchField.Selector responsible for selecting items from the search result.
      Parameters:
      selectorFactory - a factory for the EntitySearchField.Selector implementation to use when presenting a selection dialog to the user
      Throws:
      NullPointerException - in case selectorFactory is null
    • searchOnFocusLost

      public is.codion.common.state.State searchOnFocusLost()
      Returns:
      the State controlling whether this field should trigger a search when it loses focus
    • singleSelectionValue

      public is.codion.swing.common.ui.component.value.ComponentValue<is.codion.framework.domain.entity.Entity,EntitySearchField> singleSelectionValue()
      Returns:
      a ComponentValue for selecting a single entity
    • multiSelectionValue

      public is.codion.swing.common.ui.component.value.ComponentValue<Collection<is.codion.framework.domain.entity.Entity>,EntitySearchField> multiSelectionValue()
      Returns:
      a ComponentValue for selecting multiple entities
    • builder

      public static EntitySearchField.Builder builder(is.codion.framework.domain.entity.EntityType entityType, is.codion.framework.db.EntityConnectionProvider connectionProvider)
      Instantiates a new EntitySearchField.Builder
      Parameters:
      entityType - the entity type
      connectionProvider - the connection provider
      Returns:
      a new builder instance
    • builder

      public static EntitySearchField.Builder builder(is.codion.framework.model.EntitySearchModel searchModel)
      Instantiates a new EntitySearchField.Builder
      Parameters:
      searchModel - the search model on which to base the search field
      Returns:
      a new builder instance
    • listSelector

      public static EntitySearchField.ListSelector listSelector(is.codion.framework.model.EntitySearchModel searchModel)
      Parameters:
      searchModel - the search model
      Returns:
      a EntitySearchField.Selector based on a JList.
    • tableSelector

      public static EntitySearchField.TableSelector tableSelector(is.codion.framework.model.EntitySearchModel searchModel)
      Parameters:
      searchModel - the search model
      Returns:
      a EntitySearchField.Selector based on a FilteredTable.