Class SelectionModelSingle<T>
- java.lang.Object
-
- com.vaadin.v7.client.widget.grid.selection.AbstractRowHandleSelectionModel<T>
-
- com.vaadin.v7.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.v7.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 booleandeselect(T row)Deselects a row.protected booleandeselectByHandle(DataSource.RowHandle<T> handle)Deselect a row, based on itsRowHandle.TgetSelectedRow()Returns the currently selected row.Collection<T>getSelectedRows()Returns a Collection containing all selected rows.Renderer<Boolean>getSelectionColumnRenderer()Return theRendererresponsible for rendering the selection column.booleanisDeselectAllowed()Sets whether it's allowed to deselect the selected row through the UI.booleanisSelected(T row)Return true if the provided row is considered selected under the implementing selection model.booleanisUserSelectionAllowed()Checks if the user is allowed to change the selection.voidreset()Resets the SelectionModel to the initial state.booleanselect(T row)Selects a row.protected booleanselectByHandle(DataSource.RowHandle<T> handle)Select a row, based on itsRowHandle.voidsetDeselectAllowed(boolean deselectAllowed)Sets whether it's allowed to deselect the selected row through the UI.voidsetGrid(Grid<T> grid)Tells this SelectionModel which Grid it belongs to.voidsetUserSelectionAllowed(boolean userSelectionAllowed)Sets whether the user is allowed to change the selection.
-
-
-
Method Detail
-
isSelected
public boolean isSelected(T row)
Description copied from interface:SelectionModelReturn true if the provided row is considered selected under the implementing selection model.- Specified by:
isSelectedin 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:SelectionModelReturn theRendererresponsible for rendering the selection column.- Specified by:
getSelectionColumnRendererin 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:SelectionModelTells 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:
setGridin interfaceSelectionModel<T>- Parameters:
grid- aGridinstance;nullwhen removing from Grid
-
select
public boolean select(T row)
Description copied from interface:SelectionModel.SingleSelects a row.- Specified by:
selectin interfaceSelectionModel.Single<T>- Parameters:
row- aGridrow object- Returns:
- true, if this row as not previously selected.
-
deselect
public boolean deselect(T row)
Description copied from interface:SelectionModel.SingleDeselects a row.This is a no-op unless
rowis the currently selected row.- Specified by:
deselectin interfaceSelectionModel.Single<T>- Parameters:
row- aGridrow object- Returns:
- true, if the currently selected row was deselected.
-
getSelectedRow
public T getSelectedRow()
Description copied from interface:SelectionModel.SingleReturns the currently selected row.- Specified by:
getSelectedRowin interfaceSelectionModel.Single<T>- Returns:
- a
Gridrow object or null, if nothing is selected.
-
reset
public void reset()
Description copied from interface:SelectionModelResets the SelectionModel to the initial state.This method can be called internally, for example, when the attached Grid's data source changes.
- Specified by:
resetin interfaceSelectionModel<T>
-
getSelectedRows
public Collection<T> getSelectedRows()
Description copied from interface:SelectionModelReturns a Collection containing all selected rows.- Specified by:
getSelectedRowsin interfaceSelectionModel<T>- Returns:
- a non-null collection.
-
selectByHandle
protected boolean selectByHandle(DataSource.RowHandle<T> handle)
Description copied from class:AbstractRowHandleSelectionModelSelect a row, based on itsRowHandle.Note: this method may not fire selection change events.
- Specified by:
selectByHandlein classAbstractRowHandleSelectionModel<T>- Parameters:
handle- the handle to select by- Returns:
trueif the selection state was changed by this call
-
deselectByHandle
protected boolean deselectByHandle(DataSource.RowHandle<T> handle)
Description copied from class:AbstractRowHandleSelectionModelDeselect a row, based on itsRowHandle.Note: this method may not fire selection change events.
- Specified by:
deselectByHandlein classAbstractRowHandleSelectionModel<T>- Parameters:
handle- the handle to deselect by- Returns:
trueif the selection state was changed by this call
-
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<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.SingleSets whether it's allowed to deselect the selected row through the UI.- Specified by:
isDeselectAllowedin interfaceSelectionModel.Single<T>- Returns:
trueif deselection is allowed; otherwisefalse
-
isUserSelectionAllowed
public boolean isUserSelectionAllowed()
Description copied from interface:HasUserSelectionAllowedChecks if the user is allowed to change the selection.- Specified by:
isUserSelectionAllowedin interfaceHasUserSelectionAllowed<T>- Returns:
trueif the user is allowed to change the selection,falseotherwise
-
setUserSelectionAllowed
public void setUserSelectionAllowed(boolean userSelectionAllowed)
Description copied from interface:HasUserSelectionAllowedSets whether the user is allowed to change the selection.- Specified by:
setUserSelectionAllowedin interfaceHasUserSelectionAllowed<T>- Parameters:
userSelectionAllowed-trueif the user is allowed to change the selection,falseotherwise
-
-