T - the item date typepublic abstract class AbstractSingleSelect<T> extends AbstractListing<T> implements SingleSelect<T>
SelectionModel.Single,
Serialized FormAbstractListing.AbstractListingExtension<T>HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<V>Component.ErrorEvent, Component.Event, Component.Focusable, Component.ListenerClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListenerSizeable.UnitDESIGN_ATTR_PLAIN_TEXTSIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSingleSelect()
Creates a new
AbstractListing with a default data communicator. |
protected |
AbstractSingleSelect(DataCommunicator<T> dataCommunicator)
Creates a new
AbstractSingleSelect with the given custom data
communicator. |
| Modifier and Type | Method and Description |
|---|---|
Registration |
addSelectionListener(SingleSelectionListener<T> listener)
Adds a selection listener to this select.
|
Registration |
addValueChangeListener(HasValue.ValueChangeListener<T> listener)
Adds a value change listener.
|
protected void |
doSetSelectedKey(String key)
Sets the selected item based on the given communication key.
|
protected Collection<String> |
getCustomAttributes()
Returns a collection of attributes that should not be handled by the
basic implementation of the
AbstractComponent.readDesign(Element, DesignContext)
and AbstractComponent.writeDesign(Element, DesignContext) methods. |
Optional<T> |
getSelectedItem()
Returns the currently selected item, or an empty optional if no item is
selected.
|
protected String |
getSelectedKey()
Returns the communication key of the selected item or
null if no
item is selected. |
protected AbstractSingleSelectState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
protected AbstractSingleSelectState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
T |
getValue()
Returns the current value of this object which is the currently selected
item.
|
protected boolean |
isKeySelected(String key)
Returns whether the given key maps to the currently selected item.
|
boolean |
isReadOnly()
Returns the read-only status from the state of this
AbstractComponent. |
boolean |
isRequiredIndicatorVisible()
Checks whether the required indicator is visible or not.
|
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.
|
protected T |
keyToItem(String key)
Returns the item that the given key is assigned to, or
null if
there is no such item. |
protected T |
readItem(org.jsoup.nodes.Element child,
Set<T> selected,
DesignContext context)
Reads an Item from a design and inserts it into the data source.
|
protected void |
readItems(org.jsoup.nodes.Element design,
DesignContext context)
Reads the data source items from the
design. |
void |
setReadOnly(boolean readOnly)
Sets the read-only status in the state of this
AbstractComponent. |
void |
setRequiredIndicatorVisible(boolean visible)
Sets the visibility of the required indicator.
|
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.
|
void |
setSelectedItem(T item)
Sets the current selection to the given item or clears selection if given
null. |
void |
setValue(T value)
Sets the value of this object which is an item to select.
|
protected org.jsoup.nodes.Element |
writeItem(org.jsoup.nodes.Element design,
T item,
DesignContext context)
Writes a data source Item to a design.
|
addDataGenerator, deserializeDeclarativeRepresentation, doReadDesign, doWriteDesign, focus, getDataCommunicator, getItemCaptionGenerator, getItemIconGenerator, getTabIndex, internalGetDataProvider, internalSetDataProvider, internalSetDataProvider, readDesign, readItem, removeDataGenerator, serializeDeclarativeRepresentation, setItemCaptionGenerator, setItemIconGenerator, setTabIndex, writeDesign, writeItemsaddContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidth, setWidthUndefinedaddAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, 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, waitclear, getEmptyValue, getOptionalValue, isEmptygetDataProvider, setItems, setItems, setItemsaddListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setVisibleaddAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdgetHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefinedprotected AbstractSingleSelect()
AbstractListing with a default data communicator.
protected AbstractSingleSelect(DataCommunicator<T> dataCommunicator)
AbstractSingleSelect with the given custom data
communicator.
Note: This method is for creating an
AbstractSingleSelect with a custom communicator. In the common
case AbstractSingleSelect() should be used.
dataCommunicator - the data communicator to use, not nullpublic Registration addSelectionListener(SingleSelectionListener<T> listener)
listener - the selection listener, not nullpublic Optional<T> getSelectedItem()
public void setSelectedItem(T item)
null.item - the item to select or null to clear selectionpublic T getValue()
The call is delegated to getSelectedItem()
getValue in interface HasValue<T>nullgetSelectedItem(),
SelectionModel.Single.getSelectedItem()public void setValue(T value)
getValue(), fires a value change event. If
value is null then it deselects currently selected item.
The call is delegated to setSelectedItem(Object).
setValue in interface HasValue<T>value - the item to select or null to clear selectionsetSelectedItem(Object),
SelectionModel.Single.setSelectedItem(Object)public Registration addValueChangeListener(HasValue.ValueChangeListener<T> listener)
HasValueHasValue is changed either by the user or programmatically.addValueChangeListener in interface HasValue<T>listener - the value change listener, not nullprotected AbstractSingleSelectState getState()
AbstractComponentgetState in class AbstractListing<T>protected AbstractSingleSelectState getState(boolean markAsDirty)
AbstractClientConnectorgetState in class AbstractListing<T>markAsDirty - true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()public void setRequiredIndicatorVisible(boolean visible)
AbstractComponent
If the component supports the required indicator (state extends
AbstractFieldState), then expose this method and
AbstractComponent.isRequiredIndicatorVisible() as public in the component
and call this method.
This method will throw a IllegalStateException if the component
state (returned by AbstractComponent.getState()) does not inherit
AbstractFieldState.
setRequiredIndicatorVisible in interface HasValue<T>setRequiredIndicatorVisible in class AbstractComponentvisible - true to make the required indicator visible,
false if notpublic boolean isRequiredIndicatorVisible()
AbstractComponent
This method will throw a IllegalStateException if the component
state (returned by AbstractComponent.getState()) does not inherit
AbstractFieldState.
isRequiredIndicatorVisible in interface HasValue<T>isRequiredIndicatorVisible in class AbstractComponenttrue if visible, false if notAbstractComponent.setRequiredIndicatorVisible(boolean)public void setReadOnly(boolean readOnly)
AbstractComponentAbstractComponent.
This method should be made public in Components that
implement HasValue.setReadOnly in interface HasValue<T>setReadOnly in class AbstractComponentreadOnly - a boolean value specifying whether the component is put
read-only mode or notpublic boolean isReadOnly()
AbstractComponentAbstractComponent. This method should be made public in
Components that implement HasValue.isReadOnly in interface HasValue<T>isReadOnly in class AbstractComponenttrue if state has read-only on; false if notAbstractComponent.setReadOnly(boolean)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 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 itemToKey(T item)
item - the item whose key to returnprotected T keyToItem(String key)
null if
there is no such item.key - the key whose item to returnnull otherwise.public boolean isSelected(T item)
item - the item to check, not nulltrue if the item is selected, false otherwiseprotected org.jsoup.nodes.Element writeItem(org.jsoup.nodes.Element design,
T item,
DesignContext context)
AbstractListingwriteItem in class AbstractListing<T>design - the element into which to insert the itemitem - the item to writecontext - the DesignContext instance used in writingitemprotected void readItems(org.jsoup.nodes.Element design,
DesignContext context)
AbstractListingdesign.readItems in class AbstractListing<T>design - The element to obtain the state fromcontext - The DesignContext instance used for parsing the designprotected T readItem(org.jsoup.nodes.Element child, Set<T> selected, DesignContext context)
child - a child element representing the itemselected - A set accumulating selected items. If the item that is read is
marked as selected, its item id should be added to this set.context - the DesignContext instance used in parsingDesignException - if the tag name of the child element is not
option.protected Collection<String> getCustomAttributes()
AbstractComponentAbstractComponent.readDesign(Element, DesignContext)
and AbstractComponent.writeDesign(Element, DesignContext) methods. Typically these
are handled in a custom way in the overridden versions of the above
methodsgetCustomAttributes in class AbstractComponentCopyright © 2017 Vaadin Ltd. All rights reserved.