Package com.storedobject.vaadin
Class TokensField<T>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<com.vaadin.flow.component.combobox.MultiSelectComboBox<T>,Set<T>>
com.vaadin.flow.component.AbstractSinglePropertyField<com.vaadin.flow.component.combobox.MultiSelectComboBox<T>,Set<T>>
com.vaadin.flow.component.combobox.ComboBoxBase<com.vaadin.flow.component.combobox.MultiSelectComboBox<T>,T,Set<T>>
com.vaadin.flow.component.combobox.MultiSelectComboBox<T>
com.storedobject.vaadin.TokensField<T>
- Type Parameters:
T- The type of items in the selection.
- All Implemented Interfaces:
RequiredField,com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.combobox.MultiSelectComboBox<T>>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<com.vaadin.flow.component.combobox.MultiSelectComboBox<T>>,com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.combobox.MultiSelectComboBox<T>>,com.vaadin.flow.component.HasAriaLabel,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasHelper,com.vaadin.flow.component.HasLabel,com.vaadin.flow.component.HasPlaceholder,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.HasValidation,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.combobox.MultiSelectComboBox<T>,,Set<T>>, Set<T>> com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.combobox.MultiSelectComboBox<T>,,Set<T>>, Set<T>> com.vaadin.flow.component.shared.HasAllowedCharPattern,com.vaadin.flow.component.shared.HasAutoOpen,com.vaadin.flow.component.shared.HasClearButton,com.vaadin.flow.component.shared.HasClientValidation,com.vaadin.flow.component.shared.HasOverlayClassName,com.vaadin.flow.component.shared.HasThemeVariant<com.vaadin.flow.component.combobox.MultiSelectComboBoxVariant>,com.vaadin.flow.component.shared.HasTooltip,com.vaadin.flow.component.shared.HasValidationProperties,com.vaadin.flow.component.shared.InputField<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.combobox.MultiSelectComboBox<T>,,Set<T>>, Set<T>> com.vaadin.flow.data.binder.HasValidator<Set<T>>,com.vaadin.flow.data.provider.HasDataView<T,,String, com.vaadin.flow.component.combobox.dataview.ComboBoxDataView<T>> com.vaadin.flow.data.provider.HasLazyDataView<T,,String, com.vaadin.flow.component.combobox.dataview.ComboBoxLazyDataView<T>> com.vaadin.flow.data.provider.HasListDataView<T,,com.vaadin.flow.component.combobox.dataview.ComboBoxListDataView<T>> com.vaadin.flow.data.selection.MultiSelect<com.vaadin.flow.component.combobox.MultiSelectComboBox<T>,,T> Serializable
public class TokensField<T>
extends com.vaadin.flow.component.combobox.MultiSelectComboBox<T>
implements RequiredField
A custom field extending
MultiSelectComboBox to support token-based multi-selection of items.
This class provides various utility methods to manipulate and manage the selected values and items available
for selection. It also implements the RequiredField interface to allow marking the field as required.- Author:
- Syam
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.combobox.MultiSelectComboBox
com.vaadin.flow.component.combobox.MultiSelectComboBox.AutoExpandModeNested classes/interfaces inherited from class com.vaadin.flow.component.combobox.ComboBoxBase
com.vaadin.flow.component.combobox.ComboBoxBase.CustomValueSetEvent<TComponent extends com.vaadin.flow.component.combobox.ComboBoxBase<TComponent,?, ?>>, com.vaadin.flow.component.combobox.ComboBoxBase.SpringData Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V> Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.shared.HasClientValidation
com.vaadin.flow.component.shared.HasClientValidation.ClientValidatedEventNested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>> -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.TokensField(com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator) Constructor.TokensField(String label) Constructor.TokensField(String label, com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator) Constructor.TokensField(String label, Collection<T> items) Constructor.TokensField(String label, Collection<T> items, com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator) Constructor.TokensField(Collection<T> items) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddItems(Collection<T> items) Add more items to the selection list.voidAdd more items to the selection list.final voidAdd more items to the selection list.voidAdd tokens to the existing set.voidDeselect all items.voidSelect all items.voidsetValue(Collection<T> value) Sets the value by converting the provided collection into a set and passing it to thesetValuemethod of the parent class.voidprotected booleanvalueEquals(Set<T> value1, Set<T> value2) Methods inherited from class com.vaadin.flow.component.combobox.MultiSelectComboBox
addSelectionListener, getAutoExpand, getI18n, getSelectedItems, getValue, isKeepFilter, isRequiredIndicatorVisible, isSelected, isSelectedItemsOnTop, onAttach, refreshValue, setAutoExpand, setI18n, setKeepFilter, setOverlayWidth, setOverlayWidth, setRequiredIndicatorVisible, setSelectedItemsOnTop, setValue, updateSelectionMethods inherited from class com.vaadin.flow.component.combobox.ComboBoxBase
addCustomValueSetListener, generateClassName, generateLabel, getAriaLabel, getAriaLabelledBy, getDataCommunicator, getDataController, getDataGenerator, getDataProvider, getDefaultValidator, getFilter, getGenericDataView, getItemClassNameGenerator, getItemLabelGenerator, getKeyMapper, getLazyDataView, getListDataView, getPageSize, getRenderManager, isAllowCustomValue, isAutofocus, isOpened, isRequired, onDetach, runBeforeClientResponse, setAllowCustomValue, setAriaLabel, setAriaLabelledBy, setAutofocus, setClassNameGenerator, setDataProvider, setDataProvider, setFilter, setI18n, setItemLabelGenerator, setItems, setItems, setItems, setItems, setItems, setItems, setItems, setItems, setItems, setItems, setItems, setItemsPageable, setItemsPageable, setItemsWithFilterConverter, setItemsWithFilterConverter, setManualValidation, setOpened, setPageSize, setRenderer, setRequired, validateMethods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, isEmpty, setModelValueMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.shared.HasAllowedCharPattern
getAllowedCharPattern, setAllowedCharPatternMethods inherited from interface com.vaadin.flow.component.shared.HasAutoOpen
isAutoOpen, setAutoOpenMethods inherited from interface com.vaadin.flow.component.shared.HasClearButton
isClearButtonVisible, setClearButtonVisibleMethods inherited from interface com.vaadin.flow.component.shared.HasClientValidation
addClientValidatedEventListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.component.HasLabel
getLabel, setLabelMethods inherited from interface com.vaadin.flow.data.provider.HasListDataView
setItemsMethods inherited from interface com.vaadin.flow.component.shared.HasOverlayClassName
getOverlayClassName, setOverlayClassNameMethods inherited from interface com.vaadin.flow.component.HasPlaceholder
getPlaceholder, setPlaceholderMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariantsMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipTextMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, isInvalid, setErrorMessage, setInvalidMethods inherited from interface com.vaadin.flow.data.binder.HasValidator
addValidationStatusChangeListenerMethods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, clear, getOptionalValue, isEmptyMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, setReadOnlyMethods inherited from interface com.vaadin.flow.data.selection.MultiSelect
deselect, deselect, getEmptyValue, select, selectMethods inherited from interface com.storedobject.vaadin.RequiredField
setRequired
-
Constructor Details
-
TokensField
public TokensField()Constructor. -
TokensField
-
TokensField
-
TokensField
Constructor.- Parameters:
label- Labelitems- Items
-
TokensField
Constructor.- Parameters:
itemLabelGenerator- Label generator
-
TokensField
-
TokensField
public TokensField(String label, Collection<T> items, com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator) Constructor.- Parameters:
label- Labelitems- ItemsitemLabelGenerator- Label generator
-
-
Method Details
-
valueEquals
-
addValue
-
addItems
Add more items to the selection list.- Parameters:
items- Items to be added
-
addItems
Add more items to the selection list.- Parameters:
items- Items to be added
-
addItems
-
setValue
- Specified by:
setValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.combobox.MultiSelectComboBox<T>,Set<T>>, Set<T>> - Specified by:
setValuein interfacecom.vaadin.flow.data.selection.MultiSelect<com.vaadin.flow.component.combobox.MultiSelectComboBox<T>,T> - Overrides:
setValuein classcom.vaadin.flow.component.combobox.MultiSelectComboBox<T>
-
setValue
Sets the value by converting the provided collection into a set and passing it to thesetValuemethod of the parent class.- Overrides:
setValuein classcom.vaadin.flow.component.combobox.MultiSelectComboBox<T>- Parameters:
value- The collection of elements to set as the value.
-
selectAll
public void selectAll()Select all items. TheMultiSelectComboBox.getValue()will return all the items after invoking this method. -
deselectAll
public void deselectAll()Deselect all items. This is equivalent to setValue(null). TheMultiSelectComboBox.getValue()will return an empty set after invoking this method.
-