com.vaadin.ui
Class Grid.AbstractSelectionModel

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.server.AbstractExtension
          extended by com.vaadin.ui.Grid.AbstractGridExtension
              extended by com.vaadin.ui.Grid.AbstractSelectionModel
All Implemented Interfaces:
MethodEventSource, ClientConnector, DataGenerator, Extension, com.vaadin.shared.Connector, Grid.SelectionModel, java.io.Serializable
Direct Known Subclasses:
Grid.MultiSelectionModel, Grid.NoSelectionModel, Grid.SingleSelectionModel
Enclosing class:
Grid

public abstract static class Grid.AbstractSelectionModel
extends Grid.AbstractGridExtension
implements Grid.SelectionModel, DataGenerator

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
 
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
 
Field Summary
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.
 void destroyData(java.lang.Object itemId)
          Informs the DataGenerator that an item id has been dropped and is no longer needed.
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.
 void generateData(java.lang.Object itemId, Item item, elemental.json.JsonObject rowData)
          Adds data to row object for given item and item id being sent to client.
protected  java.lang.Object getItemId(java.lang.String rowKey)
          Gets the item id for a row key.
 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 com.vaadin.ui.Grid.AbstractGridExtension
addComponentToGrid, extend, getColumn, getParentGrid, refreshRow, remove, removeComponentFromGrid
 
Methods inherited from class com.vaadin.server.AbstractExtension
getParent, getSupportedParentType, setParent
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, attach, beforeClientResponse, createState, detach, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getState, getState, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isConnectorEnabled, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Grid.SelectionModel
reset
 
Methods inherited from interface com.vaadin.server.Extension
remove, setParent
 
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, attach, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getParent, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 

Field Detail

selection

protected final java.util.LinkedHashSet<java.lang.Object> selection
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. This method should usually call the extend method of AbstractExtension.

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

generateData

public void generateData(java.lang.Object itemId,
                         Item item,
                         elemental.json.JsonObject rowData)
Description copied from interface: DataGenerator
Adds data to row object for given item and item id being sent to client.

Specified by:
generateData in interface DataGenerator
Parameters:
itemId - item id of item
item - item being sent to client
rowData - row object being sent to client

destroyData

public void destroyData(java.lang.Object itemId)
Description copied from interface: DataGenerator
Informs the DataGenerator that an item id has been dropped and is no longer needed. This method should clean up any unneeded stored data related to the item.

Specified by:
destroyData in interface DataGenerator
Parameters:
itemId - removed item id

getItemId

protected java.lang.Object getItemId(java.lang.String rowKey)
Description copied from class: Grid.AbstractGridExtension
Gets the item id for a row key.

A key is used to identify a particular row on both a server and a client. This method can be used to get the item id for the row key that the client has sent.

Overrides:
getItemId in class Grid.AbstractGridExtension
Parameters:
rowKey - the row key for which to retrieve an item id
Returns:
the item id corresponding to key


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