T - the type of the selected item in grid.public class SingleSelectionModelImpl<T> extends AbstractSelectionModel<T> implements SingleSelectionModel<T>
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListenerSelectionModel.Multi<T>, SelectionModel.Single<T>| Constructor and Description |
|---|
SingleSelectionModelImpl() |
| Modifier and Type | Method and Description |
|---|---|
Registration |
addSingleSelectionListener(SingleSelectionListener<T> listener)
Adds a single selection listener that is called when the value of this
select is changed either by the user or programmatically.
|
SingleSelect<T> |
asSingleSelect()
Gets a wrapper for using this grid as a single select in a binder.
|
void |
deselect(T item)
Deselects the given item.
|
protected void |
doSetSelectedKey(String key)
Sets the selected item based on the given communication key.
|
Optional<T> |
getSelectedItem()
Returns the currently selected item, or an empty optional if no item
is selected.
|
Set<T> |
getSelectedItems()
Returns an immutable set of the currently selected items.
|
protected String |
getSelectedKey()
Returns the communication key of the selected item or
null if no
item is selected. |
protected SingleSelectionModelState |
getState()
Returns the shared state for this connector.
|
protected SingleSelectionModelState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
protected void |
init()
Initializes the selection model after it has been attached to a grid.
|
boolean |
isDeselectAllowed()
Gets whether it's allowed to deselect the selected row through the
UI.
|
protected boolean |
isKeySelected(String key)
Returns whether the given key maps to the currently selected item.
|
boolean |
isSelected(T item)
Returns whether the given item is currently selected.
|
protected String |
itemToKey(T item)
Returns the communication key assigned to the given item.
|
void |
refreshData(T item)
Informs the
DataGenerator that a data object has been updated. |
void |
select(T item)
Selects the given item.
|
void |
setDeselectAllowed(boolean deselectAllowed)
Sets whether it's allowed to deselect the selected row through the
UI.
|
protected void |
setSelectedFromClient(String key)
Sets the selection based on a client request.
|
protected void |
setSelectedFromServer(T item)
Sets the selection based on server API call.
|
destroyAllData, extend, generateData, getGrid, isUserSelectionAllowed, remove, setUserSelectionAllowedaddComponentToGrid, getInternalIdForColumn, getParent, removeComponentFromGridgetData, refreshextend, getSupportedParentType, setParentaddAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, attach, beforeClientResponse, createState, detach, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isConnectorEnabled, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstateclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitaddSelectionListenerisUserSelectionAllowed, remove, setUserSelectionAllowedaddAttachListener, addDetachListener, attach, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getParent, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIddeselectAll, getFirstSelectedItem, setSelectedItemdestroyDataprotected void init()
AbstractSelectionModelinit in class AbstractSelectionModel<T>protected SingleSelectionModelState getState()
AbstractClientConnector
As a side effect, marks the connector dirty so any changes done to the
state will be sent to the client. Use getState(false) to avoid
marking the connector as dirty.
getState in class AbstractSelectionModel<T>protected SingleSelectionModelState getState(boolean markAsDirty)
AbstractClientConnectorgetState in class AbstractSelectionModel<T>markAsDirty - true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()public Registration addSingleSelectionListener(SingleSelectionListener<T> listener)
SingleSelectionModeladdSingleSelectionListener in interface SingleSelectionModel<T>listener - the value change listener, not nullpublic Optional<T> getSelectedItem()
SelectionModel.SinglegetSelectedItem in interface SelectionModel.Single<T>public void deselect(T item)
SelectionModeldeselect in interface SelectionModel<T>item - the item to deselect, not nullpublic void select(T item)
SelectionModelselect in interface SelectionModel<T>select in interface SelectionModel.Single<T>item - the item to select, not nullprotected boolean isKeySelected(String key)
key - the key to test or null to test whether nothing is
selectedtrue if the key equals the key of the currently selected
item (or null if no selection), false otherwise.protected String getSelectedKey()
null if no
item is selected.null otherwise.protected void doSetSelectedKey(String key)
null, clears the current selection if any.key - the key of the selected item or null to clear
selectionprotected void setSelectedFromClient(String key)
isUserOriginated == true.key - the key of the item to select or null to clear
selectionprotected void setSelectedFromServer(T item)
isUserOriginated == false.item - the item to select or null to clear selectionprotected String itemToKey(T item)
item - the item whose key to returnpublic Set<T> getSelectedItems()
SelectionModelSelectionModel methods while iterating over the set.
Implementation note: the iteration order of the items in the returned set should be well-defined and documented by the implementing class.
getSelectedItems in interface SelectionModel<T>getSelectedItems in interface SelectionModel.Single<T>SelectionModel.Single.getSelectedItem()public void setDeselectAllowed(boolean deselectAllowed)
SelectionModel.SinglesetDeselectAllowed in interface SelectionModel.Single<T>deselectAllowed - true if the selected row can be deselected
without selecting another row instead; otherwise
false.public boolean isDeselectAllowed()
SelectionModel.SingleisDeselectAllowed in interface SelectionModel.Single<T>true if deselection is allowed; otherwise
falsepublic SingleSelect<T> asSingleSelect()
asSingleSelect in interface SingleSelectionModel<T>public void refreshData(T item)
DataGeneratorDataGenerator that a data object has been updated.
This method should update any unneeded information stored for given item.refreshData in interface DataGenerator<T>item - the updated itempublic boolean isSelected(T item)
SelectionModelisSelected in interface SelectionModel<T>item - the item to check, not nulltrue if the item is selected, false otherwiseCopyright © 2017 Vaadin Ltd. All rights reserved.