Class SelectionModelMulti<T>
- java.lang.Object
-
- com.vaadin.client.widget.grid.selection.AbstractRowHandleSelectionModel<T>
-
- com.vaadin.client.widget.grid.selection.SelectionModelMulti<T>
-
- All Implemented Interfaces:
HasUserSelectionAllowed<T>
,SelectionModel<T>
,SelectionModel.Multi<T>
,SelectionModel.Multi.Batched<T>
public class SelectionModelMulti<T> extends AbstractRowHandleSelectionModel<T> implements SelectionModel.Multi.Batched<T>, HasUserSelectionAllowed<T>
Multi-row selection model.- Since:
- 7.4
- Author:
- Vaadin Ltd
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.client.widget.grid.selection.SelectionModel
SelectionModel.Multi<T>, SelectionModel.None<T>, SelectionModel.Single<T>
-
Nested classes/interfaces inherited from interface com.vaadin.client.widget.grid.selection.SelectionModel.Multi
SelectionModel.Multi.Batched<T>
-
-
Constructor Summary
Constructors Constructor Description SelectionModelMulti()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
commitBatchSelect()
Commits and ends a batch selection.boolean
deselect(Collection<T> rows)
Deselect all rows in aCollection
.boolean
deselect(T... rows)
Deselects one or more rows.boolean
deselectAll()
De-selects all rows.protected boolean
deselectByHandle(DataSource.RowHandle<T> handle)
Deselect a row, based on itsRowHandle
.Collection<T>
getDeselectedRowsBatch()
Gets all the rows that would become deselected in this batch.Collection<T>
getSelectedRows()
Returns a Collection containing all selected rows.Collection<T>
getSelectedRowsBatch()
Gets all the rows that would become selected in this batch.Renderer<Boolean>
getSelectionColumnRenderer()
Return theRenderer
responsible for rendering the selection column.boolean
isBeingBatchSelected()
Checks whether or not a batch has been started.boolean
isSelected(T row)
Return true if the provided row is considered selected under the implementing selection model.protected boolean
isSelectedByHandle(DataSource.RowHandle<T> handle)
boolean
isUserSelectionAllowed()
Checks if the user is allowed to change the selection.void
reset()
Resets the SelectionModel to the initial state.boolean
select(Collection<T> rows)
Select all rows in aCollection
.boolean
select(T... rows)
Selects one or more rows.protected boolean
selectByHandle(DataSource.RowHandle<T> handle)
Select a row, based on itsRowHandle
.void
setGrid(Grid<T> grid)
Tells this SelectionModel which Grid it belongs to.void
setUserSelectionAllowed(boolean userSelectionAllowed)
Sets whether the user is allowed to change the selection.void
startBatchSelect()
Starts a batch selection.
-
-
-
Method Detail
-
isSelected
public boolean isSelected(T row)
Description copied from interface:SelectionModel
Return true if the provided row is considered selected under the implementing selection model.- Specified by:
isSelected
in interfaceSelectionModel<T>
- Parameters:
row
- row object instance- Returns:
true
, if the row given as argument is considered selected.
-
getSelectionColumnRenderer
public Renderer<Boolean> getSelectionColumnRenderer()
Description copied from interface:SelectionModel
Return theRenderer
responsible for rendering the selection column.- Specified by:
getSelectionColumnRenderer
in interfaceSelectionModel<T>
- Returns:
- a renderer instance. If null is returned, a selection column will not be drawn.
-
setGrid
public void setGrid(Grid<T> grid)
Description copied from interface:SelectionModel
Tells this SelectionModel which Grid it belongs to.Implementations are free to have this be a no-op. This method is called internally by Grid.
- Specified by:
setGrid
in interfaceSelectionModel<T>
- Parameters:
grid
- aGrid
instance;null
when removing from Grid
-
select
public boolean select(T... rows)
Description copied from interface:SelectionModel.Multi
Selects one or more rows.- Specified by:
select
in interfaceSelectionModel.Multi<T>
- Parameters:
rows
-Grid
row objects- Returns:
- true, if the set of selected rows was changed.
-
deselect
public boolean deselect(T... rows)
Description copied from interface:SelectionModel.Multi
Deselects one or more rows.- Specified by:
deselect
in interfaceSelectionModel.Multi<T>
- Parameters:
rows
- Grid row objects- Returns:
- true, if the set of selected rows was changed.
-
deselectAll
public boolean deselectAll()
Description copied from interface:SelectionModel.Multi
De-selects all rows.- Specified by:
deselectAll
in interfaceSelectionModel.Multi<T>
- Returns:
- true, if any row was previously selected.
-
select
public boolean select(Collection<T> rows)
Description copied from interface:SelectionModel.Multi
Select all rows in aCollection
.- Specified by:
select
in interfaceSelectionModel.Multi<T>
- Parameters:
rows
- a collection of Grid row objects- Returns:
- true, if the set of selected rows was changed.
-
deselect
public boolean deselect(Collection<T> rows)
Description copied from interface:SelectionModel.Multi
Deselect all rows in aCollection
.- Specified by:
deselect
in interfaceSelectionModel.Multi<T>
- Parameters:
rows
- a collection of Grid row objects- Returns:
- true, if the set of selected rows was changed.
-
isSelectedByHandle
protected boolean isSelectedByHandle(DataSource.RowHandle<T> handle)
-
selectByHandle
protected boolean selectByHandle(DataSource.RowHandle<T> handle)
Description copied from class:AbstractRowHandleSelectionModel
Select a row, based on itsRowHandle
.Note: this method may not fire selection change events.
- Specified by:
selectByHandle
in classAbstractRowHandleSelectionModel<T>
- Parameters:
handle
- the handle to select by- Returns:
true
iff the selection state was changed by this call
-
deselectByHandle
protected boolean deselectByHandle(DataSource.RowHandle<T> handle)
Description copied from class:AbstractRowHandleSelectionModel
Deselect a row, based on itsRowHandle
.Note: this method may not fire selection change events.
- Specified by:
deselectByHandle
in classAbstractRowHandleSelectionModel<T>
- Parameters:
handle
- the handle to deselect by- Returns:
true
iff the selection state was changed by this call
-
getSelectedRows
public Collection<T> getSelectedRows()
Description copied from interface:SelectionModel
Returns a Collection containing all selected rows.- Specified by:
getSelectedRows
in interfaceSelectionModel<T>
- Returns:
- a non-null collection.
-
reset
public void reset()
Description copied from interface:SelectionModel
Resets the SelectionModel to the initial state.This method can be called internally, for example, when the attached Grid's data source changes.
- Specified by:
reset
in interfaceSelectionModel<T>
-
startBatchSelect
public void startBatchSelect()
Description copied from interface:SelectionModel.Multi.Batched
Starts a batch selection.Any commands to any select or deselect method will be batched into one, and a final selection event will be fired when
SelectionModel.Multi.Batched.commitBatchSelect()
is called.Note:
SelectionChangeEvents
will still be fired for each selection/deselection. You should check whether the event is a part of a batch or not withSelectionEvent.isBatchedSelection()
.- Specified by:
startBatchSelect
in interfaceSelectionModel.Multi.Batched<T>
-
commitBatchSelect
public void commitBatchSelect()
Description copied from interface:SelectionModel.Multi.Batched
Commits and ends a batch selection.Any and all selections and deselections since the last invocation of
SelectionModel.Multi.Batched.startBatchSelect()
will be fired at once as one collatedSelectionEvent
.- Specified by:
commitBatchSelect
in interfaceSelectionModel.Multi.Batched<T>
-
isBeingBatchSelected
public boolean isBeingBatchSelected()
Description copied from interface:SelectionModel.Multi.Batched
Checks whether or not a batch has been started.- Specified by:
isBeingBatchSelected
in interfaceSelectionModel.Multi.Batched<T>
- Returns:
true
iff a batch has been started
-
getSelectedRowsBatch
public Collection<T> getSelectedRowsBatch()
Description copied from interface:SelectionModel.Multi.Batched
Gets all the rows that would become selected in this batch.- Specified by:
getSelectedRowsBatch
in interfaceSelectionModel.Multi.Batched<T>
- Returns:
- a collection of the rows that would become selected
-
getDeselectedRowsBatch
public Collection<T> getDeselectedRowsBatch()
Description copied from interface:SelectionModel.Multi.Batched
Gets all the rows that would become deselected in this batch.- Specified by:
getDeselectedRowsBatch
in interfaceSelectionModel.Multi.Batched<T>
- Returns:
- a collection of the rows that would become deselected
-
isUserSelectionAllowed
public boolean isUserSelectionAllowed()
Description copied from interface:HasUserSelectionAllowed
Checks if the user is allowed to change the selection.- Specified by:
isUserSelectionAllowed
in interfaceHasUserSelectionAllowed<T>
- Returns:
true
if the user is allowed to change the selection,false
otherwise
-
setUserSelectionAllowed
public void setUserSelectionAllowed(boolean userSelectionAllowed)
Description copied from interface:HasUserSelectionAllowed
Sets whether the user is allowed to change the selection.- Specified by:
setUserSelectionAllowed
in interfaceHasUserSelectionAllowed<T>
- Parameters:
userSelectionAllowed
-true
if the user is allowed to change the selection,false
otherwise
-
-