Package io.jmix.ui.component.impl
Class TagPickerImpl<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<Collection<V>>
io.jmix.ui.component.impl.ValuesPickerImpl<V>
io.jmix.ui.component.impl.TagPickerImpl<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<Collection<V>>,Field<Collection<V>>,HasContextHelp,HasDebugId,HasFilterMode,HasFormatter<Collection<V>>,HasHtmlCaption,HasHtmlDescription,HasHtmlSanitizer,HasInputPrompt,HasOptionCaptionProvider<V>,HasSubParts,HasValidator<Collection<V>>,HasValue<Collection<V>>,OptionsField<Collection<V>,,V> Requirable,SecuredActionsHolder,SupportsUserAction<Collection<V>>,TagPicker<V>,Validatable,ValuePicker<Collection<V>>,ValuesPicker<V>,org.springframework.beans.factory.InitializingBean
public class TagPickerImpl<V>
extends ValuesPickerImpl<V>
implements TagPicker<V>, org.springframework.beans.factory.InitializingBean
-
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.HasContextHelp
HasContextHelp.ContextHelpIconClickEventNested classes/interfaces inherited from interface io.jmix.ui.component.HasFilterMode
HasFilterMode.FilterModeNested classes/interfaces inherited from interface io.jmix.ui.component.HasValue
HasValue.ValueChangeEvent<V>Nested classes/interfaces inherited from interface io.jmix.ui.component.TagPicker
TagPicker.TagClickEvent<V>, TagPicker.TagPickerAction, TagPicker.TagPositionNested classes/interfaces inherited from interface io.jmix.ui.component.ValuePicker
ValuePicker.FieldValueChangeEvent<V>, ValuePicker.ValuePickerAction -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HasFilterMode.FilterModeprotected booleanprotected MetaClassstatic final Stringprotected OptionsBinding<V>Fields 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.ValuePicker
NAME, TYPE_STRINGFields inherited from interface io.jmix.ui.component.ValuesPicker
NAME, TYPE_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an action to the component with index.Adds a listener that will be fired in case field is editable.addTagClickListener(Consumer<TagPicker.TagClickEvent<V>> listener) Sets tag click listener.protected voidcomponentValueChanged(Collection<V> prevComponentValue, Collection<V> newComponentValue, boolean isUserOriginated) protected JmixTagPicker<V>protected booleanfilterItem(String itemCaption, String filterText) protected StringgenerateDefaultItemCaption(V item) protected StringgenerateOptionCaption(V item) protected StringgenerateTagCaption(V item) protected JmixComboBox<V>protected JmixTagPicker<V>intComparator<? super V>protected voidhideSelectedOptionsInPresentation(Collection<V> compValue) protected voidinitComponent(JmixPickerField<Collection<V>> component) booleanbooleanprotected voidonNewItemEntered(String itemCaption) protected voidonTagClick(V item) voidremoveAction(Action action) Remove the action from the componentprotected SubscriptionremoveTagLabelClickListener(Consumer<TagPicker.TagClickEvent<V>> listener) voidsetFilterMode(HasFilterMode.FilterMode filterMode) Sets filter mode for the dropdown list in the field.voidsetFormatter(Formatter<? super Collection<V>> formatter) voidsetHideSelectedOptions(boolean hide) Sets whether the field should hide options from the dropdown list if they have already selected.voidsetInlineTags(boolean inline) Defines how tags should be oriented in the field: inline = true - tags will be shown one after another in one line if it will be enough available space.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.protected voidsetItemsToPresentation(Stream<V> options) voidsetMetaClass(MetaClass metaClass) Sets entity meta class to the field.voidsetOptionCaptionProvider(Function<? super V, String> optionCaptionProvider) Sets function that provides caption for option items.voidsetOptions(Options<V> options) Sets options for UI component.voidsetPageLength(int pageLength) Sets the page length for the suggestion popup.voidsetTagCaptionProvider(Function<? super V, String> tagCaptionProvider) Sets caption provider.voidsetTagComparator(Comparator<? super V> tagComparator) Sets comparator for sorting tags in the UI.voidsetTagPosition(TagPicker.TagPosition position) Sets position where tags should be placed relative to the field.voidsetTagStyleProvider(Function<? super V, String> tagStyleProvider) Sets tag style provider.protected voidsetValueInternal(Collection<V> value, boolean userOriginated) protected voidMethods inherited from class io.jmix.ui.component.impl.ValuesPickerImpl
convertToModel, convertToPresentation, equalCollections, fieldValueEquals, fireValueChange, getOldValue, isEmpty, setValue, setValueFromUserMethods inherited from class io.jmix.ui.component.impl.ValuePickerImpl
actionPropertyChanged, addAction, afterPropertiesSet, applyDefaultValueFormat, commit, discard, focus, formatValue, generateOptionIcon, getAction, getActions, getActionsPermissions, getFieldIconProvider, getTabIndex, isBuffered, isFieldEditable, isModified, onFieldValueChange, refreshActionsState, removeAction, removeAllActions, setBuffered, setButtonIcon, setDebugId, setEditableToComponent, setFieldEditable, setFieldIconProvider, 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, getValue, getValueSource, setUiTestId, setUiTestIdsSupport, setValueSource, setValueToPresentation, valueBindingActivated, valueBindingConnectedMethods 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, setDescription, setDescriptionAsHtml, setEnabled, setHeight, setHtmlSanitizerEnabled, setIcon, setIconFromSet, setId, setResponsive, setStyleName, 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, getAction, getActionNN, getActions, getSubPart, removeAction, removeAllActionsMethods inherited from interface io.jmix.ui.component.Buffered
commit, discard, isBuffered, isModified, setBufferedMethods 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, 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.HasContextHelp
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabledMethods 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 org.springframework.beans.factory.InitializingBean
afterPropertiesSetMethods inherited from interface io.jmix.ui.component.OptionsField
setOptionsEnum, setOptionsList, setOptionsMapMethods inherited from interface io.jmix.ui.component.Requirable
getRequiredMessage, isRequired, setRequired, setRequiredMessageMethods 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, isFieldEditable, setFieldEditable, setFieldIconProvider
-
Field Details
-
NOACTION_STYLENAME
- See Also:
-
optionsBinding
-
optionCaptionProvider
-
tagCaptionProvider
-
filterMode
-
hideSelectedOptions
protected boolean hideSelectedOptions -
metaClass
-
-
Constructor Details
-
TagPickerImpl
public TagPickerImpl()
-
-
Method Details
-
createComponent
- Overrides:
createComponentin classValuesPickerImpl<V>
-
initComponent
- Overrides:
initComponentin classValuePickerImpl<Collection<V>>
-
setValueInternal
- Overrides:
setValueInternalin classValuesPickerImpl<V>
-
getOptions
- Specified by:
getOptionsin interfaceOptionsField<Collection<V>,V> - Returns:
- options object
-
setOptions
Description copied from interface:OptionsFieldSets options for UI component.- Specified by:
setOptionsin interfaceOptionsField<Collection<V>,V> - Parameters:
options- options- See Also:
-
setItemsToPresentation
-
filterItem
-
setOptionCaptionProvider
Description copied from interface:HasOptionCaptionProviderSets function that provides caption for option items.- Specified by:
setOptionCaptionProviderin interfaceHasOptionCaptionProvider<V>- Parameters:
optionCaptionProvider- caption provider for options
-
getOptionCaptionProvider
- Specified by:
getOptionCaptionProviderin interfaceHasOptionCaptionProvider<V>- Returns:
- caption provider for options
-
getTagCaptionProvider
- Specified by:
getTagCaptionProviderin interfaceTagPicker<V>- Returns:
- tag caption provider or
nullif not set
-
setTagCaptionProvider
Description copied from interface:TagPickerSets caption provider. It is used for generating tag caption.For instance:
@Install(to = "tagPicker", subject = "tagCaptionProvider") private String tagPickerCaptionProvider(User user) { return "User: " + user.getUsername(); }- Specified by:
setTagCaptionProviderin interfaceTagPicker<V>- Parameters:
tagCaptionProvider- caption provider to set
-
getMetaClass
- Specified by:
getMetaClassin interfaceTagPicker<V>- Returns:
- entity meta class or
null
-
setMetaClass
Description copied from interface:TagPickerSets entity meta class to the field. It enables to use field with entity type without data container and useTagLookupAction.- Specified by:
setMetaClassin interfaceTagPicker<V>- Parameters:
metaClass- entity meta class
-
getPageLength
public int getPageLength()- Specified by:
getPageLengthin interfaceTagPicker<V>- Returns:
- the page length of the suggestion popup.
-
setPageLength
public void setPageLength(int pageLength) Description copied from interface:TagPickerSets the page length for the suggestion popup. Setting the page length to 0 will disable suggestion popup paging (all items visible).- Specified by:
setPageLengthin interfaceTagPicker<V>- Parameters:
pageLength- the pageLength to set
-
isHideSelectedOptions
public boolean isHideSelectedOptions()- Specified by:
isHideSelectedOptionsin interfaceTagPicker<V>- Returns:
- is selected options is hidden from the dropdown list
-
setHideSelectedOptions
public void setHideSelectedOptions(boolean hide) Description copied from interface:TagPickerSets whether the field should hide options from the dropdown list if they have already selected. The default value istrue.- Specified by:
setHideSelectedOptionsin interfaceTagPicker<V>- Parameters:
hide-trueif selected options should be hidden,falseotherwise
-
addTagClickListener
Description copied from interface:TagPickerSets tag click listener. It subscribes toTagPicker.TagClickEventthat is invoked when user clicks on tag content.- Specified by:
addTagClickListenerin interfaceTagPicker<V>- Parameters:
listener- listener to add- Returns:
- a registration object for removing an event listener
-
removeTagLabelClickListener
-
getTagStyleProvider
- Specified by:
getTagStyleProviderin interfaceTagPicker<V>- Returns:
- tag style provider or
nullif not set
-
setTagStyleProvider
Description copied from interface:TagPickerSets tag style provider. It is used for generating style name for tag.For instance:
@Install(to = "tagPicker", subject = "tagStyleProvider") private String tagPickerTagStyleProvider(User user) { switch (user.getAccountType()) { case PREMIUM: return "user-premium"; case COMMON: return "user-common"; default: return null; } }- Specified by:
setTagStyleProviderin interfaceTagPicker<V>- Parameters:
tagStyleProvider- tag style provider to set
-
getFilterMode
- Specified by:
getFilterModein interfaceHasFilterMode- Returns:
- filter mode for the dropdown list in the field
-
setFilterMode
Description copied from interface:HasFilterModeSets filter mode for the dropdown list in the field.- Specified by:
setFilterModein interfaceHasFilterMode- Parameters:
filterMode- filter mode to set
-
getInputPrompt
- Specified by:
getInputPromptin interfaceHasInputPrompt- Overrides:
getInputPromptin classValuePickerImpl<Collection<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<Collection<V>>- Parameters:
inputPrompt- input prompt
-
isInlineTags
public boolean isInlineTags()- Specified by:
isInlineTagsin interfaceTagPicker<V>- Returns:
trueif tags should be placed inline
-
setInlineTags
public void setInlineTags(boolean inline) Description copied from interface:TagPickerDefines how tags should be oriented in the field:- inline = true - tags will be shown one after another in one line if it will be enough available space.
Otherwise, the next tags will be moved to another line. The width of the tag is
AUTO. - inline = false - tags will be shown under each other. Tag occupies all available space on the line.
false.- Specified by:
setInlineTagsin interfaceTagPicker<V>- Parameters:
inline- whether tags should be placed inline
- inline = true - tags will be shown one after another in one line if it will be enough available space.
Otherwise, the next tags will be moved to another line. The width of the tag is
-
getTagPosition
- Specified by:
getTagPositionin interfaceTagPicker<V>- Returns:
- position of tags relative to the field
-
setTagPosition
Description copied from interface:TagPickerSets position where tags should be placed relative to the field.TagPicker.TagPosition.TOP- tags are placed above the field.TagPicker.TagPosition.RIGHT- tags are placed to the right of the field.TagPicker.TagPosition.BOTTOM- tags are placed under the field.TagPicker.TagPosition.LEFT- tags are placed to the left of the field.
TagPicker.TagPosition.BOTTOM.- Specified by:
setTagPositionin interfaceTagPicker<V>- Parameters:
position- position to set
-
getTagComparator
- Specified by:
getTagComparatorin interfaceTagPicker<V>- Returns:
- tag comparator
-
setTagComparator
Description copied from interface:TagPickerSets comparator for sorting tags in the UI.- Specified by:
setTagComparatorin interfaceTagPicker<V>- Parameters:
tagComparator- comparator to set
-
setFormatter
- Specified by:
setFormatterin interfaceHasFormatter<V>- Overrides:
setFormatterin classValuePickerImpl<Collection<V>>
-
getFormatter
- Specified by:
getFormatterin interfaceHasFormatter<V>- Overrides:
getFormatterin classValuePickerImpl<Collection<V>>
-
addFieldValueChangeListener
public Subscription addFieldValueChangeListener(Consumer<ValuePicker.FieldValueChangeEvent<Collection<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<Collection<V>>- Parameters:
listener- a listener to add- Returns:
- a
Subscriptionobject - See Also:
-
addAction
Description copied from interface:ActionsHolderAdd an action to the component with index.- Specified by:
addActionin interfaceActionsHolder- Overrides:
addActionin classValuePickerImpl<Collection<V>>
-
removeAction
Description copied from interface:ActionsHolderRemove the action from the component- Specified by:
removeActionin interfaceActionsHolder- Overrides:
removeActionin classValuePickerImpl<Collection<V>>
-
updateNoActionStyle
protected void updateNoActionStyle() -
componentValueChanged
protected void componentValueChanged(Collection<V> prevComponentValue, Collection<V> newComponentValue, boolean isUserOriginated) - Overrides:
componentValueChangedin classAbstractValueComponent<JmixPickerField<Collection<V>>,Collection<V>, Collection<V>>
-
hideSelectedOptionsInPresentation
-
generateOptionCaption
-
generateTagCaption
-
generateDefaultItemCaption
-
getJmixTagPicker
-
getFieldInternal
-
onTagClick
-
onNewItemEntered
-