com.vaadin.ui.

Class AbstractMultiSelect<T>

    • Constructor Detail

      • AbstractMultiSelect

        protected AbstractMultiSelect()

        Creates a new multi select with an empty data provider.

    • Method Detail

      • addSelectionListener

        public Registration addSelectionListener​(MultiSelectionListener<T> listener)

        Adds a selection listener that will be called when the selection is changed either by the user or programmatically.

        Specified by:

        addSelectionListener in interface MultiSelect<T>

        Parameters:

        listener - the value change listener, not null

        Returns:

        a registration for the listener

      • setItemEnabledProvider

        protected void setItemEnabledProvider​(SerializablePredicate<T> itemEnabledProvider)

        Sets the item enabled predicate for this multiselect. 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).

        Implementation note: Override this method and getItemEnabledProvider() as public and invoke super methods to support this feature in the multiselect component.

        Parameters:

        itemEnabledProvider - the item enabled provider to set, not null

      • getState

        protected AbstractMultiSelectState getState()

        Description copied from class: AbstractComponent

        Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().

        Overrides:

        getState in class AbstractListing<T>

        Returns:

        updated component shared state

      • setReadOnly

        public void setReadOnly​(boolean readOnly)

        Description copied from class: AbstractComponent

        Sets the read-only status in the state of this AbstractComponent. This method should be made public in Components that implement HasValue.

        Specified by:

        setReadOnly in interface HasValue<T>

        Overrides:

        setReadOnly in class AbstractComponent

        Parameters:

        readOnly - a boolean value specifying whether the component is put read-only mode or not

      • updateSelection

        public void updateSelection​(Set<T> addedItems,
                                    Set<T> removedItems)

        Description copied from interface: MultiSelect

        Updates the selection by adding and removing the given items from it.

        If all the added items were already selected and the removed items were not selected, this is a NO-OP.

        Duplicate items (in both add & remove sets) are ignored and removed from the sets.

        Specified by:

        updateSelection in interface MultiSelect<T>

        Parameters:

        addedItems - the items to add, not null

        removedItems - the items to remove, not null

      • updateSelection

        protected void updateSelection​(Set<T> addedItems,
                                       Set<T> removedItems,
                                       boolean userOriginated)

        Updates the selection by adding and removing the given items.

        Parameters:

        addedItems - the items added to selection, not null

        removedItems - the items removed from selection, not null

        userOriginated - true if this was used originated, false if not

      • getSelectedItems

        public Set<T> getSelectedItems()

        Description copied from interface: MultiSelect

        Returns an immutable set of the currently selected items. It is safe to invoke other SelectionModel methods while iterating over the set.

        Implementation note: the iteration order of the items in the returned set should be well-defined and documented by the implementing class.

        Specified by:

        getSelectedItems in interface MultiSelect<T>

        Returns:

        the items in the current selection, not null

      • deselectAll

        public void deselectAll()

        Description copied from interface: MultiSelect

        Deselects all currently selected items.

        Specified by:

        deselectAll in interface MultiSelect<T>

      • isSelected

        public boolean isSelected​(T item)

        Description copied from interface: MultiSelect

        Returns whether the given item is currently selected.

        Specified by:

        isSelected in interface MultiSelect<T>

        Parameters:

        item - the item to check, not null

        Returns:

        true if the item is selected, false otherwise

      • deselect

        protected void deselect​(T item,
                                boolean userOriginated)

        Deselects the given item. If the item is not currently selected, does nothing.

        Parameters:

        item - the item to deselect, not null

        userOriginated - true if this was used originated, false if not

      • deselect

        protected void deselect​(Set<T> items,
                                boolean userOriginated)

        Removes the given items. Any item that is not currently selected, is ignored. If none of the items are selected, does nothing.

        Parameters:

        items - the items to deselect, not null

        userOriginated - true if this was used originated, false if not

      • select

        protected void select​(T item,
                              boolean userOriginated)

        Selects the given item. Depending on the implementation, may cause other items to be deselected. If the item is already selected, does nothing.

        Parameters:

        item - the item to select, not null

        userOriginated - true if this was used originated, false if not

      • writeItem

        protected org.jsoup.nodes.Element writeItem​(org.jsoup.nodes.Element design,
                                                    T item,
                                                    DesignContext context)

        Description copied from class: AbstractListing

        Writes a data source Item to a design. Hierarchical select components should override this method to recursively write any child items as well.

        Overrides:

        writeItem in class AbstractListing<T>

        Parameters:

        design - the element into which to insert the item

        item - the item to write

        context - the DesignContext instance used in writing

        Returns:

        a JSOUP element representing the item

      • readItems

        protected void readItems​(org.jsoup.nodes.Element design,
                                 DesignContext context)

        Description copied from class: AbstractListing

        Reads the data source items from the design.

        Specified by:

        readItems in class AbstractListing<T>

        Parameters:

        design - The element to obtain the state from

        context - The DesignContext instance used for parsing the design

      • readItem

        protected T readItem​(org.jsoup.nodes.Element child,
                             Set<T> selected,
                             DesignContext context)

        Reads an Item from a design and inserts it into the data source. Hierarchical select components should override this method to recursively recursively read any child items as well.

        Parameters:

        child - a child element representing the item

        selected - A set accumulating selected items. If the item that is read is marked as selected, its item id should be added to this set.

        context - the DesignContext instance used in parsing

        Returns:

        the item id of the new item

        Throws:

        DesignException - if the tag name of the child element is not option.