com.vaadin.ui
Class Grid.AbstractSelectionModel

java.lang.Object
  extended by com.vaadin.ui.Grid.AbstractSelectionModel
All Implemented Interfaces:
Grid.SelectionModel, java.io.Serializable
Direct Known Subclasses:
Grid.MultiSelectionModel, Grid.SingleSelectionModel
Enclosing class:
Grid

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

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

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Grid.SelectionModel
Grid.SelectionModel.Multi, Grid.SelectionModel.None, Grid.SelectionModel.Single
 
Field Summary
protected  Grid grid
           
protected  java.util.LinkedHashSet<java.lang.Object> selection
           
 
Constructor Summary
Grid.AbstractSelectionModel()
           
 
Method Summary
protected  void checkItemIdExists(java.lang.Object itemId)
          Sanity check for existence of item id.
protected  void checkItemIdsExist(java.util.Collection<?> itemIds)
          Sanity check for existence of item ids in given collection.
protected  void fireSelectionEvent(java.util.Collection<java.lang.Object> oldSelection, java.util.Collection<java.lang.Object> newSelection)
          Fires a SelectionEvent to all the SelectionListeners 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.Grid.SelectionModel
reset
 

Field Detail

selection

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

grid

protected Grid grid
Constructor Detail

Grid.AbstractSelectionModel

public Grid.AbstractSelectionModel()
Method Detail

isSelected

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

Specified by:
isSelected in interface Grid.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: Grid.SelectionModel
Returns a collection of all the currently selected itemIds.

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

setGrid

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

Note: This method should not be called manually.

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

checkItemIdExists

protected void checkItemIdExists(java.lang.Object itemId)
                          throws java.lang.IllegalArgumentException
Sanity check for existence of item id.

Parameters:
itemId - item id to be selected / deselected
Throws:
java.lang.IllegalArgumentException - if item Id doesn't exist in the container of Grid

checkItemIdsExist

protected void checkItemIdsExist(java.util.Collection<?> itemIds)
                          throws java.lang.IllegalArgumentException
Sanity check for existence of item ids in given collection.

Parameters:
itemIds - item id collection to be selected / deselected
Throws:
java.lang.IllegalArgumentException - if at least one item id doesn't exist in the container of Grid

fireSelectionEvent

protected void fireSelectionEvent(java.util.Collection<java.lang.Object> oldSelection,
                                  java.util.Collection<java.lang.Object> newSelection)
Fires a SelectionEvent to all the SelectionListeners 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 Grid.SelectionModel is not a SelectionEvent.SelectionNotifier

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.