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.OptionsCaptionFilteringContext
Nested 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.Wrapper
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasContextHelp
HasContextHelp.ContextHelpIconClickEvent
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasEnterPressHandler
HasEnterPressHandler.EnterPressEvent
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasFilterMode
HasFilterMode.FilterMode
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasValue
HasValue.ValueChangeEvent<V>
-
Field Summary
Modifier and TypeFieldDescriptionprotected Consumer<HasEnterPressHandler.EnterPressEvent>
protected HasFilterMode.FilterMode
protected IconResolver
protected MetadataTools
static final com.vaadin.ui.IconGenerator
static final com.vaadin.ui.StyleGenerator
protected boolean
protected OptionsBinding<V>
protected Predicate<ComboBox.OptionsCaptionFilteringContext>
Fields inherited from class io.jmix.ui.component.impl.AbstractField
editable, parentEditableChangeListener, validators, VALIDATORS_LIST_INITIAL_CAPACITY
Fields inherited from class io.jmix.ui.component.impl.AbstractValueComponent
internalValue, uiTestIdsSupport, valueBinding
Fields inherited from class io.jmix.ui.component.impl.AbstractComponent
alignment, applicationContext, component, contextHelpIconClickHandler, contextHelpIconClickListener, descriptionAsHtml, element, frame, htmlSanitizerEnabled, icon, ICON_STYLE, id, parent
Fields inherited from interface io.jmix.ui.component.ComboBox
NAME, TYPE_STRING
Fields inherited from interface io.jmix.ui.component.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
commit()
Updates all changes since the previous commit to the data source.protected JmixComboBox<V>
void
discard()
Discards all changes since last commit.protected boolean
filterItemTest
(String itemCaption, String filterText) void
focus()
Sets focus to this componentprotected String
generateDefaultItemCaption
(V item) protected String
generateItemCaption
(V item) protected String
generateItemStylename
(V item) protected com.vaadin.server.Resource
generateOptionIcon
(V item) protected com.vaadin.server.Resource
generateOptionImage
(V item) int
Returns the suggestion popup's width as a string.int
Gets the tabulator index of theHasTabIndex
component.getValue()
protected void
handleClearShortcut
(Object sender, Object target) protected void
initComponent
(JmixComboBox<V> component) boolean
boolean
Tests if the value stored in the object has been modified since it was last updated from the data source.boolean
boolean
protected void
onEnterPressed
(String text) void
setBuffered
(boolean buffered) Sets the buffered mode.void
Sets an ENTER press handler.void
setFilterMode
(HasFilterMode.FilterMode filterMode) Sets filter mode for the dropdown list in the field.void
setIconResolver
(IconResolver iconResolver) void
setInputPrompt
(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 void
setItemsToPresentation
(Stream<V> options) void
setMetadataTools
(MetadataTools metadataTools) void
setNullOptionVisible
(boolean nullOptionVisible) Sets visibility for first null element in suggestion popup.void
setNullSelectionCaption
(String nullOption) Sets the null selection caption.void
setOptionCaptionProvider
(Function<? super V, String> optionCaptionProvider) Sets function that provides caption for option items.void
setOptionIconProvider
(Function<? super V, String> optionIconProvider) Sets a function that provides an icon for options.void
setOptionImageProvider
(Function<? super V, Resource> optionImageProvider) Sets a function that provides option images.void
setOptions
(Options<V> options) Sets options for UI component.void
Sets a predicate that tests whether an item with the given caption matches to the given search string.void
setOptionStyleProvider
(Function<? super V, String> optionStyleProvider) Sets the style provider that is used to produce custom class names for option items.void
setPageLength
(int pageLength) Sets the page length for the suggestion popup.void
setPopupWidth
(String width) Sets the suggestion popup's width as a string.void
setRequired
(boolean required) Sets whether the component must contain a non-null value.void
setTabIndex
(int tabIndex) Sets the tabulator index of theFocusable
component.void
setTextInputAllowed
(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 void
valueBindingConnected
(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, validate
Methods inherited from class io.jmix.ui.component.impl.AbstractValueComponent
addValueChangeListener, componentValueChanged, convertToModel, convertToPresentation, fieldValueEquals, getValueSource, setUiTestId, setUiTestIdsSupport, setValue, setValueSource, setValueToPresentation, valueBindingActivated
Methods 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, withUnwrappedComposition
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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, withUnwrappedComposition
Methods inherited from interface io.jmix.ui.component.Component.BelongToFrame
getFrame, setFrame
Methods inherited from interface io.jmix.ui.component.Component.Editable
isEditable, isEditableWithParent, setEditable
Methods inherited from interface io.jmix.ui.component.Component.Focusable
isFocusable, setFocusable
Methods inherited from interface io.jmix.ui.component.Component.HasCaption
getCaption, setCaption
Methods inherited from interface io.jmix.ui.component.Component.HasDescription
getDescription, setDescription
Methods inherited from interface io.jmix.ui.component.Component.HasIcon
getIcon, setIcon, setIconFromSet
Methods inherited from interface io.jmix.ui.component.HasContextHelp
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled
Methods inherited from interface io.jmix.ui.component.HasHtmlCaption
isCaptionAsHtml, setCaptionAsHtml
Methods inherited from interface io.jmix.ui.component.HasHtmlDescription
isDescriptionAsHtml, setDescriptionAsHtml
Methods inherited from interface io.jmix.ui.component.HasHtmlSanitizer
isHtmlSanitizerEnabled, setHtmlSanitizerEnabled
Methods inherited from interface io.jmix.ui.component.HasValidator
addValidator, addValidators, getValidators, removeValidator
Methods inherited from interface io.jmix.ui.component.HasValue
addValueChangeListener, clear, getEmptyValue, isEmpty, setValue
Methods inherited from interface io.jmix.ui.component.data.HasValueSource
getValueSource, setValueSource
Methods inherited from interface io.jmix.ui.component.OptionsField
setOptionsEnum, setOptionsList, setOptionsMap
Methods inherited from interface io.jmix.ui.component.Requirable
getRequiredMessage, isRequired, setRequiredMessage
Methods 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:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
initComponent
-
generateDefaultItemCaption
-
generateItemCaption
-
generateItemStylename
-
filterItemTest
-
valueBindingConnected
- Overrides:
valueBindingConnected
in classAbstractValueComponent<JmixComboBox<V>,
V, V>
-
getValue
- Specified by:
getValue
in interfaceHasValue<V>
- Overrides:
getValue
in classAbstractValueComponent<JmixComboBox<V>,
V, V>
-
setFilterMode
Description copied from interface:HasFilterMode
Sets filter mode for the dropdown list in the field.- Specified by:
setFilterMode
in interfaceHasFilterMode
- Parameters:
filterMode
- filter mode to set
-
getFilterMode
- Specified by:
getFilterMode
in interfaceHasFilterMode
- 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 interfaceRequirable
- Overrides:
setRequired
in classAbstractField<JmixComboBox<V>,
V, V> - Parameters:
required
- required
-
getNullSelectionCaption
- Specified by:
getNullSelectionCaption
in interfaceComboBox<V>
- Returns:
- the null selection caption, not
null
-
setNullSelectionCaption
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 interfaceComboBox<V>
- Parameters:
nullOption
- the caption to set, notnull
-
getOptions
- Specified by:
getOptions
in interfaceOptionsField<V,
V> - Returns:
- options object
-
setOptions
Description copied from interface:OptionsField
Sets options for UI component.- Specified by:
setOptions
in interfaceOptionsField<V,
V> - Parameters:
options
- options- See Also:
-
setItemsToPresentation
-
setOptionCaptionProvider
Description copied from interface:HasOptionCaptionProvider
Sets function that provides caption for option items.- Specified by:
setOptionCaptionProvider
in interfaceHasOptionCaptionProvider<V>
- Parameters:
optionCaptionProvider
- caption provider for options
-
getOptionCaptionProvider
- Specified by:
getOptionCaptionProvider
in interfaceHasOptionCaptionProvider<V>
- Returns:
- caption provider for options
-
isTextInputAllowed
public boolean isTextInputAllowed()- Specified by:
isTextInputAllowed
in interfaceComboBox<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 interfaceComboBox<V>
-
getEnterPressHandler
- Specified by:
getEnterPressHandler
in interfaceHasEnterPressHandler
- Returns:
- an ENTER press handler
-
setEnterPressHandler
Description copied from interface:HasEnterPressHandler
Sets an ENTER press handler.- Specified by:
setEnterPressHandler
in interfaceHasEnterPressHandler
- Parameters:
handler
- an ENTER press handler to set
-
onEnterPressed
-
getPageLength
public int getPageLength()- Specified by:
getPageLength
in interfaceComboBox<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 interfaceComboBox<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 interfaceComboBox<V>
-
isNullOptionVisible
public boolean isNullOptionVisible()- Specified by:
isNullOptionVisible
in interfaceComboBox<V>
- Returns:
- true if first null element is visible.
-
setOptionIconProvider
Description copied from interface:HasOptionIconProvider
Sets a function that provides an icon for options.- Specified by:
setOptionIconProvider
in interfaceHasOptionIconProvider<V>
- Parameters:
optionIconProvider
- icon provider for options to set
-
getOptionIconProvider
- Specified by:
getOptionIconProvider
in interfaceHasOptionIconProvider<V>
- Returns:
- options icon provider or
null
if not defined
-
generateOptionIcon
-
setOptionImageProvider
Description copied from interface:HasOptionImageProvider
Sets a function that provides option images.- Specified by:
setOptionImageProvider
in interfaceHasOptionImageProvider<V>
- Parameters:
optionImageProvider
- options image provider- See Also:
-
getOptionImageProvider
- Specified by:
getOptionImageProvider
in interfaceHasOptionImageProvider<V>
- Returns:
- options image provider.
-
generateOptionImage
-
getInputPrompt
- Specified by:
getInputPrompt
in interfaceHasInputPrompt
- Returns:
- current input prompt.
-
setInputPrompt
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 interfaceHasInputPrompt
- 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 interfaceBuffered
- Overrides:
commit
in classAbstractValueComponent<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 interfaceBuffered
- Overrides:
discard
in classAbstractValueComponent<JmixComboBox<V>,
V, V>
-
isBuffered
public boolean isBuffered()- Specified by:
isBuffered
in interfaceBuffered
- Overrides:
isBuffered
in classAbstractValueComponent<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. 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:
setBuffered
in interfaceBuffered
- Overrides:
setBuffered
in classAbstractValueComponent<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 interfaceBuffered
- Overrides:
isModified
in classAbstractValueComponent<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
Description copied from interface:HasOptionStyleProvider
Sets the style provider that is used to produce custom class names for option items.- Specified by:
setOptionStyleProvider
in interfaceHasOptionStyleProvider<V>
- Parameters:
optionStyleProvider
- style provider
-
getOptionStyleProvider
- Specified by:
getOptionStyleProvider
in interfaceHasOptionStyleProvider<V>
- Returns:
- the currently used item style provider
-
getOptionsCaptionFilter
- Specified by:
getOptionsCaptionFilter
in 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:ComboBox
Sets a predicate that tests whether an item with the given caption matches to the given search string.- Specified by:
setOptionsCaptionFilter
in interfaceComboBox<V>
- Parameters:
filter
- a predicate to set
-
getPopupWidth
Description copied from interface:ComboBox
Returns the suggestion popup's width as a string. By default this width is set tonull
.- Specified by:
getPopupWidth
in interfaceComboBox<V>
- Returns:
- explicitly set popup width as size string or null if not set
-
setPopupWidth
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 interfaceComboBox<V>
- Parameters:
width
- the width
-
focus
public void focus()Description copied from interface:Component.Focusable
Sets focus to this component- Specified by:
focus
in interfaceComponent.Focusable
-
getTabIndex
public int getTabIndex()Description copied from interface:Component.Focusable
Gets the tabulator index of theHasTabIndex
component.- Specified by:
getTabIndex
in interfaceComponent.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 theFocusable
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 interfaceComponent.Focusable
- Parameters:
tabIndex
- tab index
-