Package com.vaadin.flow.component.grid
Class AbstractGridSingleSelectionModel<T>
- java.lang.Object
-
- com.vaadin.flow.component.grid.Grid.AbstractGridExtension<T>
-
- com.vaadin.flow.component.grid.AbstractGridSingleSelectionModel<T>
-
- Type Parameters:
T- the grid type
- All Implemented Interfaces:
GridSelectionModel<T>,GridSingleSelectionModel<T>,DataGenerator<T>,SelectionModel<Grid<T>,T>,SelectionModel.Single<Grid<T>,T>,Serializable
public abstract class AbstractGridSingleSelectionModel<T> extends Grid.AbstractGridExtension<T> implements GridSingleSelectionModel<T>
Abstract implementation of a GridSingleSelectionModel.- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.flow.data.selection.SelectionModel
SelectionModel.Multi<C extends Component,T>, SelectionModel.Single<C extends Component,T>
-
-
Constructor Summary
Constructors Constructor Description AbstractGridSingleSelectionModel(Grid<T> grid)Constructor for passing a reference of the grid to this implementation.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description RegistrationaddSelectionListener(SelectionListener<Grid<T>,T> listener)Adds a generic listener to this selection model, accepting both single and multiselection events.RegistrationaddSingleSelectionListener(SingleSelectionListener<Grid<T>,T> listener)Adds a selection listener that will be called when the selection is changed either by the user or programmatically.SingleSelect<Grid<T>,T>asSingleSelect()Gets a wrapper to use this single selection model as a single select inBinder.voiddeselect(T item)Deselects the given item.voiddeselectFromClient(T item)Handles the deselection of an item that originates from the client.protected abstract voidfireSelectionEvent(SelectionEvent<Grid<T>,T> event)Method for handling the firing of selection events.voidgenerateData(T item, elemental.json.JsonObject jsonObject)Adds custom data for the given item to its serializedJsonObjectrepresentation.Optional<T>getSelectedItem()Returns the currently selected item, or an empty optional if no item is selected.booleanisDeselectAllowed()Gets whether it's allowed to deselect the selected row through the UI.protected voidremove()Remove this extension from its target.voidselect(T item)Selects the given item.voidselectFromClient(T item)Handles the selection of an item that originates from the client.voidsetDeselectAllowed(boolean deselectAllowed)Sets whether it's allowed to deselect the selected row through the UI.-
Methods inherited from class com.vaadin.flow.component.grid.Grid.AbstractGridExtension
extend, getGrid, refresh
-
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.data.provider.DataGenerator
destroyAllData, destroyData, refreshData
-
Methods inherited from interface com.vaadin.flow.data.selection.SelectionModel
isSelected
-
Methods inherited from interface com.vaadin.flow.data.selection.SelectionModel.Single
deselectAll, getFirstSelectedItem, getSelectedItems, setSelectedItem
-
-
-
-
Method Detail
-
selectFromClient
public void selectFromClient(T item)
Description copied from interface:GridSelectionModelHandles the selection of an item that originates from the client.- Specified by:
selectFromClientin interfaceGridSelectionModel<T>- Parameters:
item- the item being selected
-
select
public void select(T item)
Description copied from interface:SelectionModelSelects the given item. Depending on the implementation, may cause other items to be deselected. If the item is already selected, does nothing.- Specified by:
selectin interfaceSelectionModel<Grid<T>,T>- Specified by:
selectin interfaceSelectionModel.Single<Grid<T>,T>- Parameters:
item- the item to select, not null
-
deselectFromClient
public void deselectFromClient(T item)
Description copied from interface:GridSelectionModelHandles the deselection of an item that originates from the client.- Specified by:
deselectFromClientin interfaceGridSelectionModel<T>- Parameters:
item- the item beign deselected
-
deselect
public void deselect(T item)
Description copied from interface:SelectionModelDeselects the given item. If the item is not currently selected, does nothing.- Specified by:
deselectin interfaceSelectionModel<Grid<T>,T>- Parameters:
item- the item to deselect, not null
-
getSelectedItem
public Optional<T> getSelectedItem()
Description copied from interface:SelectionModel.SingleReturns the currently selected item, or an empty optional if no item is selected.- Specified by:
getSelectedItemin interfaceSelectionModel.Single<Grid<T>,T>- Returns:
- an optional of the selected item if any, an empty optional otherwise
-
setDeselectAllowed
public void setDeselectAllowed(boolean deselectAllowed)
Description copied from interface:SelectionModel.SingleSets whether it's allowed to deselect the selected row through the UI. Deselection is allowed by default.- Specified by:
setDeselectAllowedin interfaceSelectionModel.Single<Grid<T>,T>- Parameters:
deselectAllowed-trueif the selected row can be deselected without selecting another row instead; otherwisefalse.
-
isDeselectAllowed
public boolean isDeselectAllowed()
Description copied from interface:SelectionModel.SingleGets whether it's allowed to deselect the selected row through the UI.- Specified by:
isDeselectAllowedin interfaceSelectionModel.Single<Grid<T>,T>- Returns:
trueif deselection is allowed; otherwisefalse
-
asSingleSelect
public SingleSelect<Grid<T>,T> asSingleSelect()
Description copied from interface:GridSingleSelectionModelGets a wrapper to use this single selection model as a single select inBinder.- Specified by:
asSingleSelectin interfaceGridSingleSelectionModel<T>- Returns:
- the single select wrapper
-
addSelectionListener
public Registration addSelectionListener(SelectionListener<Grid<T>,T> listener)
Description copied from interface:SelectionModelAdds a generic listener to this selection model, accepting both single and multiselection events.- Specified by:
addSelectionListenerin interfaceSelectionModel<Grid<T>,T>- Parameters:
listener- the listener to add, notnull- Returns:
- a registration handle for removing the listener
-
addSingleSelectionListener
public Registration addSingleSelectionListener(SingleSelectionListener<Grid<T>,T> listener)
Description copied from interface:GridSingleSelectionModelAdds a selection listener that will be called when the selection is changed either by the user or programmatically.- Specified by:
addSingleSelectionListenerin interfaceGridSingleSelectionModel<T>- Parameters:
listener- the single selection listener, notnull- Returns:
- a registration for the listener
-
generateData
public void generateData(T item, elemental.json.JsonObject jsonObject)
Description copied from interface:DataGeneratorAdds custom data for the given item to its serializedJsonObjectrepresentation. This JSON object will be sent to client-side DataProvider.- Specified by:
generateDatain interfaceDataGenerator<T>- Parameters:
item- the data item being serializedjsonObject- the JSON object being sent to the client
-
remove
protected void remove()
Description copied from class:Grid.AbstractGridExtensionRemove this extension from its target.- Overrides:
removein classGrid.AbstractGridExtension<T>
-
fireSelectionEvent
protected abstract void fireSelectionEvent(SelectionEvent<Grid<T>,T> event)
Method for handling the firing of selection events.- Parameters:
event- the selection event to fire
-
-