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 voidcheckItemIdExists(Object itemId)Sanity check for existence of item id.protected voidcheckItemIdsExist(Collection<?> itemIds)Sanity check for existence of item ids in given collection.voiddestroyData(Object itemId)Informs the DataGenerator that an item id has been dropped and is no longer needed.protected voidfireSelectionEvent(Collection<Object> oldSelection, Collection<Object> newSelection)Fires aSelectionEventto all theSelectionListenerscurrently added to the Grid in which this SelectionModel is.voidgenerateData(Object itemId, Item item, elemental.json.JsonObject rowData)Adds data to row object for given item and item id being sent to client.protected ObjectgetItemId(String rowKey)Gets the item id for a row key.Collection<Object>getSelectedRows()Returns a collection of all the currently selected itemIds.booleanisSelected(Object itemId)Checks whether an item is selected or not.voidsetGrid(Grid grid)Injects the currentGridinstance 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.SelectionModelChecks whether an item is selected or not.- Specified by:
isSelectedin interfaceGrid.SelectionModel- Parameters:
itemId- the item id to check for- Returns:
trueiff the item is selected
-
getSelectedRows
public Collection<Object> getSelectedRows()
Description copied from interface:Grid.SelectionModelReturns a collection of all the currently selected itemIds.- Specified by:
getSelectedRowsin interfaceGrid.SelectionModel- Returns:
- a collection of all the currently selected itemIds
-
setGrid
public void setGrid(Grid grid)
Description copied from interface:Grid.SelectionModelInjects the currentGridinstance into the SelectionModel. This method should usually call the extend method ofAbstractExtension.Note: This method should not be called manually.
- Specified by:
setGridin interfaceGrid.SelectionModel- Parameters:
grid- the Grid in which the SelectionModel currently is, ornullwhen 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 aSelectionEventto all theSelectionListenerscurrently 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.SelectionModelis not aSelectionEvent.SelectionNotifier- Parameters:
oldSelection- the completeCollectionof the itemIds that were selected before this event happenednewSelection- the completeCollectionof the itemIds that are selected after this event happened
-
generateData
public void generateData(Object itemId, Item item, elemental.json.JsonObject rowData)
Description copied from interface:DataGeneratorAdds data to row object for given item and item id being sent to client.- Specified by:
generateDatain 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:DataGeneratorInforms 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:
destroyDatain interfaceDataGenerator- Parameters:
itemId- removed item id
-
getItemId
protected Object getItemId(String rowKey)
Description copied from class:Grid.AbstractGridExtensionGets 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:
getItemIdin classGrid.AbstractGridExtension- Parameters:
rowKey- the row key for which to retrieve an item id- Returns:
- the item id corresponding to
key
-
-