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.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.HasContextHelp
HasContextHelp.ContextHelpIconClickEvent
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasFilterMode
HasFilterMode.FilterMode
Nested 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.TagPosition
Nested classes/interfaces inherited from interface io.jmix.ui.component.ValuePicker
ValuePicker.FieldValueChangeEvent<V>, ValuePicker.ValuePickerAction
-
Field Summary
Modifier and TypeFieldDescriptionprotected HasFilterMode.FilterMode
protected boolean
protected MetaClass
static final String
protected OptionsBinding<V>
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.ValuePicker
NAME, TYPE_STRING
Fields inherited from interface io.jmix.ui.component.ValuesPicker
NAME, TYPE_STRING
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add 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 void
componentValueChanged
(Collection<V> prevComponentValue, Collection<V> newComponentValue, boolean isUserOriginated) protected JmixTagPicker<V>
protected boolean
filterItem
(String itemCaption, String filterText) protected String
generateDefaultItemCaption
(V item) protected String
generateOptionCaption
(V item) protected String
generateTagCaption
(V item) protected JmixComboBox<V>
protected JmixTagPicker<V>
Comparator<? super V>
protected void
hideSelectedOptionsInPresentation
(Collection<V> compValue) protected void
initComponent
(JmixPickerField<Collection<V>> component) boolean
boolean
protected void
onNewItemEntered
(String itemCaption) protected void
onTagClick
(V item) void
removeAction
(Action action) Remove the action from the componentprotected Subscription
removeTagLabelClickListener
(Consumer<TagPicker.TagClickEvent<V>> listener) void
setFilterMode
(HasFilterMode.FilterMode filterMode) Sets filter mode for the dropdown list in the field.void
setFormatter
(Formatter<? super Collection<V>> formatter) void
setHideSelectedOptions
(boolean hide) Sets whether the field should hide options from the dropdown list if they have already selected.void
setInlineTags
(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.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
setItemsToPresentation
(Stream<V> options) void
setMetaClass
(MetaClass metaClass) Sets entity meta class to the field.void
setOptionCaptionProvider
(Function<? super V, String> optionCaptionProvider) Sets function that provides caption for option items.void
setOptions
(Options<V> options) Sets options for UI component.void
setTagCaptionProvider
(Function<? super V, String> tagCaptionProvider) Sets caption provider.void
setTagComparator
(Comparator<? super V> tagComparator) Sets comparator for sorting tags in the UI.void
setTagPosition
(TagPicker.TagPosition position) Sets position where tags should be placed relative to the field.void
setTagStyleProvider
(Function<? super V, String> tagStyleProvider) Sets tag style provider.protected void
setValueInternal
(Collection<V> value, boolean userOriginated) protected void
Methods inherited from class io.jmix.ui.component.impl.ValuesPickerImpl
convertToModel, convertToPresentation, equalCollections, fieldValueEquals, fireValueChange, getOldValue, isEmpty, setValue, setValueFromUser
Methods 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, 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, getValue, getValueSource, setUiTestId, setUiTestIdsSupport, setValueSource, setValueToPresentation, valueBindingActivated, valueBindingConnected
Methods 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, 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, getAction, getActionNN, getActions, getSubPart, 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
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, 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.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 org.springframework.beans.factory.InitializingBean
afterPropertiesSet
Methods inherited from interface io.jmix.ui.component.OptionsField
setOptionsEnum, setOptionsList, setOptionsMap
Methods inherited from interface io.jmix.ui.component.Requirable
getRequiredMessage, isRequired, setRequired, setRequiredMessage
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, 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:
createComponent
in classValuesPickerImpl<V>
-
initComponent
- Overrides:
initComponent
in classValuePickerImpl<Collection<V>>
-
setValueInternal
- Overrides:
setValueInternal
in classValuesPickerImpl<V>
-
getOptions
- Specified by:
getOptions
in interfaceOptionsField<Collection<V>,
V> - Returns:
- options object
-
setOptions
Description copied from interface:OptionsField
Sets options for UI component.- Specified by:
setOptions
in interfaceOptionsField<Collection<V>,
V> - Parameters:
options
- options- See Also:
-
setItemsToPresentation
-
filterItem
-
setOptionCaptionProvider
Description copied from interface:HasOptionCaptionProvider
Sets function that provides caption for option items.- Specified by:
setOptionCaptionProvider
in interfaceHasOptionCaptionProvider<V>
- Parameters:
optionCaptionProvider
- caption provider for options
-
getOptionCaptionProvider
- Specified by:
getOptionCaptionProvider
in interfaceHasOptionCaptionProvider<V>
- Returns:
- caption provider for options
-
getTagCaptionProvider
- Specified by:
getTagCaptionProvider
in interfaceTagPicker<V>
- Returns:
- tag caption provider or
null
if not set
-
setTagCaptionProvider
Description copied from interface:TagPicker
Sets 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:
setTagCaptionProvider
in interfaceTagPicker<V>
- Parameters:
tagCaptionProvider
- caption provider to set
-
getMetaClass
- Specified by:
getMetaClass
in interfaceTagPicker<V>
- Returns:
- entity meta class or
null
-
setMetaClass
Description copied from interface:TagPicker
Sets entity meta class to the field. It enables to use field with entity type without data container and useTagLookupAction
.- Specified by:
setMetaClass
in interfaceTagPicker<V>
- Parameters:
metaClass
- entity meta class
-
isHideSelectedOptions
public boolean isHideSelectedOptions()- Specified by:
isHideSelectedOptions
in interfaceTagPicker<V>
- Returns:
- is selected options is hidden from the dropdown list
-
setHideSelectedOptions
public void setHideSelectedOptions(boolean hide) Description copied from interface:TagPicker
Sets whether the field should hide options from the dropdown list if they have already selected. The default value istrue
.- Specified by:
setHideSelectedOptions
in interfaceTagPicker<V>
- Parameters:
hide
-true
if selected options should be hidden,false
otherwise
-
addTagClickListener
Description copied from interface:TagPicker
Sets tag click listener. It subscribes toTagPicker.TagClickEvent
that is invoked when user clicks on tag content.- Specified by:
addTagClickListener
in interfaceTagPicker<V>
- Parameters:
listener
- listener to add- Returns:
- a registration object for removing an event listener
-
removeTagLabelClickListener
-
getTagStyleProvider
- Specified by:
getTagStyleProvider
in interfaceTagPicker<V>
- Returns:
- tag style provider or
null
if not set
-
setTagStyleProvider
Description copied from interface:TagPicker
Sets 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:
setTagStyleProvider
in interfaceTagPicker<V>
- Parameters:
tagStyleProvider
- tag style provider to set
-
getFilterMode
- Specified by:
getFilterMode
in interfaceHasFilterMode
- Returns:
- filter mode for the dropdown list in the field
-
setFilterMode
Description copied from interface:HasFilterMode
Sets filter mode for the dropdown list in the field.- Specified by:
setFilterMode
in interfaceHasFilterMode
- Parameters:
filterMode
- filter mode to set
-
getInputPrompt
- Specified by:
getInputPrompt
in interfaceHasInputPrompt
- Overrides:
getInputPrompt
in classValuePickerImpl<Collection<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<Collection<V>>
- Parameters:
inputPrompt
- input prompt
-
isInlineTags
public boolean isInlineTags()- Specified by:
isInlineTags
in interfaceTagPicker<V>
- Returns:
true
if tags should be placed inline
-
setInlineTags
public void setInlineTags(boolean inline) Description copied from interface:TagPicker
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.
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:
setInlineTags
in 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:
getTagPosition
in interfaceTagPicker<V>
- Returns:
- position of tags relative to the field
-
setTagPosition
Description copied from interface:TagPicker
Sets 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:
setTagPosition
in interfaceTagPicker<V>
- Parameters:
position
- position to set
-
getTagComparator
- Specified by:
getTagComparator
in interfaceTagPicker<V>
- Returns:
- tag comparator
-
setTagComparator
Description copied from interface:TagPicker
Sets comparator for sorting tags in the UI.- Specified by:
setTagComparator
in interfaceTagPicker<V>
- Parameters:
tagComparator
- comparator to set
-
setFormatter
- Specified by:
setFormatter
in interfaceHasFormatter<V>
- Overrides:
setFormatter
in classValuePickerImpl<Collection<V>>
-
getFormatter
- Specified by:
getFormatter
in interfaceHasFormatter<V>
- Overrides:
getFormatter
in classValuePickerImpl<Collection<V>>
-
addFieldValueChangeListener
public Subscription addFieldValueChangeListener(Consumer<ValuePicker.FieldValueChangeEvent<Collection<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<Collection<V>>
- Parameters:
listener
- a listener to add- Returns:
- a
Subscription
object - See Also:
-
addAction
Description copied from interface:ActionsHolder
Add an action to the component with index.- Specified by:
addAction
in interfaceActionsHolder
- Overrides:
addAction
in classValuePickerImpl<Collection<V>>
-
removeAction
Description copied from interface:ActionsHolder
Remove the action from the component- Specified by:
removeAction
in interfaceActionsHolder
- Overrides:
removeAction
in classValuePickerImpl<Collection<V>>
-
updateNoActionStyle
protected void updateNoActionStyle() -
componentValueChanged
protected void componentValueChanged(Collection<V> prevComponentValue, Collection<V> newComponentValue, boolean isUserOriginated) - Overrides:
componentValueChanged
in classAbstractValueComponent<JmixPickerField<Collection<V>>,
Collection<V>, Collection<V>>
-
hideSelectedOptionsInPresentation
-
generateOptionCaption
-
generateTagCaption
-
generateDefaultItemCaption
-
getJmixTagPicker
-
getFieldInternal
-
onTagClick
-
onNewItemEntered
-