com.vaadin.client.widget.grid.selection
Class SelectionModelSingle<T>

java.lang.Object
  extended by com.vaadin.client.widget.grid.selection.AbstractRowHandleSelectionModel<T>
      extended by com.vaadin.client.widget.grid.selection.SelectionModelSingle<T>
All Implemented Interfaces:
SelectionModel<T>, SelectionModel.Single<T>

public class SelectionModelSingle<T>
extends AbstractRowHandleSelectionModel<T>
implements SelectionModel.Single<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
SelectionModelSingle()
           
 
Method Summary
 boolean deselect(T row)
          Deselects a row.
protected  boolean deselectByHandle(DataSource.RowHandle<T> handle)
          Deselect a row, based on its RowHandle.
 T getSelectedRow()
          Returns the currently selected row.
 java.util.Collection<T> getSelectedRows()
          Returns a Collection containing all selected rows.
 Renderer<java.lang.Boolean> getSelectionColumnRenderer()
          Return the Renderer 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.
 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 its RowHandle.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectionModelSingle

public SelectionModelSingle()
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 interface SelectionModel<T>
Parameters:
row - row object instance
Returns:
true, if the row given as argument is considered selected.

getSelectionColumnRenderer

public Renderer<java.lang.Boolean> getSelectionColumnRenderer()
Description copied from interface: SelectionModel
Return the Renderer responsible for rendering the selection column.

Specified by:
getSelectionColumnRenderer in interface SelectionModel<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 interface SelectionModel<T>
Parameters:
grid - a Grid 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 interface SelectionModel.Single<T>
Parameters:
row - a Grid 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 interface SelectionModel.Single<T>
Parameters:
row - a Grid 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 interface SelectionModel.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 interface SelectionModel<T>

getSelectedRows

public java.util.Collection<T> getSelectedRows()
Description copied from interface: SelectionModel
Returns a Collection containing all selected rows.

Specified by:
getSelectedRows in interface SelectionModel<T>
Returns:
a non-null collection.

selectByHandle

protected boolean selectByHandle(DataSource.RowHandle<T> handle)
Description copied from class: AbstractRowHandleSelectionModel
Select a row, based on its RowHandle.

Note: this method may not fire selection change events.

Specified by:
selectByHandle in class AbstractRowHandleSelectionModel<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 its RowHandle.

Note: this method may not fire selection change events.

Specified by:
deselectByHandle in class AbstractRowHandleSelectionModel<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 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
Sets 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


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.