Package io.jmix.ui.component.impl
Class EntitySuggestionFieldImpl<V>
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<JmixPickerField<V>,V,V>
io.jmix.ui.component.impl.ValuePickerImpl<V>
io.jmix.ui.component.impl.EntityPickerImpl<V>
io.jmix.ui.component.impl.EntitySuggestionFieldImpl<V>
- All Implemented Interfaces:
ActionsHolder
,AttachNotifier
,Buffered
,Component
,Component.BelongToFrame
,Component.Editable
,Component.Focusable
,Component.HasCaption
,Component.HasDescription
,Component.HasIcon
,Component.HasXmlDescriptor
,Component.Wrapper
,HasValueSource<V>
,EntityPicker<V>
,EntitySuggestionField<V>
,Field<V>
,HasContextHelp
,HasDebugId
,HasEnterPressHandler
,HasFormatter<V>
,HasHtmlCaption
,HasHtmlDescription
,HasHtmlSanitizer
,HasInputPrompt
,HasOptionStyleProvider<V>
,HasSubParts
,HasValidator<V>
,HasValue<V>
,LookupComponent<V>
,Requirable
,SecuredActionsHolder
,SuggestionField<V>
,SuggestionFieldComponent<V,
,V> SupportsUserAction<V>
,Validatable
,ValuePicker<V>
,org.springframework.beans.factory.InitializingBean
public class EntitySuggestionFieldImpl<V>
extends EntityPickerImpl<V>
implements EntitySuggestionField<V>, SecuredActionsHolder
-
Nested Class Summary
Nested classes/interfaces inherited from class io.jmix.ui.component.impl.ValuePickerImpl
ValuePickerImpl.WebValuePickerActionHandler
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.EntityPicker
EntityPicker.EntityPickerAction
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.LookupComponent
LookupComponent.LookupSelectionChangeEvent<T>, LookupComponent.LookupSelectionChangeNotifier<T>
Nested classes/interfaces inherited from interface io.jmix.ui.component.SuggestionFieldComponent
SuggestionFieldComponent.ArrowDownEvent, SuggestionFieldComponent.ParametrizedSearchExecutor<E>, SuggestionFieldComponent.SearchExecutor<E>
Nested classes/interfaces inherited from interface io.jmix.ui.component.ValuePicker
ValuePicker.FieldValueChangeEvent<V>, ValuePicker.ValuePickerAction
-
Field Summary
Modifier and TypeFieldDescriptionprotected Consumer<SuggestionFieldComponent.ArrowDownEvent>
protected BackgroundWorker
protected Consumer<HasEnterPressHandler.EnterPressEvent>
protected BackgroundTaskHandler<List<V>>
protected Locale
protected SuggestionFieldComponent.SearchExecutor<V>
Fields inherited from class io.jmix.ui.component.impl.EntityPickerImpl
metaClass, metadata
Fields inherited from class io.jmix.ui.component.impl.ValuePickerImpl
actionButtons, actionHandler, actionPropertyChangeListener, actions, actionsPermissions, fieldIconProvider, fieldListenerRegistration, formatter, metadataTools
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.EntityPicker
NAME
Fields inherited from interface io.jmix.ui.component.EntitySuggestionField
NAME
Fields inherited from interface io.jmix.ui.component.SuggestionFieldComponent
POPUP_AUTO_WIDTH, POPUP_PARENT_WIDTH
Fields inherited from interface io.jmix.ui.component.ValuePicker
NAME, TYPE_STRING
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds a listener that will be fired in case field is editable.void
addStyleName
(String styleName) Adds one or more style names to this component.asyncSearch
(SuggestionFieldComponent.SearchExecutor<V> searchExecutor, String searchString, Map<String, Object> params) protected void
protected void
checkValueType
(V value) protected JmixPickerField<V>
protected String
generateItemStylename
(Object item) int
int
protected BackgroundTask<Long,
List<V>> getSearchSuggestionsTask
(String query) int
protected void
handleSearchResult
(List<V> results) protected void
initComponent
(JmixPickerField<V> component) boolean
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.void
setBackgroundWorker
(BackgroundWorker backgroundWorker) void
setCurrentAuthentication
(CurrentAuthentication currentAuthentication) void
Sets an ENTER press handler.void
setFieldEditable
(boolean editable) Sets whether a user can input the value manually.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.void
setMinSearchStringLength
(int minSearchStringLength) Sets min string length which is required to perform suggestions search.void
setOptionStyleProvider
(Function<? super V, 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<V> 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
showSuggestions
(List<V> suggestions) Show passed suggestions in popup.protected void
showSuggestions
(List<V> suggestions, boolean userOriginated) Methods inherited from class io.jmix.ui.component.impl.EntityPickerImpl
getLookupSelectedItems, getMetaClass, setLookupSelectHandler, setMetaClass, setMetadata, setValue, setValueFromUser
Methods inherited from class io.jmix.ui.component.impl.ValuePickerImpl
actionPropertyChanged, addAction, addAction, afterPropertiesSet, applyDefaultValueFormat, commit, discard, focus, formatValue, generateOptionIcon, getAction, getActions, getActionsPermissions, getFieldIconProvider, getFormatter, getTabIndex, isBuffered, isModified, onFieldValueChange, refreshActionsState, removeAction, removeAction, removeAllActions, setBuffered, setButtonIcon, setDebugId, setEditableToComponent, setFieldIconProvider, setFormatter, setFrame, setMetadataTools, setTabIndex, setUiComponentProperties, setupButtonAction
Methods inherited from class io.jmix.ui.component.impl.AbstractField
addValidator, attachValueChangeListener, getDatatypeConversionErrorMsg, getDefaultRequiredMessage, getErrorMessage, getRequiredMessage, getValidators, isEditable, isRequired, isValid, removeValidator, setEditable, setParent, setRequired, setRequiredMessage, setupComponentErrorProvider, triggerValidators, validate
Methods inherited from class io.jmix.ui.component.impl.AbstractValueComponent
addValueChangeListener, componentValueChanged, convertToModel, convertToPresentation, fieldValueEquals, getValue, getValueSource, setUiTestId, setUiTestIdsSupport, setValueSource, setValueToPresentation, valueBindingActivated, valueBindingConnected
Methods inherited from class io.jmix.ui.component.impl.AbstractComponent
addAttachListener, addDetachListener, assignDebugId, attached, detached, getAlignment, getCaption, 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, setDescription, setDescriptionAsHtml, setEnabled, 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.ActionsHolder
addAction, addAction, getAction, getActionNN, getActions, getSubPart, removeAction, removeAction, removeAllActions
Methods inherited from interface io.jmix.ui.component.Buffered
commit, discard, isBuffered, isModified, setBuffered
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
focus, getTabIndex, isFocusable, setFocusable, setTabIndex
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.EntityPicker
getMetaClass, setMetaClass
Methods inherited from interface io.jmix.ui.component.HasContextHelp
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled
Methods inherited from interface io.jmix.ui.component.HasFormatter
getFormatter, setFormatter
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.LookupComponent
getLookupSelectedItems, setLookupSelectHandler
Methods inherited from interface io.jmix.ui.component.Requirable
getRequiredMessage, isRequired, setRequired, setRequiredMessage
Methods inherited from interface io.jmix.ui.component.SecuredActionsHolder
getActionsPermissions
Methods inherited from interface io.jmix.ui.component.SupportsUserAction
setValueFromUser
Methods inherited from interface io.jmix.ui.component.Validatable
isValid, isValidateOnCommit, validate
Methods inherited from interface io.jmix.ui.component.ValuePicker
getFieldIconProvider, setFieldIconProvider
-
Field Details
-
backgroundWorker
-
handler
-
searchExecutor
-
optionStyleProvider
-
enterPressHandler
-
arrowDownHandler
-
locale
-
-
Constructor Details
-
EntitySuggestionFieldImpl
public EntitySuggestionFieldImpl()
-
-
Method Details
-
createComponent
- Overrides:
createComponent
in classEntityPickerImpl<V>
-
getComponent
- Specified by:
getComponent
in interfaceComponent.Wrapper
- Overrides:
getComponent
in classAbstractComponent<JmixPickerField<V>>
-
setBackgroundWorker
-
initComponent
- Overrides:
initComponent
in classValuePickerImpl<V>
-
setCurrentAuthentication
-
cancelSearch
protected void cancelSearch() -
searchSuggestions
-
getSearchSuggestionsTask
-
asyncSearch
protected List<V> asyncSearch(SuggestionFieldComponent.SearchExecutor<V> searchExecutor, String searchString, Map<String, Object> params) throws Exception- Throws:
Exception
-
handleSearchResult
-
generateItemStylename
-
addFieldValueChangeListener
public Subscription addFieldValueChangeListener(Consumer<ValuePicker.FieldValueChangeEvent<V>> listener) Description copied from interface:ValuePicker
Adds a listener that will be fired in case field is editable.- Specified by:
addFieldValueChangeListener
in interfaceValuePicker<V>
- Overrides:
addFieldValueChangeListener
in classValuePickerImpl<V>
- Parameters:
listener
- a listener to add- Returns:
- a
Subscription
object - See Also:
-
isFieldEditable
public boolean isFieldEditable()- Specified by:
isFieldEditable
in interfaceValuePicker<V>
- Overrides:
isFieldEditable
in classValuePickerImpl<V>
- Returns:
- whether a user can input the value manually
-
setFieldEditable
public void setFieldEditable(boolean editable) Description copied from interface:ValuePicker
Sets whether a user can input the value manually.false
by default. Doesn't set entered value to the model. To handle user input, theValuePicker.FieldValueChangeEvent
listener must be used.- Specified by:
setFieldEditable
in interfaceValuePicker<V>
- Overrides:
setFieldEditable
in classValuePickerImpl<V>
- Parameters:
editable
-true
to enable manual input,false
otherwise- See Also:
-
getAsyncSearchDelayMs
public int getAsyncSearchDelayMs()- Specified by:
getAsyncSearchDelayMs
in interfaceSuggestionFieldComponent<V,
V> - 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,
V> - Parameters:
asyncSearchDelayMs
- delay in ms
-
getSearchExecutor
- Specified by:
getSearchExecutor
in interfaceSuggestionFieldComponent<V,
V> - Returns:
SuggestionFieldComponent.SearchExecutor
which performs search
-
setSearchExecutor
Description copied from interface:SuggestionFieldComponent
SetsSuggestionFieldComponent.SearchExecutor
which performs search.- Specified by:
setSearchExecutor
in interfaceEntitySuggestionField<V>
- Specified by:
setSearchExecutor
in interfaceSuggestionFieldComponent<V,
V> - Parameters:
searchExecutor
- SearchExecutor instance
-
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,
V> - Returns:
- an ARROW_DOWN press handler
-
setArrowDownHandler
public void setArrowDownHandler(@Nullable Consumer<SuggestionFieldComponent.ArrowDownEvent> handler) Description copied from interface:SuggestionFieldComponent
Sets an ARROW_DOWN press handler.- Specified by:
setArrowDownHandler
in interfaceSuggestionFieldComponent<V,
V> - Parameters:
handler
- an ARROW_DOWN press handler to set
-
getMinSearchStringLength
public int getMinSearchStringLength()- Specified by:
getMinSearchStringLength
in interfaceSuggestionFieldComponent<V,
V> - 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,
V> - Parameters:
minSearchStringLength
- required string length to perform search
-
getSuggestionsLimit
public int getSuggestionsLimit()- Specified by:
getSuggestionsLimit
in interfaceSuggestionFieldComponent<V,
V> - 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,
V> - Parameters:
suggestionsLimit
- integer limit value
-
showSuggestions
Description copied from interface:SuggestionFieldComponent
Show passed suggestions in popup.- Specified by:
showSuggestions
in interfaceSuggestionFieldComponent<V,
V> - Parameters:
suggestions
- suggestions to show
-
showSuggestions
-
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,
V> - Parameters:
popupWidth
- width of the component popup
-
getPopupWidth
- Specified by:
getPopupWidth
in interfaceSuggestionFieldComponent<V,
V> - Returns:
- component popup width
-
getInputPrompt
- Specified by:
getInputPrompt
in interfaceHasInputPrompt
- Overrides:
getInputPrompt
in classValuePickerImpl<V>
- 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
- Overrides:
setInputPrompt
in classValuePickerImpl<V>
- Parameters:
inputPrompt
- input prompt
-
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
-
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<JmixPickerField<V>>
- 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<JmixPickerField<V>>
- 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<JmixPickerField<V>>
- Parameters:
styleName
- one or more style names separated by space.
-
checkValueType
- Overrides:
checkValueType
in classEntityPickerImpl<V>
-
onEnterPressHandler
-
onArrowDownHandler
-