V
- value type - collection or notI
- item typeT
- component typepublic abstract class AbstractSuggestionField<V,I,T extends JmixAbstractSuggestionField<V,I>> extends AbstractField<T,V,V> implements SuggestionFieldComponent<V,I>, org.springframework.beans.factory.InitializingBean
SuggestionFieldComponent.ArrowDownEvent, SuggestionFieldComponent.ParametrizedSearchExecutor<E>, SuggestionFieldComponent.SearchExecutor<E>
HasValue.ValueChangeEvent<V>
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper
HasContextHelp.ContextHelpIconClickEvent
HasEnterPressHandler.EnterPressEvent
Modifier and Type | Field and Description |
---|---|
protected java.util.function.Consumer<SuggestionFieldComponent.ArrowDownEvent> |
arrowDownHandler |
protected BackgroundWorker |
backgroundWorker |
protected java.util.function.Consumer<HasEnterPressHandler.EnterPressEvent> |
enterPressHandler |
protected Formatter<? super I> |
formatter |
protected BackgroundTaskHandler<java.util.List<I>> |
handler |
protected java.util.Locale |
locale |
protected io.jmix.core.MetadataTools |
metadataTools |
protected java.util.function.Function<? super I,java.lang.String> |
optionStyleProvider |
protected SuggestionFieldComponent.SearchExecutor<I> |
searchExecutor |
editable, parentEditableChangeListener, validators, VALIDATORS_LIST_INITIAL_CAPACITY
internalValue, uiTestIdsSupport, valueBinding
alignment, applicationContext, component, contextHelpIconClickHandler, contextHelpIconClickListener, descriptionAsHtml, element, frame, htmlSanitizerEnabled, icon, ICON_STYLE, id, parent
POPUP_AUTO_WIDTH, POPUP_PARENT_WIDTH
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE
Constructor and Description |
---|
AbstractSuggestionField() |
Modifier and Type | Method and Description |
---|---|
void |
addStyleName(java.lang.String styleName)
Adds one or more style names to this component.
|
void |
afterPropertiesSet() |
protected java.lang.String |
applyDefaultValueFormat(I item) |
protected java.util.List<I> |
asyncSearch(SuggestionFieldComponent.SearchExecutor<I> searchExecutor,
java.lang.String searchString,
java.util.Map<java.lang.String,java.lang.Object> params) |
protected void |
cancelSearch() |
protected java.lang.String |
convertToTextView(I item) |
void |
focus()
Sets focus to this component
|
protected java.lang.String |
generateItemStylename(java.lang.Object item) |
java.util.function.Consumer<SuggestionFieldComponent.ArrowDownEvent> |
getArrowDownHandler() |
int |
getAsyncSearchDelayMs() |
java.util.function.Consumer<HasEnterPressHandler.EnterPressEvent> |
getEnterPressHandler() |
Formatter<I> |
getFormatter() |
java.lang.String |
getInputPrompt() |
int |
getMinSearchStringLength() |
java.util.function.Function<? super I,java.lang.String> |
getOptionStyleProvider() |
java.lang.String |
getPopupWidth() |
SuggestionFieldComponent.SearchExecutor<I> |
getSearchExecutor() |
protected BackgroundTask<java.lang.Long,java.util.List<I>> |
getSearchSuggestionsTask(java.lang.String query) |
int |
getSuggestionsLimit() |
int |
getTabIndex()
Gets the tabulator index of the
HasTabIndex component. |
protected void |
handleSearchResult(java.util.List<I> results) |
protected void |
initComponent(T component) |
protected void |
onArrowDownHandler(java.lang.String currentSearchString) |
protected void |
onEnterPressHandler(java.lang.String currentSearchString) |
void |
removeStyleName(java.lang.String styleName)
Removes one or more style names from component.
|
protected void |
searchSuggestions(java.lang.String query) |
void |
setArrowDownHandler(java.util.function.Consumer<SuggestionFieldComponent.ArrowDownEvent> handler)
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(io.jmix.core.security.CurrentAuthentication currentAuthentication) |
void |
setEnterPressHandler(java.util.function.Consumer<HasEnterPressHandler.EnterPressEvent> handler)
Sets an ENTER press handler.
|
void |
setFormatter(Formatter<? super I> formatter) |
void |
setInputPrompt(java.lang.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(io.jmix.core.MetadataTools metadataTools) |
void |
setMinSearchStringLength(int minSearchStringLength)
Sets min string length which is required to perform suggestions search.
|
void |
setOptionStyleProvider(java.util.function.Function<? super I,java.lang.String> optionStyleProvider)
Sets the style provider that is used to produce custom class names for option items.
|
void |
setPopupWidth(java.lang.String popupWidth)
Sets the given
width to the component popup. |
void |
setSearchExecutor(SuggestionFieldComponent.SearchExecutor<I> searchExecutor)
Sets
SuggestionFieldComponent.SearchExecutor which performs search. |
void |
setStyleName(java.lang.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 the
Focusable component. |
void |
showSuggestions(java.util.List<I> suggestions)
Show passed suggestions in popup.
|
protected void |
showSuggestions(java.util.List<I> suggestions,
boolean userOriginated) |
addValidator, attachValueChangeListener, getDatatypeConversionErrorMsg, getDefaultRequiredMessage, getErrorMessage, getRequiredMessage, getValidators, isEditable, isRequired, isValid, removeValidator, setEditable, setEditableToComponent, setParent, setRequired, setRequiredMessage, setupComponentErrorProvider, triggerValidators, validate
addValueChangeListener, commit, componentValueChanged, convertToModel, convertToPresentation, discard, fieldValueEquals, getValue, getValueSource, isBuffered, isModified, setBuffered, setUiTestId, setUiTestIdsSupport, setValue, setValueSource, setValueToPresentation, valueBindingActivated, valueBindingConnected
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getValueSource, setValueSource
addValueChangeListener, clear, getEmptyValue, getValue, isEmpty, setValue
isEditable, isEditableWithParent, setEditable
getFrame, setFrame
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
isValid, isValidateOnCommit, validate
getIcon, setIcon, setIconFromSet
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled
isCaptionAsHtml, setCaptionAsHtml
getCaption, setCaption
getDescription, setDescription
isDescriptionAsHtml, setDescriptionAsHtml
isHtmlSanitizerEnabled, setHtmlSanitizerEnabled
addValidator, addValidators, getValidators, removeValidator
getRequiredMessage, isRequired, setRequired, setRequiredMessage
isFocusable, setFocusable
protected BackgroundTaskHandler<java.util.List<I>> handler
protected SuggestionFieldComponent.SearchExecutor<I> searchExecutor
protected BackgroundWorker backgroundWorker
protected io.jmix.core.MetadataTools metadataTools
protected java.util.Locale locale
protected java.util.function.Function<? super I,java.lang.String> optionStyleProvider
protected java.util.function.Consumer<HasEnterPressHandler.EnterPressEvent> enterPressHandler
protected java.util.function.Consumer<SuggestionFieldComponent.ArrowDownEvent> arrowDownHandler
@Autowired protected void setBackgroundWorker(BackgroundWorker backgroundWorker)
@Autowired public void setCurrentAuthentication(io.jmix.core.security.CurrentAuthentication currentAuthentication)
@Autowired protected void setMetadataTools(io.jmix.core.MetadataTools metadataTools)
public void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception
protected void initComponent(T component)
public void setSearchExecutor(@Nullable SuggestionFieldComponent.SearchExecutor<I> searchExecutor)
SuggestionFieldComponent
SuggestionFieldComponent.SearchExecutor
which performs search.setSearchExecutor
in interface SuggestionFieldComponent<V,I>
searchExecutor
- SearchExecutor instance@Nullable public SuggestionFieldComponent.SearchExecutor<I> getSearchExecutor()
getSearchExecutor
in interface SuggestionFieldComponent<V,I>
SuggestionFieldComponent.SearchExecutor
which performs searchpublic int getMinSearchStringLength()
getMinSearchStringLength
in interface SuggestionFieldComponent<V,I>
public void setMinSearchStringLength(int minSearchStringLength)
SuggestionFieldComponent
setMinSearchStringLength
in interface SuggestionFieldComponent<V,I>
minSearchStringLength
- required string length to perform searchpublic int getSuggestionsLimit()
getSuggestionsLimit
in interface SuggestionFieldComponent<V,I>
public void setSuggestionsLimit(int suggestionsLimit)
SuggestionFieldComponent
setSuggestionsLimit
in interface SuggestionFieldComponent<V,I>
suggestionsLimit
- integer limit valuepublic int getAsyncSearchDelayMs()
getAsyncSearchDelayMs
in interface SuggestionFieldComponent<V,I>
public void setAsyncSearchDelayMs(int asyncSearchDelayMs)
SuggestionFieldComponent
setAsyncSearchDelayMs
in interface SuggestionFieldComponent<V,I>
asyncSearchDelayMs
- delay in ms@Nullable public java.util.function.Consumer<HasEnterPressHandler.EnterPressEvent> getEnterPressHandler()
getEnterPressHandler
in interface HasEnterPressHandler
public void setEnterPressHandler(@Nullable java.util.function.Consumer<HasEnterPressHandler.EnterPressEvent> handler)
HasEnterPressHandler
setEnterPressHandler
in interface HasEnterPressHandler
handler
- an ENTER press handler to set@Nullable public java.util.function.Consumer<SuggestionFieldComponent.ArrowDownEvent> getArrowDownHandler()
getArrowDownHandler
in interface SuggestionFieldComponent<V,I>
public void setArrowDownHandler(java.util.function.Consumer<SuggestionFieldComponent.ArrowDownEvent> handler)
SuggestionFieldComponent
setArrowDownHandler
in interface SuggestionFieldComponent<V,I>
handler
- an ARROW_DOWN press handler to setpublic void showSuggestions(java.util.List<I> suggestions)
SuggestionFieldComponent
showSuggestions
in interface SuggestionFieldComponent<V,I>
suggestions
- suggestions to showpublic void focus()
Component.Focusable
focus
in interface Component.Focusable
public int getTabIndex()
Component.Focusable
HasTabIndex
component.getTabIndex
in interface Component.Focusable
HasTabIndex
componentpublic void setTabIndex(int tabIndex)
Component.Focusable
Focusable
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.setTabIndex
in interface Component.Focusable
tabIndex
- tab index@Nullable public java.lang.String getInputPrompt()
getInputPrompt
in interface HasInputPrompt
public void setInputPrompt(@Nullable java.lang.String inputPrompt)
HasInputPrompt
setInputPrompt
in interface HasInputPrompt
inputPrompt
- input promptpublic void setStyleName(@Nullable java.lang.String name)
Component
setStyleName
in interface Component
setStyleName
in class AbstractComponent<T extends JmixAbstractSuggestionField<V,I>>
name
- one or more style names separated by space.public void addStyleName(java.lang.String styleName)
Component
addStyleName
in interface Component
addStyleName
in class AbstractComponent<T extends JmixAbstractSuggestionField<V,I>>
styleName
- one or more style names separated by space.public void removeStyleName(java.lang.String styleName)
Component
removeStyleName
in interface Component
removeStyleName
in class AbstractComponent<T extends JmixAbstractSuggestionField<V,I>>
styleName
- one or more style names separated by space.public void setPopupWidth(java.lang.String popupWidth)
SuggestionFieldComponent
width
to the component popup. There are two predefined settings available:
SuggestionFieldComponent.POPUP_AUTO_WIDTH
and SuggestionFieldComponent.POPUP_PARENT_WIDTH
.setPopupWidth
in interface SuggestionFieldComponent<V,I>
popupWidth
- width of the component popuppublic java.lang.String getPopupWidth()
getPopupWidth
in interface SuggestionFieldComponent<V,I>
public void setOptionStyleProvider(@Nullable java.util.function.Function<? super I,java.lang.String> optionStyleProvider)
HasOptionStyleProvider
setOptionStyleProvider
in interface HasOptionStyleProvider<I>
optionStyleProvider
- style provider@Nullable public java.util.function.Function<? super I,java.lang.String> getOptionStyleProvider()
getOptionStyleProvider
in interface HasOptionStyleProvider<I>
@Nullable public Formatter<I> getFormatter()
getFormatter
in interface HasFormatter<I>
public void setFormatter(@Nullable Formatter<? super I> formatter)
setFormatter
in interface HasFormatter<I>
@Nullable protected java.lang.String generateItemStylename(java.lang.Object item)
@Nullable protected BackgroundTask<java.lang.Long,java.util.List<I>> getSearchSuggestionsTask(java.lang.String query)
protected java.util.List<I> asyncSearch(SuggestionFieldComponent.SearchExecutor<I> searchExecutor, java.lang.String searchString, java.util.Map<java.lang.String,java.lang.Object> params) throws java.lang.Exception
java.lang.Exception
protected void handleSearchResult(java.util.List<I> results)
protected void showSuggestions(java.util.List<I> suggestions, boolean userOriginated)
protected void cancelSearch()
protected void searchSuggestions(java.lang.String query)
protected java.lang.String convertToTextView(@Nullable I item)
protected java.lang.String applyDefaultValueFormat(I item)
protected void onEnterPressHandler(java.lang.String currentSearchString)
protected void onArrowDownHandler(java.lang.String currentSearchString)