Package io.jmix.ui.component.impl
Class AbstractSuggestionField<V,I,T extends JmixAbstractSuggestionField<V,I>>
java.lang.Object
io.jmix.ui.component.impl.AbstractComponent<T>
io.jmix.ui.component.impl.AbstractValueComponent<T,P,V>
io.jmix.ui.component.impl.AbstractField<T,V,V>
io.jmix.ui.component.impl.AbstractSuggestionField<V,I,T>
- Type Parameters:
V
- value type - collection or notI
- item typeT
- component type
- All Implemented Interfaces:
AttachNotifier
,Component
,Component.BelongToFrame
,Component.Editable
,Component.Focusable
,Component.HasCaption
,Component.HasDescription
,Component.HasIcon
,Component.HasXmlDescriptor
,Component.Wrapper
,HasValueSource<V>
,Field<V>
,HasContextHelp
,HasDebugId
,HasEnterPressHandler
,HasFormatter<I>
,HasHtmlCaption
,HasHtmlDescription
,HasHtmlSanitizer
,HasInputPrompt
,HasOptionStyleProvider<I>
,HasValidator<V>
,HasValue<V>
,Requirable
,SuggestionFieldComponent<V,
,I> Validatable
,org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
SuggestionFieldImpl
,TagFieldImpl
public abstract class AbstractSuggestionField<V,I,T extends JmixAbstractSuggestionField<V,I>>
extends AbstractField<T,V,V>
implements SuggestionFieldComponent<V,I>, org.springframework.beans.factory.InitializingBean
Base class for SuggestionField components.
-
Nested Class Summary
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.HasValue
HasValue.ValueChangeEvent<V>
Nested classes/interfaces inherited from interface io.jmix.ui.component.SuggestionFieldComponent
SuggestionFieldComponent.ArrowDownEvent, SuggestionFieldComponent.ParametrizedSearchExecutor<E>, SuggestionFieldComponent.SearchExecutor<E>
-
Field Summary
Modifier and TypeFieldDescriptionprotected Consumer<SuggestionFieldComponent.ArrowDownEvent>
protected BackgroundWorker
protected Consumer<HasEnterPressHandler.EnterPressEvent>
protected BackgroundTaskHandler<List<I>>
protected Locale
protected MetadataTools
protected SuggestionFieldComponent.SearchExecutor<I>
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.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE
Fields inherited from interface io.jmix.ui.component.SuggestionFieldComponent
POPUP_AUTO_WIDTH, POPUP_PARENT_WIDTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addStyleName
(String styleName) Adds one or more style names to this component.void
protected String
applyDefaultValueFormat
(I item) asyncSearch
(SuggestionFieldComponent.SearchExecutor<I> searchExecutor, String searchString, Map<String, Object> params) protected void
protected String
convertToTextView
(I item) void
focus()
Sets focus to this componentprotected String
generateItemStylename
(Object item) int
int
protected BackgroundTask<Long,
List<I>> getSearchSuggestionsTask
(String query) int
int
Gets the tabulator index of theHasTabIndex
component.protected void
handleSearchResult
(List<I> results) protected void
initComponent
(T component) protected void
onArrowDownHandler
(String currentSearchString) protected void
onEnterPressHandler
(String currentSearchString) void
removeStyleName
(String styleName) Removes one or more style names from component.protected void
searchSuggestions
(String query) void
Sets an ARROW_DOWN press handler.void
setAsyncSearchDelayMs
(int asyncSearchDelayMs) Sets delay between the last key press action and async search.protected void
setBackgroundWorker
(BackgroundWorker backgroundWorker) void
setCurrentAuthentication
(CurrentAuthentication currentAuthentication) void
Sets an ENTER press handler.void
setFormatter
(Formatter<? super I> formatter) 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
setMetadataTools
(MetadataTools metadataTools) void
setMinSearchStringLength
(int minSearchStringLength) Sets min string length which is required to perform suggestions search.void
setOptionStyleProvider
(Function<? super I, String> optionStyleProvider) Sets the style provider that is used to produce custom class names for option items.void
setPopupWidth
(String popupWidth) Sets the givenwidth
to the component popup.void
setSearchExecutor
(SuggestionFieldComponent.SearchExecutor<I> searchExecutor) SetsSuggestionFieldComponent.SearchExecutor
which performs search.void
setStyleName
(String name) Sets one or more style names of the component, replacing any previous styles.void
setSuggestionsLimit
(int suggestionsLimit) Sets limit of suggestions which will be shown.void
setTabIndex
(int tabIndex) Sets the tabulator index of theFocusable
component.void
showSuggestions
(List<I> suggestions) Show passed suggestions in popup.protected void
showSuggestions
(List<I> suggestions, boolean userOriginated) Methods inherited from class io.jmix.ui.component.impl.AbstractField
addValidator, attachValueChangeListener, getDatatypeConversionErrorMsg, getDefaultRequiredMessage, getErrorMessage, getRequiredMessage, getValidators, isEditable, isRequired, isValid, removeValidator, setEditable, setEditableToComponent, setParent, setRequired, setRequiredMessage, setupComponentErrorProvider, triggerValidators, validate
Methods inherited from class io.jmix.ui.component.impl.AbstractValueComponent
addValueChangeListener, commit, componentValueChanged, convertToModel, convertToPresentation, discard, fieldValueEquals, getValue, getValueSource, isBuffered, isModified, setBuffered, setUiTestId, setUiTestIdsSupport, setValue, setValueSource, setValueToPresentation, valueBindingActivated, valueBindingConnected
Methods inherited from class io.jmix.ui.component.impl.AbstractComponent
addAttachListener, addDetachListener, 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, sanitize, setAlignment, setApplicationContext, setCaption, setCaptionAsHtml, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled, setDebugId, setDescription, setDescriptionAsHtml, setEnabled, setFrame, setHeight, setHtmlSanitizerEnabled, setIcon, setIconFromSet, setId, setResponsive, 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
getAlignment, getHeight, getHeightSizeUnit, getId, getParent, getStyleName, getWidth, getWidthSizeUnit, isEnabled, isEnabledRecursive, isResponsive, isVisible, isVisibleRecursive, setAlignment, setEnabled, setHeight, setHeightAuto, setHeightFull, setId, setParent, setResponsive, setSizeAuto, setSizeFull, 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, getValue, isEmpty, setValue
Methods inherited from interface io.jmix.ui.component.data.HasValueSource
getValueSource, setValueSource
Methods inherited from interface io.jmix.ui.component.Requirable
getRequiredMessage, isRequired, setRequired, setRequiredMessage
Methods inherited from interface io.jmix.ui.component.Validatable
isValid, isValidateOnCommit, validate
-
Field Details
-
handler
-
searchExecutor
-
backgroundWorker
-
metadataTools
-
locale
-
optionStyleProvider
-
formatter
-
enterPressHandler
-
arrowDownHandler
-
-
Constructor Details
-
AbstractSuggestionField
public AbstractSuggestionField()
-
-
Method Details
-
setBackgroundWorker
-
setCurrentAuthentication
-
setMetadataTools
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
initComponent
-
setSearchExecutor
Description copied from interface:SuggestionFieldComponent
SetsSuggestionFieldComponent.SearchExecutor
which performs search.- Specified by:
setSearchExecutor
in interfaceSuggestionFieldComponent<V,
I> - Parameters:
searchExecutor
- SearchExecutor instance
-
getSearchExecutor
- Specified by:
getSearchExecutor
in interfaceSuggestionFieldComponent<V,
I> - Returns:
SuggestionFieldComponent.SearchExecutor
which performs search
-
getMinSearchStringLength
public int getMinSearchStringLength()- Specified by:
getMinSearchStringLength
in interfaceSuggestionFieldComponent<V,
I> - Returns:
- min string length to perform suggestions search
-
setMinSearchStringLength
public void setMinSearchStringLength(int minSearchStringLength) Description copied from interface:SuggestionFieldComponent
Sets min string length which is required to perform suggestions search.- Specified by:
setMinSearchStringLength
in interfaceSuggestionFieldComponent<V,
I> - Parameters:
minSearchStringLength
- required string length to perform search
-
getSuggestionsLimit
public int getSuggestionsLimit()- Specified by:
getSuggestionsLimit
in interfaceSuggestionFieldComponent<V,
I> - Returns:
- limit of suggestions which will be shown
-
setSuggestionsLimit
public void setSuggestionsLimit(int suggestionsLimit) Description copied from interface:SuggestionFieldComponent
Sets limit of suggestions which will be shown.- Specified by:
setSuggestionsLimit
in interfaceSuggestionFieldComponent<V,
I> - Parameters:
suggestionsLimit
- integer limit value
-
getAsyncSearchDelayMs
public int getAsyncSearchDelayMs()- Specified by:
getAsyncSearchDelayMs
in interfaceSuggestionFieldComponent<V,
I> - Returns:
- delay between the last key press action and async search
-
setAsyncSearchDelayMs
public void setAsyncSearchDelayMs(int asyncSearchDelayMs) Description copied from interface:SuggestionFieldComponent
Sets delay between the last key press action and async search.- Specified by:
setAsyncSearchDelayMs
in interfaceSuggestionFieldComponent<V,
I> - Parameters:
asyncSearchDelayMs
- delay in ms
-
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
-
getArrowDownHandler
- Specified by:
getArrowDownHandler
in interfaceSuggestionFieldComponent<V,
I> - Returns:
- an ARROW_DOWN press handler
-
setArrowDownHandler
Description copied from interface:SuggestionFieldComponent
Sets an ARROW_DOWN press handler.- Specified by:
setArrowDownHandler
in interfaceSuggestionFieldComponent<V,
I> - Parameters:
handler
- an ARROW_DOWN press handler to set
-
showSuggestions
Description copied from interface:SuggestionFieldComponent
Show passed suggestions in popup.- Specified by:
showSuggestions
in interfaceSuggestionFieldComponent<V,
I> - Parameters:
suggestions
- suggestions to show
-
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
-
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
-
setStyleName
Description copied from interface:Component
Sets one or more style names of the component, replacing any previous styles. Multiple styles can be specified as a space-separated list of style names. Styles implementation is client-type-specific.- Specified by:
setStyleName
in interfaceComponent
- Overrides:
setStyleName
in classAbstractComponent<T extends JmixAbstractSuggestionField<V,
I>> - Parameters:
name
- one or more style names separated by space.
-
addStyleName
Description copied from interface:Component
Adds one or more style names to this component. Multiple styles can be specified as a space-separated list of style names.- Specified by:
addStyleName
in interfaceComponent
- Overrides:
addStyleName
in classAbstractComponent<T extends JmixAbstractSuggestionField<V,
I>> - Parameters:
styleName
- one or more style names separated by space.
-
removeStyleName
Description copied from interface:Component
Removes one or more style names from component. Multiple styles can be specified as a space-separated list of style names.- Specified by:
removeStyleName
in interfaceComponent
- Overrides:
removeStyleName
in classAbstractComponent<T extends JmixAbstractSuggestionField<V,
I>> - Parameters:
styleName
- one or more style names separated by space.
-
setPopupWidth
Description copied from interface:SuggestionFieldComponent
Sets the givenwidth
to the component popup. There are two predefined settings available:SuggestionFieldComponent.POPUP_AUTO_WIDTH
andSuggestionFieldComponent.POPUP_PARENT_WIDTH
.- Specified by:
setPopupWidth
in interfaceSuggestionFieldComponent<V,
I> - Parameters:
popupWidth
- width of the component popup
-
getPopupWidth
- Specified by:
getPopupWidth
in interfaceSuggestionFieldComponent<V,
I> - Returns:
- component popup width
-
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
-
getFormatter
- Specified by:
getFormatter
in interfaceHasFormatter<V>
-
setFormatter
- Specified by:
setFormatter
in interfaceHasFormatter<V>
-
generateItemStylename
-
getSearchSuggestionsTask
-
asyncSearch
protected List<I> asyncSearch(SuggestionFieldComponent.SearchExecutor<I> searchExecutor, String searchString, Map<String, Object> params) throws Exception- Throws:
Exception
-
handleSearchResult
-
showSuggestions
-
cancelSearch
protected void cancelSearch() -
searchSuggestions
-
convertToTextView
-
applyDefaultValueFormat
-
onEnterPressHandler
-
onArrowDownHandler
-