Package com.vaadin.ui
Class Grid.AbstractSelectionModel
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.server.AbstractExtension
-
- com.vaadin.ui.Grid.AbstractGridExtension
-
- com.vaadin.ui.Grid.AbstractSelectionModel
-
- All Implemented Interfaces:
MethodEventSource
,ClientConnector
,DataGenerator
,Extension
,Connector
,Grid.SelectionModel
,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.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Grid.SelectionModel
Grid.SelectionModel.HasUserSelectionAllowed, Grid.SelectionModel.Multi, Grid.SelectionModel.None, Grid.SelectionModel.Single
-
-
Field Summary
Fields Modifier and Type Field Description protected LinkedHashSet<Object>
selection
-
Constructor Summary
Constructors Constructor Description AbstractSelectionModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkItemIdExists(Object itemId)
Sanity check for existence of item id.protected void
checkItemIdsExist(Collection<?> itemIds)
Sanity check for existence of item ids in given collection.void
destroyData(Object itemId)
Informs the DataGenerator that an item id has been dropped and is no longer needed.protected void
fireSelectionEvent(Collection<Object> oldSelection, Collection<Object> newSelection)
Fires aSelectionEvent
to all theSelectionListeners
currently added to the Grid in which this SelectionModel is.void
generateData(Object itemId, Item item, JsonObject rowData)
Adds data to row object for given item and item id being sent to client.protected Object
getItemId(String rowKey)
Gets the item id for a row key.Collection<Object>
getSelectedRows()
Returns a collection of all the currently selected itemIds.boolean
isSelected(Object itemId)
Checks whether an item is selected or not.void
setGrid(Grid grid)
Injects the currentGrid
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.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
-
Methods inherited from interface com.vaadin.ui.Grid.SelectionModel
reset
-
-
-
-
Field Detail
-
selection
protected final LinkedHashSet<Object> selection
-
-
Method Detail
-
isSelected
public boolean isSelected(Object itemId)
Description copied from interface:Grid.SelectionModel
Checks whether an item is selected or not.- Specified by:
isSelected
in interfaceGrid.SelectionModel
- Parameters:
itemId
- the item id to check for- Returns:
true
iff the item is selected
-
getSelectedRows
public Collection<Object> getSelectedRows()
Description copied from interface:Grid.SelectionModel
Returns a collection of all the currently selected itemIds.- Specified by:
getSelectedRows
in interfaceGrid.SelectionModel
- Returns:
- a collection of all the currently selected itemIds
-
setGrid
public void setGrid(Grid grid)
Description copied from interface:Grid.SelectionModel
Injects the currentGrid
instance into the SelectionModel. This method should usually call the extend method ofAbstractExtension
.Note: This method should not be called manually.
- Specified by:
setGrid
in interfaceGrid.SelectionModel
- Parameters:
grid
- the Grid in which the SelectionModel currently is, ornull
when a selection model is being detached from a Grid.
-
checkItemIdExists
protected void checkItemIdExists(Object itemId) throws IllegalArgumentException
Sanity check for existence of item id.- Parameters:
itemId
- item id to be selected / deselected- Throws:
IllegalArgumentException
- if item Id doesn't exist in the container of Grid
-
checkItemIdsExist
protected void checkItemIdsExist(Collection<?> itemIds) throws IllegalArgumentException
Sanity check for existence of item ids in given collection.- Parameters:
itemIds
- item id collection to be selected / deselected- Throws:
IllegalArgumentException
- if at least one item id doesn't exist in the container of Grid
-
fireSelectionEvent
protected void fireSelectionEvent(Collection<Object> oldSelection, Collection<Object> newSelection)
Fires aSelectionEvent
to all theSelectionListeners
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 aSelectionEvent.SelectionNotifier
- Parameters:
oldSelection
- the completeCollection
of the itemIds that were selected before this event happenednewSelection
- the completeCollection
of the itemIds that are selected after this event happened
-
generateData
public void generateData(Object itemId, Item item, 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 interfaceDataGenerator
- Parameters:
itemId
- item id of itemitem
- item being sent to clientrowData
- row object being sent to client
-
destroyData
public void destroyData(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 interfaceDataGenerator
- Parameters:
itemId
- removed item id
-
getItemId
protected Object getItemId(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 classGrid.AbstractGridExtension
- Parameters:
rowKey
- the row key for which to retrieve an item id- Returns:
- the item id corresponding to
key
-
-