T
- item typepublic abstract class AbstractMultiSelect<T> extends AbstractListing<T> implements MultiSelect<T>
Sends selection information individually for each item.
AbstractListing.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 |
AbstractMultiSelect()
Creates a new multi select with an empty data provider.
|
Modifier and Type | Method and Description |
---|---|
Registration |
addSelectionListener(MultiSelectionListener<T> listener)
Adds a selection listener that will be called when the selection is
changed either by the user or programmatically.
|
Registration |
addValueChangeListener(HasValue.ValueChangeListener<Set<T>> listener)
Adds a value change listener.
|
protected void |
deselect(Set<T> items,
boolean userOriginated)
Removes the given items.
|
protected void |
deselect(T item,
boolean userOriginated)
Deselects the given item.
|
void |
deselectAll()
Deselects all currently selected items.
|
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. |
ItemCaptionGenerator<T> |
getItemCaptionGenerator()
Gets the item caption generator that is used to produce the strings shown
in the combo box for each item.
|
protected SerializablePredicate<T> |
getItemEnabledProvider()
Returns the item enabled provider for this multiselect.
|
Set<T> |
getSelectedItems()
Returns an immutable set of the currently selected items.
|
protected AbstractMultiSelectState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
protected AbstractMultiSelectState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
Set<T> |
getValue()
Returns the current value of this object which is an immutable set of the
currently selected items.
|
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 |
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 . |
protected void |
select(T item,
boolean userOriginated)
Selects the given item.
|
void |
setItemCaptionGenerator(ItemCaptionGenerator<T> itemCaptionGenerator)
Sets the item caption generator that is used to produce the strings shown
in the combo box for each item.
|
protected void |
setItemEnabledProvider(SerializablePredicate<T> itemEnabledProvider)
Sets the item enabled predicate for this multiselect.
|
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 |
setValue(Set<T> value)
Sets the value of this object which is a set of items to select.
|
void |
updateSelection(Set<T> addedItems,
Set<T> removedItems)
Updates the selection by adding and removing the given items from it.
|
protected void |
updateSelection(Set<T> addedItems,
Set<T> removedItems,
boolean userOriginated)
Updates the selection by adding and removing the given items.
|
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, getItemIconGenerator, getTabIndex, internalGetDataProvider, internalSetDataProvider, internalSetDataProvider, readDesign, readItem, removeDataGenerator, serializeDeclarativeRepresentation, 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
deselect, getEmptyValue, select
clear, getDefaultValidator, 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 AbstractMultiSelect()
public Registration addSelectionListener(MultiSelectionListener<T> listener)
addSelectionListener
in interface MultiSelect<T>
listener
- the value change listener, not null
public ItemCaptionGenerator<T> getItemCaptionGenerator()
AbstractListing
getItemCaptionGenerator
in class AbstractListing<T>
public void setItemCaptionGenerator(ItemCaptionGenerator<T> itemCaptionGenerator)
AbstractListing
String.valueOf(Object)
is used.setItemCaptionGenerator
in class AbstractListing<T>
itemCaptionGenerator
- the item caption provider to use, not nullpublic Set<T> getValue()
The call is delegated to getSelectedItems()
getValue
in interface HasValue<Set<T>>
getSelectedItems()
,
SelectionModel.getSelectedItems()
public void setValue(Set<T> value)
getValue()
, fires a value change event.
May throw IllegalArgumentException
if the value is not
acceptable.
The method effectively selects the given items and deselects previously
selected. The call is delegated to
SelectionModel.Multi.updateSelection(Set, Set)
.
setValue
in interface HasValue<Set<T>>
value
- the items to select, not null
NullPointerException
- if the value is invalidSelectionModel.Multi.updateSelection(Set, Set)
public Registration addValueChangeListener(HasValue.ValueChangeListener<Set<T>> listener)
addValueChangeListener
in interface HasValue<Set<T>>
listener
- the value change listener, not nulladdSelectionListener(MultiSelectionListener)
protected SerializablePredicate<T> getItemEnabledProvider()
Implementation note: Override this method and
setItemEnabledProvider(SerializablePredicate)
as public
and invoke super
methods to support this feature in the
multiselect component.
null
setItemEnabledProvider(SerializablePredicate)
protected void setItemEnabledProvider(SerializablePredicate<T> itemEnabledProvider)
true
) or disabled (false
). Disabled items are displayed
as grayed out and the user cannot select them. The default predicate
always returns true
(all the items are enabled).
Implementation note: Override this method and
getItemEnabledProvider()
as public
and invoke
super
methods to support this feature in the multiselect
component.
itemEnabledProvider
- the item enabled provider to set, not null
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<Set<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<Set<T>>
isRequiredIndicatorVisible
in class AbstractComponent
true
if visible, false
if notAbstractComponent.setRequiredIndicatorVisible(boolean)
protected AbstractMultiSelectState getState()
AbstractComponent
getState
in class AbstractListing<T>
protected AbstractMultiSelectState getState(boolean markAsDirty)
AbstractClientConnector
getState
in class AbstractListing<T>
markAsDirty
- true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()
public void setReadOnly(boolean readOnly)
AbstractComponent
AbstractComponent
.
This method should be made public in Components
that
implement HasValue
.setReadOnly
in interface HasValue<Set<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<Set<T>>
isReadOnly
in class AbstractComponent
true
if state has read-only on; false
if notAbstractComponent.setReadOnly(boolean)
public void updateSelection(Set<T> addedItems, Set<T> removedItems)
MultiSelect
If all the added items were already selected and the removed items were not selected, this is a NO-OP.
Duplicate items (in both add & remove sets) are ignored.
updateSelection
in interface MultiSelect<T>
addedItems
- the items to add, not null
removedItems
- the items to remove, not null
protected void updateSelection(Set<T> addedItems, Set<T> removedItems, boolean userOriginated)
addedItems
- the items added to selection, not nullremovedItems
- the items removed from selection, not nulluserOriginated
- true
if this was used originated, false
if notpublic Set<T> getSelectedItems()
MultiSelect
SelectionModel
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 MultiSelect<T>
public void deselectAll()
MultiSelect
deselectAll
in interface MultiSelect<T>
public boolean isSelected(T item)
MultiSelect
isSelected
in interface MultiSelect<T>
item
- the item to check, not nulltrue
if the item is selected, false
otherwiseprotected void deselect(T item, boolean userOriginated)
item
- the item to deselect, not nulluserOriginated
- true
if this was used originated, false
if notprotected void deselect(Set<T> items, boolean userOriginated)
items
- the items to deselect, not null
userOriginated
- true
if this was used originated, false
if notprotected void select(T item, boolean userOriginated)
item
- the item to select, not nulluserOriginated
- true
if this was used originated, false
if notprotected 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 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
.Copyright © 2019 Vaadin Ltd. All rights reserved.