Class SelectionModelSingle<T>
- java.lang.Object
-
- com.vaadin.client.widget.grid.selection.AbstractRowHandleSelectionModel<T>
-
- com.vaadin.client.widget.grid.selection.SelectionModelSingle<T>
-
- All Implemented Interfaces:
HasUserSelectionAllowed<T>
,SelectionModel<T>
,SelectionModel.Single<T>
public class SelectionModelSingle<T> extends AbstractRowHandleSelectionModel<T> implements SelectionModel.Single<T>, HasUserSelectionAllowed<T>
Single-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>
-
-
Constructor Summary
Constructors Constructor Description SelectionModelSingle()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
deselect(T row)
Deselects a row.protected boolean
deselectByHandle(DataSource.RowHandle<T> handle)
Deselect a row, based on itsRowHandle
.T
getSelectedRow()
Returns the currently selected row.Collection<T>
getSelectedRows()
Returns a Collection containing all selected rows.Renderer<Boolean>
getSelectionColumnRenderer()
Return theRenderer
responsible for rendering the selection column.boolean
isDeselectAllowed()
Sets whether it's allowed to deselect the selected row through the UI.boolean
isSelected(T row)
Return true if the provided row is considered selected under the implementing selection model.boolean
isUserSelectionAllowed()
Checks if the user is allowed to change the selection.void
reset()
Resets the SelectionModel to the initial state.boolean
select(T row)
Selects a row.protected boolean
selectByHandle(DataSource.RowHandle<T> handle)
Select a row, based on itsRowHandle
.void
setDeselectAllowed(boolean deselectAllowed)
Sets whether it's allowed to deselect the selected row through the UI.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.
-
-
-
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 row)
Description copied from interface:SelectionModel.Single
Selects a row.- Specified by:
select
in interfaceSelectionModel.Single<T>
- Parameters:
row
- aGrid
row object- Returns:
- true, if this row as not previously selected.
-
deselect
public boolean deselect(T row)
Description copied from interface:SelectionModel.Single
Deselects a row.This is a no-op unless
row
is the currently selected row.- Specified by:
deselect
in interfaceSelectionModel.Single<T>
- Parameters:
row
- aGrid
row object- Returns:
- true, if the currently selected row was deselected.
-
getSelectedRow
public T getSelectedRow()
Description copied from interface:SelectionModel.Single
Returns the currently selected row.- Specified by:
getSelectedRow
in interfaceSelectionModel.Single<T>
- Returns:
- a
Grid
row object or null, if nothing is selected.
-
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>
-
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.
-
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
-
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 interfaceSelectionModel.Single<T>
- Parameters:
deselectAllowed
-true
if the selected row can be deselected without selecting another row instead; otherwisefalse
.
-
isDeselectAllowed
public boolean isDeselectAllowed()
Description copied from interface:SelectionModel.Single
Sets whether it's allowed to deselect the selected row through the UI.- Specified by:
isDeselectAllowed
in interfaceSelectionModel.Single<T>
- Returns:
true
if deselection is allowed; otherwisefalse
-
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
-
-