Class ComboBoxImpl<V>

All Implemented Interfaces:
AttachNotifier, Buffered, ComboBox<V>, Component, Component.BelongToFrame, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper, HasValueSource<V>, Field<V>, HasContextHelp, HasDebugId, HasEnterPressHandler, HasFilterMode, HasHtmlCaption, HasHtmlDescription, HasHtmlSanitizer, HasInputPrompt, HasOptionCaptionProvider<V>, HasOptionIconProvider<V>, HasOptionImageProvider<V>, HasOptionStyleProvider<V>, HasValidator<V>, HasValue<V>, OptionsField<V,V>, Requirable, Validatable, org.springframework.beans.factory.InitializingBean

public class ComboBoxImpl<V> extends AbstractField<JmixComboBox<V>,V,V> implements ComboBox<V>, org.springframework.beans.factory.InitializingBean
  • Field Details

  • Constructor Details

    • ComboBoxImpl

      public ComboBoxImpl()
  • Method Details

    • createComponent

      protected JmixComboBox<V> createComponent()
    • setMetadataTools

      @Autowired public void setMetadataTools(MetadataTools metadataTools)
    • setIconResolver

      @Autowired public void setIconResolver(IconResolver iconResolver)
    • handleClearShortcut

      protected void handleClearShortcut(Object sender, Object target)
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • initComponent

      protected void initComponent(JmixComboBox<V> component)
    • generateDefaultItemCaption

      protected String generateDefaultItemCaption(V item)
    • generateItemCaption

      protected String generateItemCaption(@Nullable V item)
    • generateItemStylename

      @Nullable protected String generateItemStylename(V item)
    • filterItemTest

      protected boolean filterItemTest(String itemCaption, String filterText)
    • valueBindingConnected

      protected void valueBindingConnected(ValueSource<V> valueSource)
      Overrides:
      valueBindingConnected in class AbstractValueComponent<JmixComboBox<V>,V,V>
    • getValue

      @Nullable public V getValue()
      Specified by:
      getValue in interface HasValue<V>
      Overrides:
      getValue in class AbstractValueComponent<JmixComboBox<V>,V,V>
    • setFilterMode

      public void setFilterMode(HasFilterMode.FilterMode filterMode)
      Description copied from interface: HasFilterMode
      Sets filter mode for the dropdown list in the field.
      Specified by:
      setFilterMode in interface HasFilterMode
      Parameters:
      filterMode - filter mode to set
    • getFilterMode

      public HasFilterMode.FilterMode getFilterMode()
      Specified by:
      getFilterMode in interface HasFilterMode
      Returns:
      filter mode for the dropdown list in the field
    • setRequired

      public void setRequired(boolean required)
      Description copied from interface: Requirable
      Sets whether the component must contain a non-null value.
      Specified by:
      setRequired in interface Requirable
      Overrides:
      setRequired in class AbstractField<JmixComboBox<V>,V,V>
      Parameters:
      required - required
    • getNullSelectionCaption

      public String getNullSelectionCaption()
      Specified by:
      getNullSelectionCaption in interface ComboBox<V>
      Returns:
      the null selection caption, not null
    • setNullSelectionCaption

      public void setNullSelectionCaption(String nullOption)
      Description copied from interface: ComboBox
      Sets the null selection caption.

      The empty string "" is the default null selection caption.

      If null selection is allowed then the null item will be shown with the given caption.

      Specified by:
      setNullSelectionCaption in interface ComboBox<V>
      Parameters:
      nullOption - the caption to set, not null
    • getOptions

      @Nullable public Options<V> getOptions()
      Specified by:
      getOptions in interface OptionsField<V,V>
      Returns:
      options object
    • setOptions

      public void setOptions(@Nullable Options<V> options)
      Description copied from interface: OptionsField
      Sets options for UI component.
      Specified by:
      setOptions in interface OptionsField<V,V>
      Parameters:
      options - options
      See Also:
    • setItemsToPresentation

      protected void setItemsToPresentation(Stream<V> options)
    • setOptionCaptionProvider

      public void setOptionCaptionProvider(@Nullable Function<? super V,String> optionCaptionProvider)
      Description copied from interface: HasOptionCaptionProvider
      Sets function that provides caption for option items.
      Specified by:
      setOptionCaptionProvider in interface HasOptionCaptionProvider<V>
      Parameters:
      optionCaptionProvider - caption provider for options
    • getOptionCaptionProvider

      @Nullable public Function<? super V,String> getOptionCaptionProvider()
      Specified by:
      getOptionCaptionProvider in interface HasOptionCaptionProvider<V>
      Returns:
      caption provider for options
    • isTextInputAllowed

      public boolean isTextInputAllowed()
      Specified by:
      isTextInputAllowed in interface ComboBox<V>
      Returns:
      true if text input allowed
    • setTextInputAllowed

      public void setTextInputAllowed(boolean textInputAllowed)
      Description copied from interface: ComboBox
      Sets whether it is possible to input text into the field or whether the field area of the component is just used to show what is selected.
      Specified by:
      setTextInputAllowed in interface ComboBox<V>
    • getEnterPressHandler

      @Nullable public Consumer<HasEnterPressHandler.EnterPressEvent> getEnterPressHandler()
      Specified by:
      getEnterPressHandler in interface HasEnterPressHandler
      Returns:
      an ENTER press handler
    • setEnterPressHandler

      public void setEnterPressHandler(@Nullable Consumer<HasEnterPressHandler.EnterPressEvent> handler)
      Description copied from interface: HasEnterPressHandler
      Sets an ENTER press handler.
      Specified by:
      setEnterPressHandler in interface HasEnterPressHandler
      Parameters:
      handler - an ENTER press handler to set
    • onEnterPressed

      protected void onEnterPressed(String text)
    • getPageLength

      public int getPageLength()
      Specified by:
      getPageLength in interface ComboBox<V>
      Returns:
      the page length of the suggestion popup.
    • setPageLength

      public void setPageLength(int pageLength)
      Description copied from interface: ComboBox
      Sets the page length for the suggestion popup. Setting the page length to 0 will disable suggestion popup paging (all items visible).
      Specified by:
      setPageLength in interface ComboBox<V>
      Parameters:
      pageLength - the pageLength to set
    • setNullOptionVisible

      public void setNullOptionVisible(boolean nullOptionVisible)
      Description copied from interface: ComboBox
      Sets visibility for first null element in suggestion popup.
      Specified by:
      setNullOptionVisible in interface ComboBox<V>
    • isNullOptionVisible

      public boolean isNullOptionVisible()
      Specified by:
      isNullOptionVisible in interface ComboBox<V>
      Returns:
      true if first null element is visible.
    • setOptionIconProvider

      public void setOptionIconProvider(@Nullable Function<? super V,String> optionIconProvider)
      Description copied from interface: HasOptionIconProvider
      Sets a function that provides an icon for options.
      Specified by:
      setOptionIconProvider in interface HasOptionIconProvider<V>
      Parameters:
      optionIconProvider - icon provider for options to set
    • getOptionIconProvider

      @Nullable public Function<? super V,String> getOptionIconProvider()
      Specified by:
      getOptionIconProvider in interface HasOptionIconProvider<V>
      Returns:
      options icon provider or null if not defined
    • generateOptionIcon

      @Nullable protected com.vaadin.server.Resource generateOptionIcon(V item)
    • setOptionImageProvider

      public void setOptionImageProvider(@Nullable Function<? super V,Resource> optionImageProvider)
      Description copied from interface: HasOptionImageProvider
      Sets a function that provides option images.
      Specified by:
      setOptionImageProvider in interface HasOptionImageProvider<V>
      Parameters:
      optionImageProvider - options image provider
      See Also:
    • getOptionImageProvider

      @Nullable public Function<? super V,Resource> getOptionImageProvider()
      Specified by:
      getOptionImageProvider in interface HasOptionImageProvider<V>
      Returns:
      options image provider.
    • generateOptionImage

      @Nullable protected com.vaadin.server.Resource generateOptionImage(V item)
    • getInputPrompt

      @Nullable public String getInputPrompt()
      Specified by:
      getInputPrompt in interface HasInputPrompt
      Returns:
      current input prompt.
    • setInputPrompt

      public void setInputPrompt(@Nullable String inputPrompt)
      Description copied from interface: HasInputPrompt
      Sets the input prompt - a textual prompt that is displayed when the field would otherwise be empty, to prompt the user for input.
      Specified by:
      setInputPrompt in interface HasInputPrompt
      Parameters:
      inputPrompt - input prompt
    • commit

      public void commit()
      Description copied from interface: Buffered
      Updates all changes since the previous commit to the data source.
      Specified by:
      commit in interface Buffered
      Overrides:
      commit in class AbstractValueComponent<JmixComboBox<V>,V,V>
    • discard

      public void discard()
      Description copied from interface: Buffered
      Discards all changes since last commit. The object updates its value from the data source.
      Specified by:
      discard in interface Buffered
      Overrides:
      discard in class AbstractValueComponent<JmixComboBox<V>,V,V>
    • isBuffered

      public boolean isBuffered()
      Specified by:
      isBuffered in interface Buffered
      Overrides:
      isBuffered in class AbstractValueComponent<JmixComboBox<V>,V,V>
      Returns:
      true if buffered mode is on, false otherwise
    • setBuffered

      public void setBuffered(boolean buffered)
      Description copied from interface: Buffered
      Sets the buffered mode.

      When in buffered mode, an internal buffer will be used to store changes until Buffered.commit() is called. Calling Buffered.discard() will revert the internal buffer to the value of the data source.

      When in non-buffered mode both read and write operations will be done directly on the data source. In this mode the Buffered.commit() and Buffered.discard() methods serve no purpose.

      Specified by:
      setBuffered in interface Buffered
      Overrides:
      setBuffered in class AbstractValueComponent<JmixComboBox<V>,V,V>
      Parameters:
      buffered - true if buffered mode should be turned on, false otherwise
    • isModified

      public boolean isModified()
      Description copied from interface: Buffered
      Tests if the value stored in the object has been modified since it was last updated from the data source.
      Specified by:
      isModified in interface Buffered
      Overrides:
      isModified in class AbstractValueComponent<JmixComboBox<V>,V,V>
      Returns:
      true if the value in the object has been modified since the last data source update, false if not.
    • setOptionStyleProvider

      public void setOptionStyleProvider(@Nullable Function<? super V,String> optionStyleProvider)
      Description copied from interface: HasOptionStyleProvider
      Sets the style provider that is used to produce custom class names for option items.
      Specified by:
      setOptionStyleProvider in interface HasOptionStyleProvider<V>
      Parameters:
      optionStyleProvider - style provider
    • getOptionStyleProvider

      @Nullable public Function<? super V,String> getOptionStyleProvider()
      Specified by:
      getOptionStyleProvider in interface HasOptionStyleProvider<V>
      Returns:
      the currently used item style provider
    • getOptionsCaptionFilter

      @Nullable public Predicate<ComboBox.OptionsCaptionFilteringContext> getOptionsCaptionFilter()
      Specified by:
      getOptionsCaptionFilter in interface ComboBox<V>
      Returns:
      a predicate that tests whether an item with the given caption matches to the given search string.
    • setOptionsCaptionFilter

      public void setOptionsCaptionFilter(@Nullable Predicate<ComboBox.OptionsCaptionFilteringContext> filter)
      Description copied from interface: ComboBox
      Sets a predicate that tests whether an item with the given caption matches to the given search string.
      Specified by:
      setOptionsCaptionFilter in interface ComboBox<V>
      Parameters:
      filter - a predicate to set
    • getPopupWidth

      @Nullable public String getPopupWidth()
      Description copied from interface: ComboBox
      Returns the suggestion popup's width as a string. By default this width is set to null.
      Specified by:
      getPopupWidth in interface ComboBox<V>
      Returns:
      explicitly set popup width as size string or null if not set
    • setPopupWidth

      public void setPopupWidth(@Nullable String width)
      Description copied from interface: ComboBox
      Sets the suggestion popup's width as a string. By using relative units (e.g. "50%") it's possible to set the popup's width relative to the LookupField itself.

      By default this width is set to null so that the popup's width can be greater than a component width to fit the content of all displayed items. By setting width to "100%" the popup's width will be equal to the width of the LookupField.

      Specified by:
      setPopupWidth in interface ComboBox<V>
      Parameters:
      width - the width
    • focus

      public void focus()
      Description copied from interface: Component.Focusable
      Sets focus to this component
      Specified by:
      focus in interface Component.Focusable
    • getTabIndex

      public int getTabIndex()
      Description copied from interface: Component.Focusable
      Gets the tabulator index of the HasTabIndex component.
      Specified by:
      getTabIndex in interface Component.Focusable
      Returns:
      tab index set for the HasTabIndex component
    • setTabIndex

      public void setTabIndex(int tabIndex)
      Description copied from interface: Component.Focusable
      Sets the tabulator index of the Focusable component. The tab index property is used to specify the order in which the fields are focused when the user presses the Tab key. Components with a defined tab index are focused sequentially first, and then the components with no tab index.
      Specified by:
      setTabIndex in interface Component.Focusable
      Parameters:
      tabIndex - tab index