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
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jmix.ui.component.ComboBox
ComboBox.OptionsCaptionFilteringContextNested classes/interfaces inherited from interface io.jmix.ui.component.Component
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.WrapperNested classes/interfaces inherited from interface io.jmix.ui.component.HasContextHelp
HasContextHelp.ContextHelpIconClickEventNested classes/interfaces inherited from interface io.jmix.ui.component.HasEnterPressHandler
HasEnterPressHandler.EnterPressEventNested classes/interfaces inherited from interface io.jmix.ui.component.HasFilterMode
HasFilterMode.FilterModeNested classes/interfaces inherited from interface io.jmix.ui.component.HasValue
HasValue.ValueChangeEvent<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Consumer<HasEnterPressHandler.EnterPressEvent>protected HasFilterMode.FilterModeprotected IconResolverprotected MetadataToolsstatic final com.vaadin.ui.IconGeneratorstatic final com.vaadin.ui.StyleGeneratorprotected booleanprotected OptionsBinding<V>protected Predicate<ComboBox.OptionsCaptionFilteringContext>Fields inherited from class io.jmix.ui.component.impl.AbstractField
editable, parentEditableChangeListener, validators, VALIDATORS_LIST_INITIAL_CAPACITYFields inherited from class io.jmix.ui.component.impl.AbstractValueComponent
internalValue, uiTestIdsSupport, valueBindingFields inherited from class io.jmix.ui.component.impl.AbstractComponent
alignment, applicationContext, component, contextHelpIconClickHandler, contextHelpIconClickListener, descriptionAsHtml, element, frame, htmlSanitizerEnabled, icon, ICON_STYLE, id, parentFields inherited from interface io.jmix.ui.component.ComboBox
NAME, TYPE_STRINGFields inherited from interface io.jmix.ui.component.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidcommit()Updates all changes since the previous commit to the data source.protected JmixComboBox<V>voiddiscard()Discards all changes since last commit.protected booleanfilterItemTest(String itemCaption, String filterText) voidfocus()Sets focus to this componentprotected StringgenerateDefaultItemCaption(V item) protected StringgenerateItemCaption(V item) protected StringgenerateItemStylename(V item) protected com.vaadin.server.ResourcegenerateOptionIcon(V item) protected com.vaadin.server.ResourcegenerateOptionImage(V item) intReturns the suggestion popup's width as a string.intGets the tabulator index of theHasTabIndexcomponent.getValue()protected voidhandleClearShortcut(Object sender, Object target) protected voidinitComponent(JmixComboBox<V> component) booleanbooleanbooleanTests if the value stored in the object has been modified since it was last updated from the data source.booleanbooleanprotected voidonEnterPressed(String text) voidsetAutomaticPopupOnFocus(boolean popup) When enabled popup automatically opens on focus.voidsetBuffered(boolean buffered) Sets the buffered mode.voidSets an ENTER press handler.voidsetFilterMode(HasFilterMode.FilterMode filterMode) Sets filter mode for the dropdown list in the field.voidsetIconResolver(IconResolver iconResolver) voidsetInputPrompt(String inputPrompt) Sets the input prompt - a textual prompt that is displayed when the field would otherwise be empty, to prompt the user for input.protected voidsetItemsToPresentation(Stream<V> options) voidsetMetadataTools(MetadataTools metadataTools) voidsetNullOptionVisible(boolean nullOptionVisible) Sets visibility for first null element in suggestion popup.voidsetNullSelectionCaption(String nullOption) Sets the null selection caption.voidsetOptionCaptionProvider(Function<? super V, String> optionCaptionProvider) Sets function that provides caption for option items.voidsetOptionIconProvider(Function<? super V, String> optionIconProvider) Sets a function that provides an icon for options.voidsetOptionImageProvider(Function<? super V, Resource> optionImageProvider) Sets a function that provides option images.voidsetOptions(Options<V> options) Sets options for UI component.voidSets a predicate that tests whether an item with the given caption matches to the given search string.voidsetOptionStyleProvider(Function<? super V, String> optionStyleProvider) Sets the style provider that is used to produce custom class names for option items.voidsetPageLength(int pageLength) Sets the page length for the suggestion popup.voidsetPopupWidth(String width) Sets the suggestion popup's width as a string.voidsetRequired(boolean required) Sets whether the component must contain a non-null value.voidsetTabIndex(int tabIndex) Sets the tabulator index of theFocusablecomponent.voidsetTextInputAllowed(boolean textInputAllowed) 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.protected voidvalueBindingConnected(ValueSource<V> valueSource) Methods inherited from class io.jmix.ui.component.impl.AbstractField
addValidator, attachValueChangeListener, getDatatypeConversionErrorMsg, getDefaultRequiredMessage, getErrorMessage, getRequiredMessage, getValidators, isEditable, isRequired, isValid, removeValidator, setEditable, setEditableToComponent, setParent, setRequiredMessage, setupComponentErrorProvider, triggerValidators, validateMethods inherited from class io.jmix.ui.component.impl.AbstractValueComponent
addValueChangeListener, componentValueChanged, convertToModel, convertToPresentation, fieldValueEquals, getValueSource, setUiTestId, setUiTestIdsSupport, setValue, setValueSource, setValueToPresentation, valueBindingActivatedMethods inherited from class io.jmix.ui.component.impl.AbstractComponent
addAttachListener, addDetachListener, addStyleName, assignDebugId, attached, detached, getAlignment, getCaption, getComponent, getComposition, getContextHelpIconClickHandler, getContextHelpText, getDebugId, getDescription, getEventHub, getFrame, getHeight, getHeightSizeUnit, getHtmlSanitizer, getIcon, getIconName, getIconResource, getId, getParent, getStyleName, getUiComponentProperties, getUiProperties, getWidth, getWidthSizeUnit, getXmlDescriptor, hasSubscriptions, hasValidationError, isAttached, isCaptionAsHtml, isContextHelpTextHtmlEnabled, isDescriptionAsHtml, isEnabled, isEnabledRecursive, isHtmlSanitizerEnabled, isResponsive, isVisible, isVisibleRecursive, onContextHelpIconClick, publish, removeStyleName, sanitize, setAlignment, setApplicationContext, setCaption, setCaptionAsHtml, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled, setDebugId, setDescription, setDescriptionAsHtml, setEnabled, setFrame, setHeight, setHtmlSanitizerEnabled, setIcon, setIconFromSet, setId, setResponsive, setStyleName, setValidationError, setVisible, setWidth, setXmlDescriptor, unsubscribe, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedCompositionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.jmix.ui.component.Component
addStyleName, getAlignment, getHeight, getHeightSizeUnit, getId, getParent, getStyleName, getWidth, getWidthSizeUnit, isEnabled, isEnabledRecursive, isResponsive, isVisible, isVisibleRecursive, removeStyleName, setAlignment, setEnabled, setHeight, setHeightAuto, setHeightFull, setId, setParent, setResponsive, setSizeAuto, setSizeFull, setStyleName, setVisible, setWidth, setWidthAuto, setWidthFull, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedCompositionMethods inherited from interface io.jmix.ui.component.Component.BelongToFrame
getFrame, setFrameMethods inherited from interface io.jmix.ui.component.Component.Editable
isEditable, isEditableWithParent, setEditableMethods inherited from interface io.jmix.ui.component.Component.Focusable
isFocusable, setFocusableMethods inherited from interface io.jmix.ui.component.Component.HasCaption
getCaption, setCaptionMethods inherited from interface io.jmix.ui.component.Component.HasDescription
getDescription, setDescriptionMethods inherited from interface io.jmix.ui.component.Component.HasIcon
getIcon, setIcon, setIconFromSetMethods inherited from interface io.jmix.ui.component.HasContextHelp
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabledMethods inherited from interface io.jmix.ui.component.HasHtmlCaption
isCaptionAsHtml, setCaptionAsHtmlMethods inherited from interface io.jmix.ui.component.HasHtmlDescription
isDescriptionAsHtml, setDescriptionAsHtmlMethods inherited from interface io.jmix.ui.component.HasHtmlSanitizer
isHtmlSanitizerEnabled, setHtmlSanitizerEnabledMethods inherited from interface io.jmix.ui.component.HasValidator
addValidator, addValidators, getValidators, removeValidatorMethods inherited from interface io.jmix.ui.component.HasValue
addValueChangeListener, clear, getEmptyValue, isEmpty, setValueMethods inherited from interface io.jmix.ui.component.data.HasValueSource
getValueSource, setValueSourceMethods inherited from interface io.jmix.ui.component.OptionsField
setOptionsEnum, setOptionsList, setOptionsMapMethods inherited from interface io.jmix.ui.component.Requirable
getRequiredMessage, isRequired, setRequiredMessageMethods inherited from interface io.jmix.ui.component.Validatable
isValid, isValidateOnCommit, validate
-
Field Details
-
NULL_STYLE_GENERATOR
public static final com.vaadin.ui.StyleGenerator NULL_STYLE_GENERATOR -
NULL_ITEM_ICON_GENERATOR
public static final com.vaadin.ui.IconGenerator NULL_ITEM_ICON_GENERATOR -
filterMode
-
nullOptionVisible
protected boolean nullOptionVisible -
enterPressHandler
-
optionIconProvider
-
optionImageProvider
-
optionCaptionProvider
-
optionStyleProvider
-
optionsCaptionFilter
-
metadataTools
-
iconResolver
-
optionsBinding
-
-
Constructor Details
-
ComboBoxImpl
public ComboBoxImpl()
-
-
Method Details
-
createComponent
-
setMetadataTools
-
setIconResolver
-
handleClearShortcut
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
initComponent
-
generateDefaultItemCaption
-
generateItemCaption
-
generateItemStylename
-
filterItemTest
-
valueBindingConnected
- Overrides:
valueBindingConnectedin classAbstractValueComponent<JmixComboBox<V>,V, V>
-
getValue
- Specified by:
getValuein interfaceHasValue<V>- Overrides:
getValuein classAbstractValueComponent<JmixComboBox<V>,V, V>
-
setFilterMode
Description copied from interface:HasFilterModeSets filter mode for the dropdown list in the field.- Specified by:
setFilterModein interfaceHasFilterMode- Parameters:
filterMode- filter mode to set
-
getFilterMode
- Specified by:
getFilterModein interfaceHasFilterMode- Returns:
- filter mode for the dropdown list in the field
-
setRequired
public void setRequired(boolean required) Description copied from interface:RequirableSets whether the component must contain a non-null value.- Specified by:
setRequiredin interfaceRequirable- Overrides:
setRequiredin classAbstractField<JmixComboBox<V>,V, V> - Parameters:
required- required
-
getNullSelectionCaption
- Specified by:
getNullSelectionCaptionin interfaceComboBox<V>- Returns:
- the null selection caption, not
null
-
setNullSelectionCaption
Description copied from interface:ComboBoxSets 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:
setNullSelectionCaptionin interfaceComboBox<V>- Parameters:
nullOption- the caption to set, notnull
-
getOptions
- Specified by:
getOptionsin interfaceOptionsField<V,V> - Returns:
- options object
-
setOptions
Description copied from interface:OptionsFieldSets options for UI component.- Specified by:
setOptionsin interfaceOptionsField<V,V> - Parameters:
options- options- See Also:
-
setItemsToPresentation
-
setOptionCaptionProvider
Description copied from interface:HasOptionCaptionProviderSets function that provides caption for option items.- Specified by:
setOptionCaptionProviderin interfaceHasOptionCaptionProvider<V>- Parameters:
optionCaptionProvider- caption provider for options
-
getOptionCaptionProvider
- Specified by:
getOptionCaptionProviderin interfaceHasOptionCaptionProvider<V>- Returns:
- caption provider for options
-
isTextInputAllowed
public boolean isTextInputAllowed()- Specified by:
isTextInputAllowedin interfaceComboBox<V>- Returns:
- true if text input allowed
-
setTextInputAllowed
public void setTextInputAllowed(boolean textInputAllowed) Description copied from interface:ComboBoxSets 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:
setTextInputAllowedin interfaceComboBox<V>
-
isAutomaticPopupOnFocus
public boolean isAutomaticPopupOnFocus()- Specified by:
isAutomaticPopupOnFocusin interfaceComboBox<V>- Returns:
- whether popup is automatically shows on focus.
-
setAutomaticPopupOnFocus
public void setAutomaticPopupOnFocus(boolean popup) Description copied from interface:ComboBoxWhen enabled popup automatically opens on focus.- Specified by:
setAutomaticPopupOnFocusin interfaceComboBox<V>
-
getEnterPressHandler
- Specified by:
getEnterPressHandlerin interfaceHasEnterPressHandler- Returns:
- an ENTER press handler
-
setEnterPressHandler
Description copied from interface:HasEnterPressHandlerSets an ENTER press handler.- Specified by:
setEnterPressHandlerin interfaceHasEnterPressHandler- Parameters:
handler- an ENTER press handler to set
-
onEnterPressed
-
getPageLength
public int getPageLength()- Specified by:
getPageLengthin interfaceComboBox<V>- Returns:
- the page length of the suggestion popup.
-
setPageLength
public void setPageLength(int pageLength) Description copied from interface:ComboBoxSets the page length for the suggestion popup. Setting the page length to 0 will disable suggestion popup paging (all items visible).- Specified by:
setPageLengthin interfaceComboBox<V>- Parameters:
pageLength- the pageLength to set
-
setNullOptionVisible
public void setNullOptionVisible(boolean nullOptionVisible) Description copied from interface:ComboBoxSets visibility for first null element in suggestion popup.- Specified by:
setNullOptionVisiblein interfaceComboBox<V>
-
isNullOptionVisible
public boolean isNullOptionVisible()- Specified by:
isNullOptionVisiblein interfaceComboBox<V>- Returns:
- true if first null element is visible.
-
setOptionIconProvider
Description copied from interface:HasOptionIconProviderSets a function that provides an icon for options.- Specified by:
setOptionIconProviderin interfaceHasOptionIconProvider<V>- Parameters:
optionIconProvider- icon provider for options to set
-
getOptionIconProvider
- Specified by:
getOptionIconProviderin interfaceHasOptionIconProvider<V>- Returns:
- options icon provider or
nullif not defined
-
generateOptionIcon
-
setOptionImageProvider
Description copied from interface:HasOptionImageProviderSets a function that provides option images.- Specified by:
setOptionImageProviderin interfaceHasOptionImageProvider<V>- Parameters:
optionImageProvider- options image provider- See Also:
-
getOptionImageProvider
- Specified by:
getOptionImageProviderin interfaceHasOptionImageProvider<V>- Returns:
- options image provider.
-
generateOptionImage
-
getInputPrompt
- Specified by:
getInputPromptin interfaceHasInputPrompt- Returns:
- current input prompt.
-
setInputPrompt
Description copied from interface:HasInputPromptSets the input prompt - a textual prompt that is displayed when the field would otherwise be empty, to prompt the user for input.- Specified by:
setInputPromptin interfaceHasInputPrompt- Parameters:
inputPrompt- input prompt
-
commit
public void commit()Description copied from interface:BufferedUpdates all changes since the previous commit to the data source.- Specified by:
commitin interfaceBuffered- Overrides:
commitin classAbstractValueComponent<JmixComboBox<V>,V, V>
-
discard
public void discard()Description copied from interface:BufferedDiscards all changes since last commit. The object updates its value from the data source.- Specified by:
discardin interfaceBuffered- Overrides:
discardin classAbstractValueComponent<JmixComboBox<V>,V, V>
-
isBuffered
public boolean isBuffered()- Specified by:
isBufferedin interfaceBuffered- Overrides:
isBufferedin classAbstractValueComponent<JmixComboBox<V>,V, V> - Returns:
trueif buffered mode is on,falseotherwise
-
setBuffered
public void setBuffered(boolean buffered) Description copied from interface:BufferedSets the buffered mode.When in buffered mode, an internal buffer will be used to store changes until
Buffered.commit()is called. CallingBuffered.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()andBuffered.discard()methods serve no purpose.- Specified by:
setBufferedin interfaceBuffered- Overrides:
setBufferedin classAbstractValueComponent<JmixComboBox<V>,V, V> - Parameters:
buffered-trueif buffered mode should be turned on,falseotherwise
-
isModified
public boolean isModified()Description copied from interface:BufferedTests if the value stored in the object has been modified since it was last updated from the data source.- Specified by:
isModifiedin interfaceBuffered- Overrides:
isModifiedin classAbstractValueComponent<JmixComboBox<V>,V, V> - Returns:
trueif the value in the object has been modified since the last data source update,falseif not.
-
setOptionStyleProvider
Description copied from interface:HasOptionStyleProviderSets the style provider that is used to produce custom class names for option items.- Specified by:
setOptionStyleProviderin interfaceHasOptionStyleProvider<V>- Parameters:
optionStyleProvider- style provider
-
getOptionStyleProvider
- Specified by:
getOptionStyleProviderin interfaceHasOptionStyleProvider<V>- Returns:
- the currently used item style provider
-
getOptionsCaptionFilter
- Specified by:
getOptionsCaptionFilterin interfaceComboBox<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:ComboBoxSets a predicate that tests whether an item with the given caption matches to the given search string.- Specified by:
setOptionsCaptionFilterin interfaceComboBox<V>- Parameters:
filter- a predicate to set
-
getPopupWidth
Description copied from interface:ComboBoxReturns the suggestion popup's width as a string. By default this width is set tonull.- Specified by:
getPopupWidthin interfaceComboBox<V>- Returns:
- explicitly set popup width as size string or null if not set
-
setPopupWidth
Description copied from interface:ComboBoxSets 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
nullso 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:
setPopupWidthin interfaceComboBox<V>- Parameters:
width- the width
-
focus
public void focus()Description copied from interface:Component.FocusableSets focus to this component- Specified by:
focusin interfaceComponent.Focusable
-
getTabIndex
public int getTabIndex()Description copied from interface:Component.FocusableGets the tabulator index of theHasTabIndexcomponent.- Specified by:
getTabIndexin interfaceComponent.Focusable- Returns:
- tab index set for the
HasTabIndexcomponent
-
setTabIndex
public void setTabIndex(int tabIndex) Description copied from interface:Component.FocusableSets the tabulator index of theFocusablecomponent. 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:
setTabIndexin interfaceComponent.Focusable- Parameters:
tabIndex- tab index
-