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.Listener
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Sizeable.Unit
DESIGN_ATTR_PLAIN_TEXT
SIZE_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 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 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.
|
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 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.
|
void |
setSelectedItem(T item)
Sets the current selection to the given item or clears selection if given
null . |
protected void |
setSelectedItem(T value,
boolean userOriginated)
This method updates the internal selection state of the server-side of
AbstractSingleSelect . |
void |
setValue(T value)
Sets the value of this object which is an item to select.
|
protected void |
updateSelectedItemState(T value)
This method updates the shared selection state of the
AbstractSingleSelect . |
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, writeItems
addContextClickListener, 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, setVisible, setWidth, setWidth, setWidthUndefined
addAttachListener, 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, updateDiffstate
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
clear, getDefaultValidator, getEmptyValue, getOptionalValue, isEmpty
getDataProvider, setItems, setItems, setItems
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
protected 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>
null
getSelectedItem()
,
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)
HasValue
HasValue
is changed either by the user or programmatically.addValueChangeListener
in interface HasValue<T>
listener
- the value change listener, not nullprotected AbstractSingleSelectState getState()
AbstractComponent
getState
in class AbstractListing<T>
protected AbstractSingleSelectState getState(boolean markAsDirty)
AbstractClientConnector
getState
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 AbstractComponent
visible
- 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 AbstractComponent
true
if visible, false
if notAbstractComponent.setRequiredIndicatorVisible(boolean)
public void setReadOnly(boolean readOnly)
AbstractComponent
AbstractComponent
.
This method should be made public in Components
that
implement HasValue
.setReadOnly
in interface HasValue<T>
setReadOnly
in class AbstractComponent
readOnly
- a boolean value specifying whether the component is put
read-only mode or notpublic boolean isReadOnly()
AbstractComponent
AbstractComponent
. This method should be made public in
Components
that implement HasValue
.isReadOnly
in interface HasValue<T>
isReadOnly
in class AbstractComponent
true
if state has read-only on; false
if notAbstractComponent.setReadOnly(boolean)
protected 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)
AbstractListing
writeItem
in class AbstractListing<T>
design
- the element into which to insert the itemitem
- the item to writecontext
- the DesignContext instance used in writingitem
protected void readItems(org.jsoup.nodes.Element design, DesignContext context)
AbstractListing
design
.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()
AbstractComponent
AbstractComponent.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 AbstractComponent
protected void setSelectedItem(T value, boolean userOriginated)
AbstractSingleSelect
.value
- the value that should be selecteduserOriginated
- true
if selection was done by user, false
if
notprotected void updateSelectedItemState(T value)
AbstractSingleSelect
.value
- the value that is selected; may be null
Copyright © 2018 Vaadin Ltd. All rights reserved.