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.WebValuePickerActionHandlerNested 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.EntityPicker
EntityPicker.EntityPickerActionNested 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.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
FieldsModifier and TypeFieldDescriptionprotected Consumer<SuggestionFieldComponent.ArrowDownEvent>protected BackgroundWorkerprotected Consumer<HasEnterPressHandler.EnterPressEvent>protected BackgroundTaskHandler<List<V>>protected Localeprotected SuggestionFieldComponent.SearchExecutor<V>Fields inherited from class io.jmix.ui.component.impl.EntityPickerImpl
metaClass, metadataFields inherited from class io.jmix.ui.component.impl.ValuePickerImpl
actionButtons, actionHandler, actionPropertyChangeListener, actions, actionsPermissions, fieldIconProvider, fieldListenerRegistration, formatter, metadataToolsFields 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.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZEFields inherited from interface io.jmix.ui.component.EntityPicker
NAMEFields inherited from interface io.jmix.ui.component.EntitySuggestionField
NAMEFields inherited from interface io.jmix.ui.component.SuggestionFieldComponent
POPUP_AUTO_WIDTH, POPUP_PARENT_WIDTHFields inherited from interface io.jmix.ui.component.ValuePicker
NAME, TYPE_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a listener that will be fired in case field is editable.voidaddStyleName(String styleName) Adds one or more style names to this component.asyncSearch(SuggestionFieldComponent.SearchExecutor<V> searchExecutor, String searchString, Map<String, Object> params) protected voidprotected voidcheckValueType(V value) protected JmixPickerField<V>protected StringgenerateItemStylename(Object item) intintprotected BackgroundTask<Long,List<V>> getSearchSuggestionsTask(String query) intprotected voidhandleSearchResult(List<V> results) protected voidinitComponent(JmixPickerField<V> component) booleanprotected voidonArrowDownHandler(String currentSearchString) protected voidonEnterPressHandler(String currentSearchString) voidremoveStyleName(String styleName) Removes one or more style names from component.protected voidsearchSuggestions(String query) voidSets an ARROW_DOWN press handler.voidsetAsyncSearchDelayMs(int asyncSearchDelayMs) Sets delay between the last key press action and async search.voidsetBackgroundWorker(BackgroundWorker backgroundWorker) voidsetCurrentAuthentication(CurrentAuthentication currentAuthentication) voidSets an ENTER press handler.voidsetFieldEditable(boolean editable) Sets whether a user can input the value manually.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.voidsetMinSearchStringLength(int minSearchStringLength) Sets min string length which is required to perform suggestions search.voidsetOptionStyleProvider(Function<? super V, String> optionStyleProvider) Sets the style provider that is used to produce custom class names for option items.voidsetPopupWidth(String popupWidth) Sets the givenwidthto the component popup.voidsetSearchExecutor(SuggestionFieldComponent.SearchExecutor<V> searchExecutor) SetsSuggestionFieldComponent.SearchExecutorwhich performs search.voidsetStyleName(String name) Sets one or more style names of the component, replacing any previous styles.voidsetSuggestionsLimit(int suggestionsLimit) Sets limit of suggestions which will be shown.voidshowSuggestions(List<V> suggestions) Show passed suggestions in popup.protected voidshowSuggestions(List<V> suggestions, boolean userOriginated) Methods inherited from class io.jmix.ui.component.impl.EntityPickerImpl
getLookupSelectedItems, getMetaClass, setLookupSelectHandler, setMetaClass, setMetadata, setValue, setValueFromUserMethods 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, setupButtonActionMethods 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, validateMethods inherited from class io.jmix.ui.component.impl.AbstractValueComponent
addValueChangeListener, componentValueChanged, convertToModel, convertToPresentation, fieldValueEquals, getValue, getValueSource, setUiTestId, setUiTestIdsSupport, setValueSource, setValueToPresentation, valueBindingActivated, valueBindingConnectedMethods 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, 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.ActionsHolder
addAction, addAction, getAction, getActionNN, getActions, getSubPart, removeAction, removeAction, removeAllActionsMethods inherited from interface io.jmix.ui.component.Buffered
commit, discard, isBuffered, isModified, setBufferedMethods 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, 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
focus, getTabIndex, isFocusable, setFocusable, setTabIndexMethods 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.EntityPicker
getMetaClass, setMetaClassMethods inherited from interface io.jmix.ui.component.HasContextHelp
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabledMethods inherited from interface io.jmix.ui.component.HasFormatter
getFormatter, setFormatterMethods 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, getValue, isEmpty, setValueMethods inherited from interface io.jmix.ui.component.data.HasValueSource
getValueSource, setValueSourceMethods inherited from interface io.jmix.ui.component.LookupComponent
getLookupSelectedItems, setLookupSelectHandlerMethods inherited from interface io.jmix.ui.component.Requirable
getRequiredMessage, isRequired, setRequired, setRequiredMessageMethods inherited from interface io.jmix.ui.component.SecuredActionsHolder
getActionsPermissionsMethods inherited from interface io.jmix.ui.component.SupportsUserAction
setValueFromUserMethods inherited from interface io.jmix.ui.component.Validatable
isValid, isValidateOnCommit, validateMethods 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:
createComponentin classEntityPickerImpl<V>
-
getComponent
- Specified by:
getComponentin interfaceComponent.Wrapper- Overrides:
getComponentin classAbstractComponent<JmixPickerField<V>>
-
setBackgroundWorker
-
initComponent
- Overrides:
initComponentin 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:ValuePickerAdds a listener that will be fired in case field is editable.- Specified by:
addFieldValueChangeListenerin interfaceValuePicker<V>- Overrides:
addFieldValueChangeListenerin classValuePickerImpl<V>- Parameters:
listener- a listener to add- Returns:
- a
Subscriptionobject - See Also:
-
isFieldEditable
public boolean isFieldEditable()- Specified by:
isFieldEditablein interfaceValuePicker<V>- Overrides:
isFieldEditablein classValuePickerImpl<V>- Returns:
- whether a user can input the value manually
-
setFieldEditable
public void setFieldEditable(boolean editable) Description copied from interface:ValuePickerSets whether a user can input the value manually.falseby default. Doesn't set entered value to the model. To handle user input, theValuePicker.FieldValueChangeEventlistener must be used.- Specified by:
setFieldEditablein interfaceValuePicker<V>- Overrides:
setFieldEditablein classValuePickerImpl<V>- Parameters:
editable-trueto enable manual input,falseotherwise- See Also:
-
getAsyncSearchDelayMs
public int getAsyncSearchDelayMs()- Specified by:
getAsyncSearchDelayMsin interfaceSuggestionFieldComponent<V,V> - Returns:
- delay between the last key press action and async search
-
setAsyncSearchDelayMs
public void setAsyncSearchDelayMs(int asyncSearchDelayMs) Description copied from interface:SuggestionFieldComponentSets delay between the last key press action and async search.- Specified by:
setAsyncSearchDelayMsin interfaceSuggestionFieldComponent<V,V> - Parameters:
asyncSearchDelayMs- delay in ms
-
getSearchExecutor
- Specified by:
getSearchExecutorin interfaceSuggestionFieldComponent<V,V> - Returns:
SuggestionFieldComponent.SearchExecutorwhich performs search
-
setSearchExecutor
Description copied from interface:SuggestionFieldComponentSetsSuggestionFieldComponent.SearchExecutorwhich performs search.- Specified by:
setSearchExecutorin interfaceEntitySuggestionField<V>- Specified by:
setSearchExecutorin interfaceSuggestionFieldComponent<V,V> - Parameters:
searchExecutor- SearchExecutor instance
-
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
-
getArrowDownHandler
- Specified by:
getArrowDownHandlerin interfaceSuggestionFieldComponent<V,V> - Returns:
- an ARROW_DOWN press handler
-
setArrowDownHandler
public void setArrowDownHandler(@Nullable Consumer<SuggestionFieldComponent.ArrowDownEvent> handler) Description copied from interface:SuggestionFieldComponentSets an ARROW_DOWN press handler.- Specified by:
setArrowDownHandlerin interfaceSuggestionFieldComponent<V,V> - Parameters:
handler- an ARROW_DOWN press handler to set
-
getMinSearchStringLength
public int getMinSearchStringLength()- Specified by:
getMinSearchStringLengthin interfaceSuggestionFieldComponent<V,V> - Returns:
- min string length to perform suggestions search
-
setMinSearchStringLength
public void setMinSearchStringLength(int minSearchStringLength) Description copied from interface:SuggestionFieldComponentSets min string length which is required to perform suggestions search.- Specified by:
setMinSearchStringLengthin interfaceSuggestionFieldComponent<V,V> - Parameters:
minSearchStringLength- required string length to perform search
-
getSuggestionsLimit
public int getSuggestionsLimit()- Specified by:
getSuggestionsLimitin interfaceSuggestionFieldComponent<V,V> - Returns:
- limit of suggestions which will be shown
-
setSuggestionsLimit
public void setSuggestionsLimit(int suggestionsLimit) Description copied from interface:SuggestionFieldComponentSets limit of suggestions which will be shown.- Specified by:
setSuggestionsLimitin interfaceSuggestionFieldComponent<V,V> - Parameters:
suggestionsLimit- integer limit value
-
showSuggestions
Description copied from interface:SuggestionFieldComponentShow passed suggestions in popup.- Specified by:
showSuggestionsin interfaceSuggestionFieldComponent<V,V> - Parameters:
suggestions- suggestions to show
-
showSuggestions
-
setPopupWidth
Description copied from interface:SuggestionFieldComponentSets the givenwidthto the component popup. There are two predefined settings available:SuggestionFieldComponent.POPUP_AUTO_WIDTHandSuggestionFieldComponent.POPUP_PARENT_WIDTH.- Specified by:
setPopupWidthin interfaceSuggestionFieldComponent<V,V> - Parameters:
popupWidth- width of the component popup
-
getPopupWidth
- Specified by:
getPopupWidthin interfaceSuggestionFieldComponent<V,V> - Returns:
- component popup width
-
getInputPrompt
- Specified by:
getInputPromptin interfaceHasInputPrompt- Overrides:
getInputPromptin classValuePickerImpl<V>- 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- Overrides:
setInputPromptin classValuePickerImpl<V>- Parameters:
inputPrompt- input prompt
-
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
-
setStyleName
Description copied from interface:ComponentSets 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:
setStyleNamein interfaceComponent- Overrides:
setStyleNamein classAbstractComponent<JmixPickerField<V>>- Parameters:
name- one or more style names separated by space.
-
addStyleName
Description copied from interface:ComponentAdds one or more style names to this component. Multiple styles can be specified as a space-separated list of style names.- Specified by:
addStyleNamein interfaceComponent- Overrides:
addStyleNamein classAbstractComponent<JmixPickerField<V>>- Parameters:
styleName- one or more style names separated by space.
-
removeStyleName
Description copied from interface:ComponentRemoves one or more style names from component. Multiple styles can be specified as a space-separated list of style names.- Specified by:
removeStyleNamein interfaceComponent- Overrides:
removeStyleNamein classAbstractComponent<JmixPickerField<V>>- Parameters:
styleName- one or more style names separated by space.
-
checkValueType
- Overrides:
checkValueTypein classEntityPickerImpl<V>
-
onEnterPressHandler
-
onArrowDownHandler
-