Class TwinColSelect<T>

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<TwinColSelect<T>,Set<T>>
org.vaadin.tatu.TwinColSelect<T>
Type Parameters:
T - The bean type in TwinColSelect
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, 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<TwinColSelect<T>,Set<T>>,Set<T>>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<TwinColSelect<T>,Set<T>>,Set<T>>, com.vaadin.flow.data.binder.HasItemComponents<T>, com.vaadin.flow.data.provider.HasDataView<T,Void,TwinColSelectDataView<T>>, com.vaadin.flow.data.provider.HasListDataView<T,TwinColSelectListDataView<T>>, com.vaadin.flow.data.selection.MultiSelect<TwinColSelect<T>,T>, Serializable

@Tag("twin-col-select") @CssImport("./twincolselect.css") public class TwinColSelect<T> extends com.vaadin.flow.component.AbstractField<TwinColSelect<T>,Set<T>> implements com.vaadin.flow.data.binder.HasItemComponents<T>, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasValidation, com.vaadin.flow.component.HasTheme, com.vaadin.flow.data.selection.MultiSelect<TwinColSelect<T>,T>, com.vaadin.flow.data.provider.HasListDataView<T,TwinColSelectListDataView<T>>, com.vaadin.flow.data.provider.HasDataView<T,Void,TwinColSelectDataView<T>>
TwinColSelect component, also known as list builder. It is a component for multiselection. This is component consists of two lists. You can move items from the other list to other. The left list is master list and backed by DataProvider. The right list is the selection list and reflects the value of the selection. The component also has drag and drop support.
Author:
Tatu Lund
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The column as LEFT, RIGHT, BOTH
    static enum 
    Defines the filter mode
    static enum 
    Defines the picking mode
    static enum 
     
    static class 
    Class for defining internationalization texts

    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 extends Object>

    Nested classes/interfaces inherited from interface com.vaadin.flow.data.binder.HasItemComponents

    com.vaadin.flow.data.binder.HasItemComponents.ItemComponent<T extends Object>

    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<?>>
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Default constructor
    protected
    TwinColSelect(Set<T> initialValue)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    addSelectionListener(com.vaadin.flow.data.selection.MultiSelectionListener<TwinColSelect<T>,T> listener)
     
    void
    Adds theme variants to the component.
    void
     
    void
    Clear the ticks for specified column(s) without affecting the selection.
    com.vaadin.flow.data.provider.DataProvider<T,?>
    Deprecated.
    com.vaadin.flow.dom.Element
     
     
    Gets the current error message from the twincolselect.
     
    Gets the internationalization object previously set for this component.
    com.vaadin.flow.function.SerializablePredicate<T>
    Returns the item enabled predicate.
    com.vaadin.flow.component.ItemLabelGenerator<T>
    Gets the item label generator that is used to produce the strings shown in the twincolselect for each item.
    Gets the label of the twincolselect.
     
     
    com.vaadin.flow.function.SerializableFunction<T,String>
    Gets the tooltip generator that is used to produce the strings shown in the twincolselect for each item.
    boolean
    Returns if ticks are currently set to be cleared or not.
    protected boolean
     
    boolean
     
    boolean
    Determines whether the twincolselect is marked as input required.
    protected void
    onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
     
    protected void
    onDetach(com.vaadin.flow.component.DetachEvent detachEvent)
     
    void
    Removes theme variants from the component.
    void
     
    void
    setAddButtonIcon(com.vaadin.flow.component.Component icon)
     
    void
     
    void
    setAllButtonIcon(com.vaadin.flow.component.Component icon)
     
    void
     
    void
    setClearButtonIcon(com.vaadin.flow.component.Component icon)
     
    void
    setClearTicks(boolean clearTicksOnSelect)
    Clear the ticks after selection action.
    void
    setDataProvider(com.vaadin.flow.data.provider.DataProvider<T,?> dataProvider)
    Deprecated.
    void
    setErrorMessage(String errorMessage)
     
    void
    Define how data providers filter is applied.
    void
    Sets the internationalization properties (texts used for button tooltips) for this component.
    void
    setInvalid(boolean invalid)
     
    void
    setItemEnabledProvider(com.vaadin.flow.function.SerializablePredicate<T> itemEnabledProvider)
    Sets the item enabled predicate for this twincolselect.
    void
    setItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator)
    Sets the item label generator that is used to produce the strings shown in the twincolselect for each item.
    setItems(com.vaadin.flow.data.provider.DataProvider<T,Void> dataProvider)
     
    setItems(com.vaadin.flow.data.provider.InMemoryDataProvider<T> inMemoryDataProvider)
     
    setItems(com.vaadin.flow.data.provider.ListDataProvider<T> dataProvider)
     
    void
    setItems(Stream<T> streamOfItems)
     
    void
    Set the caption label of the twincolselect
    void
    Set the used PickMode, default is PickMode.DOUBLE.
    protected void
    setPresentationValue(Set<T> newPresentationValue)
     
    void
    setReadOnly(boolean readOnly)
     
    void
     
    void
    setRecycleButtonIcon(com.vaadin.flow.component.Component icon)
     
    void
     
    void
    setRemoveButtonIcon(com.vaadin.flow.component.Component icon)
     
    void
    setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
     
    void
    Define how filters are applied with sorting.
    void
    setTooltipGenerator(com.vaadin.flow.function.SerializableFunction<T,String> tooltipGenerator)
    Sets the tooltip generator that is used to produce the tooltips shown in the twincolselect for each item.
    void
    setValue(Set<T> value)
    Sets the value of this component.
    void
    updateSelection(Set<T> addedItems, Set<T> removedItems)
     
    protected boolean
    valueEquals(Set<T> value1, Set<T> value2)
     

    Methods inherited from class com.vaadin.flow.component.AbstractField

    addValueChangeListener, getValue, isEmpty, setModelValue

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, findAncestor, fireEvent, from, get, getChildren, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasComponents

    add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAll

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    isEnabled, setEnabled

    Methods inherited from interface com.vaadin.flow.data.binder.HasItemComponents

    addComponents, getItemPosition, prependComponents

    Methods inherited from interface com.vaadin.flow.data.provider.HasListDataView

    setItems, setItems

    Methods 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, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.HasTheme

    addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName

    Methods inherited from interface com.vaadin.flow.component.HasValidation

    setManualValidation

    Methods inherited from interface com.vaadin.flow.component.HasValue

    addValueChangeListener, getOptionalValue, isEmpty

    Methods inherited from interface com.vaadin.flow.component.HasValueAndElement

    isReadOnly

    Methods inherited from interface com.vaadin.flow.data.selection.MultiSelect

    deselect, deselect, deselectAll, getValue, isSelected, select, select
  • Constructor Details

    • TwinColSelect

      public TwinColSelect()
      Default constructor
    • TwinColSelect

      protected TwinColSelect(Set<T> initialValue)
  • Method Details

    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • onDetach

      protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent)
      Overrides:
      onDetach in class com.vaadin.flow.component.Component
    • setRequiredIndicatorVisible

      public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
      Specified by:
      setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<TwinColSelect<T>,Set<T>>,Set<T>>
      Specified by:
      setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<TwinColSelect<T>,Set<T>>,Set<T>>
    • isRequiredIndicatorVisible

      public boolean isRequiredIndicatorVisible()
      Determines whether the twincolselect is marked as input required.

      Specified by:
      isRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<TwinColSelect<T>,Set<T>>,Set<T>>
      Specified by:
      isRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<TwinColSelect<T>,Set<T>>,Set<T>>
      Returns:
      true if the input is required, false otherwise
    • setLabel

      public void setLabel(String label)
      Set the caption label of the twincolselect
      Parameters:
      label - The label as String
    • getLabel

      public String getLabel()
      Gets the label of the twincolselect.
      Returns:
      the of the twincolselect
    • setItemLabelGenerator

      public void setItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator)
      Sets the item label generator that is used to produce the strings shown in the twincolselect for each item. By default, String.valueOf(Object) is used.
      Parameters:
      itemLabelGenerator - the item label provider to use, not null
    • setTooltipGenerator

      public void setTooltipGenerator(com.vaadin.flow.function.SerializableFunction<T,String> tooltipGenerator)
      Sets the tooltip generator that is used to produce the tooltips shown in the twincolselect for each item. By default, String.valueOf(Object) is used.
      Parameters:
      tooltipGenerator - the item label provider to use, set null to disable tooltips.
    • setItemEnabledProvider

      public void setItemEnabledProvider(com.vaadin.flow.function.SerializablePredicate<T> itemEnabledProvider)
      Sets the item enabled predicate for this twincolselect. The predicate is applied to each item to determine whether the item should be enabled (true) or disabled (false). Disabled items are displayed as grayed out and the user cannot select them. The default predicate always returns true (all the items are enabled).
      Parameters:
      itemEnabledProvider - the item enable predicate, not null
    • getItemLabelGenerator

      public com.vaadin.flow.component.ItemLabelGenerator<T> getItemLabelGenerator()
      Gets the item label generator that is used to produce the strings shown in the twincolselect for each item.
      Returns:
      the item label generator used, not null
    • getTooltipGenerator

      public com.vaadin.flow.function.SerializableFunction<T,String> getTooltipGenerator()
      Gets the tooltip generator that is used to produce the strings shown in the twincolselect for each item.
      Returns:
      the tooltip generator used
    • getItemEnabledProvider

      public com.vaadin.flow.function.SerializablePredicate<T> getItemEnabledProvider()
      Returns the item enabled predicate.
      Returns:
      the item enabled predicate
      See Also:
    • isDisabledBoolean

      protected boolean isDisabledBoolean()
    • getEmptyValue

      public Set<T> getEmptyValue()
      Specified by:
      getEmptyValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<TwinColSelect<T>,Set<T>>,Set<T>>
      Specified by:
      getEmptyValue in interface com.vaadin.flow.data.selection.MultiSelect<TwinColSelect<T>,T>
      Overrides:
      getEmptyValue in class com.vaadin.flow.component.AbstractField<TwinColSelect<T>,Set<T>>
    • getElement

      public com.vaadin.flow.dom.Element getElement()
      Specified by:
      getElement in interface com.vaadin.flow.component.HasElement
      Overrides:
      getElement in class com.vaadin.flow.component.Component
    • setInvalid

      public void setInvalid(boolean invalid)
      Specified by:
      setInvalid in interface com.vaadin.flow.component.HasValidation
    • clear

      public void clear()
      Specified by:
      clear in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<TwinColSelect<T>,Set<T>>,Set<T>>
    • clearTicks

      public void clearTicks(TwinColSelect.ColType column)
      Clear the ticks for specified column(s) without affecting the selection.
      Parameters:
      column - The column(s) from which to clear the ticks
    • setClearTicks

      public void setClearTicks(boolean clearTicksOnSelect)
      Clear the ticks after selection action. Default is false.
      Parameters:
      clearTicksOnSelect - A boolean value
    • isClearTicksOnSelect

      public boolean isClearTicksOnSelect()
      Returns if ticks are currently set to be cleared or not.
      Returns:
      A boolean value
    • setValue

      public void setValue(Set<T> value)
      Sets the value of this component. If the new value is not equal to the previous value, fires a value change event.

      The component doesn't accept null values. The value of a checkbox group without any selected items is an empty set. You can use the clear() method to set the empty value.

      Specified by:
      setValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<TwinColSelect<T>,Set<T>>,Set<T>>
      Specified by:
      setValue in interface com.vaadin.flow.data.selection.MultiSelect<TwinColSelect<T>,T>
      Overrides:
      setValue in class com.vaadin.flow.component.AbstractField<TwinColSelect<T>,Set<T>>
      Parameters:
      value - the new value to set, not null
      Throws:
      NullPointerException - if value is null
    • isInvalid

      public boolean isInvalid()
      Specified by:
      isInvalid in interface com.vaadin.flow.component.HasValidation
    • setDataProvider

      @Deprecated public void setDataProvider(com.vaadin.flow.data.provider.DataProvider<T,?> dataProvider)
      Deprecated.
    • addThemeVariants

      public void addThemeVariants(TwinColSelectVariant... variants)
      Adds theme variants to the component.
      Parameters:
      variants - theme variants to add
    • removeThemeVariants

      public void removeThemeVariants(TwinColSelectVariant... variants)
      Removes theme variants from the component.
      Parameters:
      variants - theme variants to remove
    • getSelectedItems

      public Set<T> getSelectedItems()
      Specified by:
      getSelectedItems in interface com.vaadin.flow.data.selection.MultiSelect<TwinColSelect<T>,T>
    • updateSelection

      public void updateSelection(Set<T> addedItems, Set<T> removedItems)
      Specified by:
      updateSelection in interface com.vaadin.flow.data.selection.MultiSelect<TwinColSelect<T>,T>
    • setErrorMessage

      public void setErrorMessage(String errorMessage)
      Specified by:
      setErrorMessage in interface com.vaadin.flow.component.HasValidation
    • getErrorMessage

      public String getErrorMessage()
      Gets the current error message from the twincolselect.
      Specified by:
      getErrorMessage in interface com.vaadin.flow.component.HasValidation
      Returns:
      the current error message
    • addSelectionListener

      public com.vaadin.flow.shared.Registration addSelectionListener(com.vaadin.flow.data.selection.MultiSelectionListener<TwinColSelect<T>,T> listener)
      Specified by:
      addSelectionListener in interface com.vaadin.flow.data.selection.MultiSelect<TwinColSelect<T>,T>
    • setPresentationValue

      protected void setPresentationValue(Set<T> newPresentationValue)
      Specified by:
      setPresentationValue in class com.vaadin.flow.component.AbstractField<TwinColSelect<T>,Set<T>>
    • getDataProvider

      @Deprecated public com.vaadin.flow.data.provider.DataProvider<T,?> getDataProvider()
      Deprecated.
    • setReadOnly

      public void setReadOnly(boolean readOnly)
      Specified by:
      setReadOnly in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<TwinColSelect<T>,Set<T>>,Set<T>>
      Specified by:
      setReadOnly in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<TwinColSelect<T>,Set<T>>,Set<T>>
    • setFilterMode

      public void setFilterMode(TwinColSelect.FilterMode filterMode)
      Define how data providers filter is applied.
      Parameters:
      filterMode - FilterMode
    • setSortMode

      public void setSortMode(TwinColSelect.SortMode sortMode)
      Define how filters are applied with sorting.

      Note: This is for performance optimization when also filtering is applied.

      Parameters:
      sortMode - SortMode
    • setAllButtonCaption

      public void setAllButtonCaption(String text)
    • setAllButtonIcon

      public void setAllButtonIcon(com.vaadin.flow.component.Component icon)
    • setClearButtonCaption

      public void setClearButtonCaption(String text)
    • setClearButtonIcon

      public void setClearButtonIcon(com.vaadin.flow.component.Component icon)
    • setRecycleButtonCaption

      public void setRecycleButtonCaption(String text)
    • setRecycleButtonIcon

      public void setRecycleButtonIcon(com.vaadin.flow.component.Component icon)
    • setRemoveButtonCaption

      public void setRemoveButtonCaption(String text)
    • setRemoveButtonIcon

      public void setRemoveButtonIcon(com.vaadin.flow.component.Component icon)
    • setAddButtonCaption

      public void setAddButtonCaption(String text)
    • setAddButtonIcon

      public void setAddButtonIcon(com.vaadin.flow.component.Component icon)
    • getGenericDataView

      public TwinColSelectDataView<T> getGenericDataView()
      Specified by:
      getGenericDataView in interface com.vaadin.flow.data.provider.HasDataView<T,Void,TwinColSelectDataView<T>>
    • setItems

      public TwinColSelectDataView<T> setItems(com.vaadin.flow.data.provider.DataProvider<T,Void> dataProvider)
      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasDataView<T,Void,TwinColSelectDataView<T>>
    • setItems

      public TwinColSelectDataView<T> setItems(com.vaadin.flow.data.provider.InMemoryDataProvider<T> inMemoryDataProvider)
      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasDataView<T,Void,TwinColSelectDataView<T>>
    • getListDataView

      public TwinColSelectListDataView<T> getListDataView()
      Specified by:
      getListDataView in interface com.vaadin.flow.data.provider.HasListDataView<T,TwinColSelectListDataView<T>>
    • setItems

      public TwinColSelectListDataView<T> setItems(com.vaadin.flow.data.provider.ListDataProvider<T> dataProvider)
      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasListDataView<T,TwinColSelectListDataView<T>>
    • setItems

      public void setItems(Stream<T> streamOfItems)
    • valueEquals

      protected boolean valueEquals(Set<T> value1, Set<T> value2)
      Overrides:
      valueEquals in class com.vaadin.flow.component.AbstractField<TwinColSelect<T>,Set<T>>
    • setPickMode

      public void setPickMode(TwinColSelect.PickMode pickMode)
      Set the used PickMode, default is PickMode.DOUBLE.
      Parameters:
      pickMode - The PickMode.
    • setI18n

      public void setI18n(TwinColSelect.TwinColSelectI18n i18n)
      Sets the internationalization properties (texts used for button tooltips) for this component.
      Parameters:
      i18n - the internationalized properties, null to disable all tooltips.
    • getI18n

      Gets the internationalization object previously set for this component.
      Returns:
      the i18n object. It will be null, If the i18n properties weren't set.