com.vaadin.ui.components.grid.selection
Class AbstractSelectionModel

java.lang.Object
  extended by com.vaadin.ui.components.grid.selection.AbstractSelectionModel
All Implemented Interfaces:
SelectionModel, java.io.Serializable
Direct Known Subclasses:
MultiSelectionModel, SingleSelectionModel

public abstract class AbstractSelectionModel
extends java.lang.Object
implements SelectionModel

A base class for SelectionModels that contains some of the logic that is reusable.

Since:
Author:
Vaadin Ltd
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.ui.components.grid.selection.SelectionModel
SelectionModel.Multi, SelectionModel.None, SelectionModel.Single
 
Field Summary
protected  Grid grid
           
protected  java.util.LinkedHashSet<java.lang.Object> selection
           
 
Constructor Summary
AbstractSelectionModel()
           
 
Method Summary
protected  void fireSelectionChangeEvent(java.util.Collection<java.lang.Object> oldSelection, java.util.Collection<java.lang.Object> newSelection)
          Fires a SelectionChangeEvent to all the SelectionChangeListeners currently added to the Grid in which this SelectionModel is.
 java.util.Collection<java.lang.Object> getSelectedRows()
          Returns a collection of all the currently selected itemIds.
 boolean isSelected(java.lang.Object itemId)
          Checks whether an item is selected or not.
 void setGrid(Grid grid)
          Injects the current Grid instance into the SelectionModel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.components.grid.selection.SelectionModel
reset
 

Field Detail

selection

protected final java.util.LinkedHashSet<java.lang.Object> selection

grid

protected Grid grid
Constructor Detail

AbstractSelectionModel

public AbstractSelectionModel()
Method Detail

isSelected

public boolean isSelected(java.lang.Object itemId)
Description copied from interface: SelectionModel
Checks whether an item is selected or not.

Specified by:
isSelected in interface SelectionModel
Parameters:
itemId - the item id to check for
Returns:
true iff the item is selected

getSelectedRows

public java.util.Collection<java.lang.Object> getSelectedRows()
Description copied from interface: SelectionModel
Returns a collection of all the currently selected itemIds.

Specified by:
getSelectedRows in interface SelectionModel
Returns:
a collection of all the currently selected itemIds

setGrid

public void setGrid(Grid grid)
Description copied from interface: SelectionModel
Injects the current Grid instance into the SelectionModel.

Note: This method should not be called manually.

Specified by:
setGrid in interface SelectionModel
Parameters:
grid - the Grid in which the SelectionModel currently is, or null when a selection model is being detached from a Grid.

fireSelectionChangeEvent

protected void fireSelectionChangeEvent(java.util.Collection<java.lang.Object> oldSelection,
                                        java.util.Collection<java.lang.Object> newSelection)
Fires a SelectionChangeEvent to all the SelectionChangeListeners currently added to the Grid in which this SelectionModel is.

Note that this is only a helper method, and routes the call all the way to Grid. A SelectionModel is not a SelectionChangeNotifier

Parameters:
oldSelection - the complete Collection of the itemIds that were selected before this event happened
newSelection - the complete Collection of the itemIds that are selected after this event happened


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