Package software.xdev.vaadin.chips
Class ChipComboBox<T>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<C>
com.vaadin.flow.component.AbstractCompositeField<com.vaadin.flow.component.orderedlayout.VerticalLayout,ChipComboBox<T>,Set<T>>
software.xdev.vaadin.chips.ChipComboBox<T>
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<ChipComboBox<T>>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<ChipComboBox<T>>,com.vaadin.flow.component.FocusNotifier<ChipComboBox<T>>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasLabel,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<ChipComboBox<T>,,Set<T>>, Set<T>> com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ChipComboBox<T>,,Set<T>>, Set<T>> com.vaadin.flow.component.shared.HasTooltip,com.vaadin.flow.data.binder.HasItems<T>,com.vaadin.flow.data.binder.HasValidator<T>,Serializable
public class ChipComboBox<T>
extends com.vaadin.flow.component.AbstractCompositeField<com.vaadin.flow.component.orderedlayout.VerticalLayout,ChipComboBox<T>,Set<T>>
implements com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.Focusable<ChipComboBox<T>>, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasValidation, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.HasLabel, com.vaadin.flow.component.shared.HasTooltip, com.vaadin.flow.data.binder.HasItems<T>, com.vaadin.flow.data.binder.HasValidator<T>
This component has a ComboBox with available items and displays the selected items as "chips" underneath it.
It behaves somewhat similar to a
It behaves somewhat similar to a
Select.- See Also:
-
Nested Class Summary
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.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.vaadin.flow.component.button.Buttonprotected com.vaadin.flow.component.combobox.ComboBox<T>protected com.vaadin.flow.component.ItemLabelGenerator<T>protected com.vaadin.flow.component.orderedlayout.FlexLayoutprotected com.vaadin.flow.function.SerializableFunction<T,ChipComponent<T>> protected com.vaadin.flow.component.orderedlayout.HorizontalLayoutprotected final List<ChipComponent<T>> -
Constructor Summary
ConstructorsConstructorDescriptionChipComboBox(String label) ChipComboBox(String label, Set<T> defaultValue) ChipComboBox(Set<T> defaultValue) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidblur()voidfocus()Get all available items, that can potentially get selectedcom.vaadin.flow.component.combobox.ComboBox<T>Returns theComboBoxwhich contains the available items.com.vaadin.flow.component.orderedlayout.FlexLayoutReturns theFlexLayoutwith the select items (asChipComponents).Returns the current supplier for creating newChipComponentscom.vaadin.flow.component.Componentcom.vaadin.flow.component.orderedlayout.HorizontalLayoutReturns theHorizontalLayoutwhich containscbAvailableItems.getLabel()protected voidprotected voidinitUI()booleanbooleanbooleanprotected voidonCbAvailableItemsValueChanged(com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<com.vaadin.flow.component.combobox.ComboBox<T>, T> event) protected voidonClickClearAll(com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.button.Button> event) protected voidremoveItem(T item, boolean isFromClient) voidsetChipItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> generator) Sets the item label generator used by the individualChipComponents.voidsetChipsSupplier(com.vaadin.flow.function.SerializableFunction<T, ChipComponent<T>> chipsSupplier) Sets the supplier for creating newChipComponentsvoidsetClearAllButtonVisible(boolean clearAllButtonVisible) Sets the "Clear All Button" to visible or invisible.voidsetClearAllIcon(com.vaadin.flow.component.Component clearAllIcon) Sets the "Clear All Button" icon.voidsetErrorMessage(String errorMessage) voidsetFullComboBoxWidth(boolean useFullWidth) voidsetInvalid(boolean invalid) voidsetItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> generator) Convenience method, which sets the item label generator used by *BOTH*ComboBoxand theChipComponents.voidsetItems(Collection<T> items) voidvoidsetPlaceholder(String placeholder) protected voidsetPresentationValue(Set<T> newPresentationValue) voidsetReadOnly(boolean readOnly) voidsetRequiredIndicatorVisible(boolean requiredIndicatorVisible) voidprotected voidprotected voidprotected voidprotected voidupdateUI()Updates/Rebuilds the UI from the fieldsprotected voidupdateValues(Set<T> newValues, boolean isFromClient) Updates the underlying values (if the newValues doesn't equals the oldValue)withAllAvailableItems(Collection<T> allAvailableItems) withChipItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> generator) Sets the item label generator used by the individualChipComponents.withChipsSupplier(com.vaadin.flow.function.SerializableFunction<T, ChipComponent<T>> chipsSupplier) withClearAllButtonVisible(boolean clearAllButtonVisible) withClearAllIcon(com.vaadin.flow.component.Component clearAllIcon) withFullComboBoxWidth(boolean useFullWidth) withItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> generator) Convenience method, which sets the item label generator used by *BOTH*ComboBoxand theChipComponents.withPlaceholder(String placeholder) Methods inherited from class com.vaadin.flow.component.AbstractCompositeField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElement, initContentMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, 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, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods 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.data.binder.HasItems
setItems, setItemsMethods 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.HasTooltip
getTooltip, setTooltipTextMethods inherited from interface com.vaadin.flow.component.HasValidation
setManualValidationMethods inherited from interface com.vaadin.flow.data.binder.HasValidator
addValidationStatusChangeListener, getDefaultValidatorMethods inherited from interface com.vaadin.flow.component.HasValue
clear, getOptionalValueMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly
-
Field Details
-
cbAvailableItems
-
btnClearAll
protected com.vaadin.flow.component.button.Button btnClearAll -
comboBoxContainer
protected com.vaadin.flow.component.orderedlayout.HorizontalLayout comboBoxContainer -
chipsContainer
protected com.vaadin.flow.component.orderedlayout.FlexLayout chipsContainer -
chipsSupplier
-
chipItemLabelGenerator
-
allAvailableItems
-
selectedComponents
-
-
Constructor Details
-
ChipComboBox
public ChipComboBox() -
ChipComboBox
-
ChipComboBox
-
ChipComboBox
-
-
Method Details
-
initUI
protected void initUI() -
initListeners
protected void initListeners() -
onCbAvailableItemsValueChanged
-
onClickClearAll
protected void onClickClearAll(com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.button.Button> event) -
setPresentationValue
- Specified by:
setPresentationValuein classcom.vaadin.flow.component.AbstractCompositeField<com.vaadin.flow.component.orderedlayout.VerticalLayout,ChipComboBox<T>, Set<T>>
-
addItem
-
removeItem
-
updateValues
Updates the underlying values (if the newValues doesn't equals the oldValue) -
updateUI
protected void updateUI()Updates/Rebuilds the UI from the fields -
updateSelectedChips
protected void updateSelectedChips() -
updateAvailableItems
protected void updateAvailableItems() -
updateRequiredIndicatorOfCbAvailableItems
protected void updateRequiredIndicatorOfCbAvailableItems() -
setItems
- Specified by:
setItemsin interfacecom.vaadin.flow.data.binder.HasItems<T>
-
getChipsSupplier
Returns the current supplier for creating newChipComponents- Returns:
- the current supplier for creating new
ChipComponents
-
withChipsSupplier
public ChipComboBox<T> withChipsSupplier(com.vaadin.flow.function.SerializableFunction<T, ChipComponent<T>> chipsSupplier) - Returns:
- self
- See Also:
-
setChipsSupplier
public void setChipsSupplier(com.vaadin.flow.function.SerializableFunction<T, ChipComponent<T>> chipsSupplier) Sets the supplier for creating newChipComponents- Parameters:
chipsSupplier- supplier for creating newChipComponents
-
getAllAvailableItems
Get all available items, that can potentially get selected -
withAllAvailableItems
-
getLabel
- Specified by:
getLabelin interfacecom.vaadin.flow.component.HasLabel
-
withLabel
-
setLabel
- Specified by:
setLabelin interfacecom.vaadin.flow.component.HasLabel
-
getPlaceholder
-
withPlaceholder
-
setPlaceholder
-
isClearAllButtonVisible
public boolean isClearAllButtonVisible()- Returns:
- "Clear All Button" visibility. With this button it is possible to clear all selected items with one
click. The default value is
true.
-
withClearAllButtonVisible
- Returns:
- self
- See Also:
-
setClearAllButtonVisible
public void setClearAllButtonVisible(boolean clearAllButtonVisible) Sets the "Clear All Button" to visible or invisible. With this button it is possible to clear all selected items with one click. The default value istrue.- Parameters:
clearAllButtonVisible- defines the visibility of the "Clear All Button".
-
getClearAllIcon
public com.vaadin.flow.component.Component getClearAllIcon()- Returns:
- "Clear All Button" icon. With this button it is possible to clear all selected items with one click. The
default value is
VaadinIcon.TRASH.
-
withClearAllIcon
- Returns:
- self
- See Also:
-
setClearAllIcon
public void setClearAllIcon(com.vaadin.flow.component.Component clearAllIcon) Sets the "Clear All Button" icon. With this button it is possible to clear all selected items with one click. The default value isVaadinIcon.TRASH.- Parameters:
clearAllIcon- the "Clear All Button" icon.
-
withFullComboBoxWidth
-
setFullComboBoxWidth
public void setFullComboBoxWidth(boolean useFullWidth) -
setChipItemLabelGenerator
Sets the item label generator used by the individualChipComponents. -
withChipItemLabelGenerator
public ChipComboBox<T> withChipItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> generator) Sets the item label generator used by the individualChipComponents. Equal to setChipItemLabelGenerator, but allows in-line usage for easier component creation.- Returns:
- this
-
setItemLabelGenerator
Convenience method, which sets the item label generator used by *BOTH*ComboBoxand theChipComponents. -
withItemLabelGenerator
public ChipComboBox<T> withItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> generator) Convenience method, which sets the item label generator used by *BOTH*ComboBoxand theChipComponents. Identical with setItemLabelGenerator, but allows in-line usage for easier component creation.- Returns:
- this
-
setValue
- Specified by:
setValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ChipComboBox<T>,Set<T>>, Set<T>> - Overrides:
setValuein classcom.vaadin.flow.component.AbstractCompositeField<com.vaadin.flow.component.orderedlayout.VerticalLayout,ChipComboBox<T>, Set<T>>
-
setReadOnly
public void setReadOnly(boolean readOnly) - Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ChipComboBox<T>,Set<T>>, Set<T>> - Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ChipComboBox<T>,Set<T>>, Set<T>>
-
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible) - Specified by:
setRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ChipComboBox<T>,Set<T>>, Set<T>> - Specified by:
setRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ChipComboBox<T>,Set<T>>, Set<T>>
-
isRequiredIndicatorVisible
public boolean isRequiredIndicatorVisible()- Specified by:
isRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ChipComboBox<T>,Set<T>>, Set<T>> - Specified by:
isRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<ChipComboBox<T>,Set<T>>, Set<T>>
-
setErrorMessage
- Specified by:
setErrorMessagein interfacecom.vaadin.flow.component.HasValidation
-
getErrorMessage
- Specified by:
getErrorMessagein interfacecom.vaadin.flow.component.HasValidation
-
setInvalid
public void setInvalid(boolean invalid) - Specified by:
setInvalidin interfacecom.vaadin.flow.component.HasValidation
-
isInvalid
public boolean isInvalid()- Specified by:
isInvalidin interfacecom.vaadin.flow.component.HasValidation
-
focus
public void focus()- Specified by:
focusin interfacecom.vaadin.flow.component.Focusable<T>
-
blur
public void blur()- Specified by:
blurin interfacecom.vaadin.flow.component.Focusable<T>
-
getCbAvailableItems
Returns theComboBoxwhich contains the available items. NOTE: If the contents are modified from the outside this component may break -
getComboBoxContainer
public com.vaadin.flow.component.orderedlayout.HorizontalLayout getComboBoxContainer()Returns theHorizontalLayoutwhich containscbAvailableItems. NOTE: If the contents are modified from the outside this component may break -
getChipsContainer
public com.vaadin.flow.component.orderedlayout.FlexLayout getChipsContainer()Returns theFlexLayoutwith the select items (asChipComponents). NOTE: If the contents are modified from the outside this component may break
-