public abstract static class Grid.AbstractSelectionModel extends Grid.AbstractGridExtension implements Grid.SelectionModel, DataGenerator
Grid.SelectionModel.HasUserSelectionAllowed, Grid.SelectionModel.Multi, Grid.SelectionModel.None, Grid.SelectionModel.Single
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Modifier and Type | Field and Description |
---|---|
protected LinkedHashSet<Object> |
selection |
Constructor and Description |
---|
AbstractSelectionModel() |
Modifier and Type | Method and 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 a
SelectionEvent to all the SelectionListeners 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 current
Grid instance into the SelectionModel. |
addComponentToGrid, extend, getColumn, getParentGrid, refreshRow, remove, removeComponentFromGrid
getParent, getSupportedParentType, setParent
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
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
reset
addAttachListener, addDetachListener, attach, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getParent, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
protected final LinkedHashSet<Object> selection
public boolean isSelected(Object itemId)
Grid.SelectionModel
isSelected
in interface Grid.SelectionModel
itemId
- the item id to check fortrue
iff the item is selectedpublic Collection<Object> getSelectedRows()
Grid.SelectionModel
getSelectedRows
in interface Grid.SelectionModel
public void setGrid(Grid grid)
Grid.SelectionModel
Grid
instance into the SelectionModel.
This method should usually call the extend method of
AbstractExtension
.
Note: This method should not be called manually.
setGrid
in interface Grid.SelectionModel
grid
- the Grid in which the SelectionModel currently is, or
null
when a selection model is being detached
from a Grid.protected void checkItemIdExists(Object itemId) throws IllegalArgumentException
itemId
- item id to be selected / deselectedIllegalArgumentException
- if item Id doesn't exist in the container of Gridprotected void checkItemIdsExist(Collection<?> itemIds) throws IllegalArgumentException
itemIds
- item id collection to be selected / deselectedIllegalArgumentException
- if at least one item id doesn't exist in the container of
Gridprotected void fireSelectionEvent(Collection<Object> oldSelection, Collection<Object> newSelection)
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
oldSelection
- the complete Collection
of the itemIds that were
selected before this event happenednewSelection
- the complete Collection
of the itemIds that are
selected after this event happenedpublic void generateData(Object itemId, Item item, JsonObject rowData)
DataGenerator
generateData
in interface DataGenerator
itemId
- item id of itemitem
- item being sent to clientrowData
- row object being sent to clientpublic void destroyData(Object itemId)
DataGenerator
destroyData
in interface DataGenerator
itemId
- removed item idprotected Object getItemId(String rowKey)
Grid.AbstractGridExtension
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.
getItemId
in class Grid.AbstractGridExtension
rowKey
- the row key for which to retrieve an item idkey
Copyright © 2019 Vaadin Ltd. All rights reserved.