com.vaadin.ui.components.grid.

Class SingleSelectionModelImpl<T>

    • Constructor Detail

      • SingleSelectionModelImpl

        public SingleSelectionModelImpl()
    • Method Detail

      • getState

        protected SingleSelectionModelState getState()

        Description copied from class: AbstractClientConnector

        Returns the shared state for this connector. The shared state object is shared between the server connector and the client connector. Changes are only communicated from the server to the client and not in the other direction.

        As a side effect, marks the connector dirty so any changes done to the state will be sent to the client. Use getState(false) to avoid marking the connector as dirty.

        Overrides:

        getState in class AbstractSelectionModel<T>

        Returns:

        The shared state for this connector. Never null.

      • getSelectedItem

        public Optional<T> getSelectedItem()

        Description copied from interface: SelectionModel.Single

        Returns the currently selected item, or an empty optional if no item is selected.

        Specified by:

        getSelectedItem in interface SelectionModel.Single<T>

        Returns:

        an optional of the selected item if any, an empty optional otherwise

      • deselect

        public void deselect​(T item)

        Description copied from interface: SelectionModel

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

        Specified by:

        deselect in interface SelectionModel<T>

        Parameters:

        item - the item to deselect, not null

      • select

        public void select​(T item)

        Description copied from interface: SelectionModel

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

        Specified by:

        select in interface SelectionModel<T>

        Specified by:

        select in interface SelectionModel.Single<T>

        Parameters:

        item - the item to select, not null

      • isKeySelected

        protected boolean isKeySelected​(String key)

        Returns whether the given key maps to the currently selected item.

        Parameters:

        key - the key to test or null to test whether nothing is selected

        Returns:

        true if the key equals the key of the currently selected item (or null if no selection), false otherwise.

      • doSetSelected

        protected void doSetSelected​(T item)

        Sets the selected item. If the item is null, clears the current selection if any.

        Parameters:

        item - the selected item or null to clear selection

        Since:

        8.1

      • setSelectedFromClient

        protected void setSelectedFromClient​(String key)

        Sets the selection based on a client request. Does nothing if the select component is HasValue.isReadOnly() or if the selection would not change. Otherwise updates the selection and fires a selection change event with isUserOriginated == true.

        Parameters:

        key - the key of the item to select or null to clear selection

      • setSelectedFromServer

        protected void setSelectedFromServer​(T item)

        Sets the selection based on server API call. Does nothing if the selection would not change; otherwise updates the selection and fires a selection change event with isUserOriginated == false.

        Parameters:

        item - the item to select or null to clear selection

      • setDeselectAllowed

        public void setDeselectAllowed​(boolean deselectAllowed)

        Description copied from interface: SelectionModel.Single

        Sets whether it's allowed to deselect the selected row through the UI. Deselection is allowed by default.

        Specified by:

        setDeselectAllowed in interface SelectionModel.Single<T>

        Parameters:

        deselectAllowed - true if the selected row can be deselected without selecting another row instead; otherwise false.

      • isDeselectAllowed

        public boolean isDeselectAllowed()

        Description copied from interface: SelectionModel.Single

        Gets whether it's allowed to deselect the selected row through the UI.

        Specified by:

        isDeselectAllowed in interface SelectionModel.Single<T>

        Returns:

        true if deselection is allowed; otherwise false

      • refreshData

        public void refreshData​(T item)

        Description copied from interface: DataGenerator

        Informs the DataGenerator that a data object has been updated. This method should update any unneeded information stored for given item.

        Specified by:

        refreshData in interface DataGenerator<T>

        Parameters:

        item - the updated item

      • isSelected

        public boolean isSelected​(T item)

        Description copied from interface: SelectionModel

        Returns whether the given item is currently selected.

        Specified by:

        isSelected in interface SelectionModel<T>

        Parameters:

        item - the item to check, not null

        Returns:

        true if the item is selected, false otherwise