Class AbstractSelect
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.ui.AbstractComponent
-
- com.vaadin.ui.AbstractField<Object>
-
- com.vaadin.ui.AbstractSelect
-
- All Implemented Interfaces:
Buffered
,BufferedValidatable
,Container
,Container.ItemSetChangeListener
,Container.ItemSetChangeNotifier
,Container.PropertySetChangeListener
,Container.PropertySetChangeNotifier
,Container.Viewer
,Property<Object>
,Property.Editor
,Property.ReadOnlyStatusChangeListener
,Property.ReadOnlyStatusChangeNotifier
,Property.ValueChangeListener
,Property.ValueChangeNotifier
,Property.Viewer
,Validatable
,Action.ShortcutNotifier
,ConnectorEventListener
,ContextClickEvent.ContextClickNotifier
,MethodEventSource
,ClientConnector
,Sizeable
,VariableOwner
,Connector
,Component
,Component.Focusable
,Field<Object>
,LegacyComponent
,Serializable
,EventListener
- Direct Known Subclasses:
ComboBox
,ListSelect
,NativeSelect
,OptionGroup
,Table
,Tree
,TwinColSelect
public abstract class AbstractSelect extends AbstractField<Object> implements Container, Container.Viewer, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.ItemSetChangeNotifier, Container.ItemSetChangeListener, LegacyComponent
A class representing a selection of items the user has selected in a UI. The set of choices is presented as a set of
Item
s in aContainer
.A
Select
component may be in single- or multiselect mode. Multiselect mode means that more than one item can be selected simultaneously.- Since:
- 5.0
- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
AbstractSelect.AbstractSelectTargetDetails
TargetDetails implementation for subclasses ofAbstractSelect
that implementDropTarget
.static class
AbstractSelect.AcceptItem
This criterion accepts a only aTransferable
that contains given Item (practically its identifier) from a specific AbstractSelect.protected class
AbstractSelect.CaptionChangeListener
This is a listener helper for Item and Property changes that should cause a repaint.class
AbstractSelect.DefaultNewItemHandler
TODO refine doc This is a default class that handles adding new items that are typed by user to selects container.static interface
AbstractSelect.Filtering
Interface for option filtering, used to filter options based on user entered value.static class
AbstractSelect.ItemCaptionMode
static interface
AbstractSelect.ItemDescriptionGenerator
Implement this interface and pass it to Tree.setItemDescriptionGenerator or Table.setItemDescriptionGenerator to generate mouse over descriptions ("tooltips") for the rows and cells in Table or for the items in Tree.static interface
AbstractSelect.NewItemHandler
static class
AbstractSelect.TargetItemIs
Criterion which accepts a drop only if the drop target is (one of) the given Item identifier(s).static class
AbstractSelect.VerticalLocationIs
An accept criterion to accept drops only on a specific vertical location of an item.-
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractField
AbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEvent
-
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered
Buffered.SourceException
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.data.Container
Container.Editor, Container.Filter, Container.Filterable, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.SimpleFilterable, Container.Sortable, Container.Viewer
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Field
Field.ValueChangeEvent
-
Nested classes/interfaces inherited from interface com.vaadin.data.Property
Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Constructor Summary
Constructors Constructor Description AbstractSelect()
Creates an empty Select.AbstractSelect(String caption)
Creates an empty Select with caption.AbstractSelect(String caption, Container dataSource)
Creates a new select that is connected to a data-source.AbstractSelect(String caption, Collection<?> options)
Creates a new select that is filled from a collection of option values.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
addContainerProperty(Object propertyId, Class<?> type, Object defaultValue)
Adds the new property to all items.Object
addItem()
Creates a new item into container with container managed id.Item
addItem(Object itemId)
Create a new item into container.void
addItems(Object... itemId)
Adds given items with given item ids to container.void
addItems(Collection<?> itemIds)
Adds given items with given item ids to container.void
addItemSetChangeListener(Container.ItemSetChangeListener listener)
Adds an Item set change listener for the object.void
addListener(Container.ItemSetChangeListener listener)
Deprecated.As of 7.0, replaced byaddItemSetChangeListener(Container.ItemSetChangeListener)
void
addListener(Container.PropertySetChangeListener listener)
Deprecated.As of 7.0, replaced byaddPropertySetChangeListener(Container.PropertySetChangeListener)
void
addPropertySetChangeListener(Container.PropertySetChangeListener listener)
Adds a new Property set change listener for this Container.void
attach()
Notifies the component that it is connected to an application.void
changeVariables(Object source, Map<String,Object> variables)
Invoked when the value of a variable has changed.void
containerItemSetChange(Container.ItemSetChangeEvent event)
Lets the listener know a Containers Item set has changed.void
containerPropertySetChange(Container.PropertySetChangeEvent event)
Notifies this listener that the Containers contents has changed.boolean
containsId(Object itemId)
Tests, if the collection contains an item with given id.void
detach()
Detaches the component from application.protected void
fireItemSetChange()
Fires the item set change event.protected void
firePropertySetChange()
Fires the property set change event.protected AbstractSelect.CaptionChangeListener
getCaptionChangeListener()
Container
getContainerDataSource()
Gets the viewing data-source container.Property
getContainerProperty(Object itemId, Object propertyId)
Gets the Property identified by the given itemId and propertyId from the ContainerCollection<?>
getContainerPropertyIds()
Gets the property Id collection from the container.Item
getItem(Object itemId)
Gets the item from the container with given id.String
getItemCaption(Object itemId)
Gets the caption of an item.AbstractSelect.ItemCaptionMode
getItemCaptionMode()
Gets the item caption mode.Object
getItemCaptionPropertyId()
Gets the item caption property.Resource
getItemIcon(Object itemId)
Gets the item icon.Object
getItemIconPropertyId()
Gets the item icon property.Collection<?>
getItemIds()
Gets the item Id collection from the container.Collection<?>
getListeners(Class<?> eventType)
Returns all listeners that are registered for the given event type or one of its subclasses.AbstractSelect.NewItemHandler
getNewItemHandler()
TODO refine docObject
getNullSelectionItemId()
Returns the item id that represents null value of this select in single select mode.protected AbstractSelectState
getState()
Returns the shared state bean with information to be sent from the server to the client.Class<?>
getType()
Returns the type of the property.Class<?>
getType(Object propertyId)
Gets the property type.Object
getValue()
Gets the selected item id or in multiselect mode a set of selected ids.Collection<?>
getVisibleItemIds()
Gets the visible item ids.boolean
isEmpty()
For multi-selectable fields, also an empty collection of values is considered to be an empty field.boolean
isMultiSelect()
Is the select in multiselect mode? In multiselect modeboolean
isNewItemsAllowed()
Does the select allow adding new options by the user.boolean
isNullSelectionAllowed()
Checks if null empty selection is allowed by the user.boolean
isSelected(Object itemId)
Tests if an item is selected.void
paintContent(PaintTarget target)
Paints the content of this component.protected void
paintItem(PaintTarget target, Object itemId)
void
readDesign(org.jsoup.nodes.Element design, DesignContext context)
Reads the component state from the given design.protected Object
readItem(org.jsoup.nodes.Element child, Set<String> 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)
boolean
removeAllItems()
Removes all items from the container.boolean
removeContainerProperty(Object propertyId)
Removes the property from all items.boolean
removeItem(Object itemId)
Removes the Item identified byItemId
from the Container.void
removeItemSetChangeListener(Container.ItemSetChangeListener listener)
Removes the Item set change listener from the object.void
removeListener(Container.ItemSetChangeListener listener)
Deprecated.As of 7.0, replaced byremoveItemSetChangeListener(Container.ItemSetChangeListener)
void
removeListener(Container.PropertySetChangeListener listener)
Deprecated.As of 7.0, replaced byremovePropertySetChangeListener(Container.PropertySetChangeListener)
void
removePropertySetChangeListener(Container.PropertySetChangeListener listener)
Removes a previously registered Property set change listener.void
sanitizeSelection()
Checks that the current selection is valid, i.e.void
select(Object itemId)
Selects an item.void
setContainerDataSource(Container newDataSource)
Sets the Container that serves as the data source of the viewer.void
setItemCaption(Object itemId, String caption)
Override the caption of an item.void
setItemCaptionMode(AbstractSelect.ItemCaptionMode mode)
Sets the item caption mode.void
setItemCaptionPropertyId(Object propertyId)
Sets the item caption property.void
setItemIcon(Object itemId, Resource icon)
Sets the icon for an item.void
setItemIconPropertyId(Object propertyId)
Sets the item icon property.void
setMultiSelect(boolean multiSelect)
Sets the multiselect mode.void
setNewItemHandler(AbstractSelect.NewItemHandler newItemHandler)
TODO refine doc Setter for new item handler that is called when user adds new item in newItemAllowed mode.void
setNewItemsAllowed(boolean allowNewOptions)
Enables or disables possibility to add new options by the user.void
setNullSelectionAllowed(boolean nullSelectionAllowed)
Allow or disallow empty selection by the user.void
setNullSelectionItemId(Object nullSelectionItemId)
Sets the item id that represents null value of this select.void
setValue(Object newValue)
Sets the visible value of the property.protected void
setValue(Object newFieldValue, boolean repaintIsNotNeeded, boolean ignoreReadOnly)
Sets the visible value of the property.int
size()
Gets the number of items in the container.void
unselect(Object itemId)
Unselects an item.void
writeDesign(org.jsoup.nodes.Element design, DesignContext context)
Writes the component state to the given design.protected org.jsoup.nodes.Element
writeItem(org.jsoup.nodes.Element design, Object itemId, DesignContext context)
Writes a data source Item to a design.protected void
writeItems(org.jsoup.nodes.Element design, DesignContext context)
Writes the data source items to a design.-
Methods inherited from class com.vaadin.ui.AbstractField
addListener, addListener, addReadOnlyStatusChangeListener, addValidator, addValueChangeListener, beforeClientResponse, clear, commit, discard, fireReadOnlyStatusChange, fireValueChange, focus, getConversionError, getConversionError, getConvertedValue, getConverter, getCurrentBufferedSourceException, getCustomAttributes, getErrorMessage, getInternalValue, getModelType, getPropertyDataSource, getRequiredError, getState, getTabIndex, getValidators, isBuffered, isImmediate, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isRequired, isValid, isValidationVisible, readOnlyStatusChange, removeAllValidators, removeListener, removeListener, removeReadOnlyStatusChangeListener, removeValidator, removeValueChangeListener, setBuffered, setConversionError, setConvertedValue, setConverter, setConverter, setCurrentBufferedSourceException, setInternalValue, setInvalidAllowed, setInvalidCommitted, setLocale, setPropertyDataSource, setReadOnly, setRequired, setRequiredError, setTabIndex, setValidationVisible, setValue, shouldHideErrors, toString, validate, validate, valueChange
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getExplicitImmediateValue, 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, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidth, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, 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
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.vaadin.event.Action.ShortcutNotifier
addShortcutListener, removeShortcutListener
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setStyleName, setVisible
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.ui.LegacyComponent
markAsDirty
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
-
Methods inherited from interface com.vaadin.server.VariableOwner
isEnabled, isImmediate
-
-
-
-
Field Detail
-
ITEM_CAPTION_MODE_ID
@Deprecated public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_ID
Deprecated.As of 7.0, useAbstractSelect.ItemCaptionMode.ID
instead
-
ITEM_CAPTION_MODE_ITEM
@Deprecated public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_ITEM
Deprecated.As of 7.0, useAbstractSelect.ItemCaptionMode.ITEM
instead
-
ITEM_CAPTION_MODE_INDEX
@Deprecated public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_INDEX
Deprecated.As of 7.0, useAbstractSelect.ItemCaptionMode.INDEX
instead
-
ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID
@Deprecated public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID
Deprecated.As of 7.0, useAbstractSelect.ItemCaptionMode.EXPLICIT_DEFAULTS_ID
instead
-
ITEM_CAPTION_MODE_EXPLICIT
@Deprecated public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_EXPLICIT
Deprecated.As of 7.0, useAbstractSelect.ItemCaptionMode.EXPLICIT
instead
-
ITEM_CAPTION_MODE_ICON_ONLY
@Deprecated public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_ICON_ONLY
Deprecated.As of 7.0, useAbstractSelect.ItemCaptionMode.ICON_ONLY
instead
-
ITEM_CAPTION_MODE_PROPERTY
@Deprecated public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_PROPERTY
Deprecated.As of 7.0, useAbstractSelect.ItemCaptionMode.PROPERTY
instead
-
items
protected Container items
Select options.
-
-
Constructor Detail
-
AbstractSelect
public AbstractSelect()
Creates an empty Select. The caption is not used.
-
AbstractSelect
public AbstractSelect(String caption)
Creates an empty Select with caption.
-
AbstractSelect
public AbstractSelect(String caption, Container dataSource)
Creates a new select that is connected to a data-source.- Parameters:
caption
- the Caption of the component.dataSource
- the Container datasource to be selected from by this select.
-
AbstractSelect
public AbstractSelect(String caption, Collection<?> options)
Creates a new select that is filled from a collection of option values.- Parameters:
caption
- the Caption of this field.options
- the Collection containing the options.
-
-
Method Detail
-
paintContent
public void paintContent(PaintTarget target) throws PaintException
Paints the content of this component.- Specified by:
paintContent
in interfaceLegacyComponent
- Parameters:
target
- the Paint Event.- Throws:
PaintException
- if the paint operation failed.
-
paintItem
protected void paintItem(PaintTarget target, Object itemId) throws PaintException
- Throws:
PaintException
-
changeVariables
public void changeVariables(Object source, Map<String,Object> variables)
Invoked when the value of a variable has changed.- Specified by:
changeVariables
in interfaceVariableOwner
- Parameters:
source
- the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.variables
- the Mapping from variable names to new variable values.- See Also:
AbstractComponent#changeVariables(java.lang.Object, java.util.Map)
-
setNewItemHandler
public void setNewItemHandler(AbstractSelect.NewItemHandler newItemHandler)
TODO refine doc Setter for new item handler that is called when user adds new item in newItemAllowed mode.- Parameters:
newItemHandler
-
-
getNewItemHandler
public AbstractSelect.NewItemHandler getNewItemHandler()
TODO refine doc- Returns:
-
getVisibleItemIds
public Collection<?> getVisibleItemIds()
Gets the visible item ids. In Select, this returns list of all item ids, but can be overriden in subclasses if they paint only part of the items to the terminal or null if no items is visible.
-
getType
public Class<?> getType()
Returns the type of the property.getValue
andsetValue
methods must be compatible with this type: one can safely castgetValue
to given type and pass any variable assignable to this type as a parameter tosetValue
.
-
getValue
public Object getValue()
Gets the selected item id or in multiselect mode a set of selected ids.- Specified by:
getValue
in interfaceProperty<Object>
- Overrides:
getValue
in classAbstractField<Object>
- Returns:
- the current value of the field.
- See Also:
AbstractField.getValue()
-
setValue
public void setValue(Object newValue) throws Property.ReadOnlyException
Sets the visible value of the property.The value of the select is the selected item id. If the select is in multiselect-mode, the value is a set of selected item keys. In multiselect mode all collections of id:s can be assigned.
- Specified by:
setValue
in interfaceProperty<Object>
- Overrides:
setValue
in classAbstractField<Object>
- Parameters:
newValue
- the New selected item or collection of selected items.- Throws:
Property.ReadOnlyException
- if the object is in read-only mode- See Also:
AbstractField.setValue(java.lang.Object)
-
setValue
protected void setValue(Object newFieldValue, boolean repaintIsNotNeeded, boolean ignoreReadOnly) throws Property.ReadOnlyException, Converter.ConversionException, Validator.InvalidValueException
Sets the visible value of the property.The value of the select is the selected item id. If the select is in multiselect-mode, the value is a set of selected item keys. In multiselect mode all collections of id:s can be assigned.
- Overrides:
setValue
in classAbstractField<Object>
- Parameters:
newValue
- the New selected item or collection of selected items.repaintIsNotNeeded
- True if caller is sure that repaint is not needed.ignoreReadOnly
- True if read-only check should be omitted.- Throws:
Property.ReadOnlyException
Converter.ConversionException
Validator.InvalidValueException
- Since:
- 7.5.7
- See Also:
AbstractField#setValue(java.lang.Object, java.lang.Boolean)
-
getItem
public Item getItem(Object itemId)
Gets the item from the container with given id. If the container does not contain the requested item, null is returned.
-
getItemIds
public Collection<?> getItemIds()
Gets the item Id collection from the container.- Specified by:
getItemIds
in interfaceContainer
- Returns:
- the Collection of item ids.
-
getContainerPropertyIds
public Collection<?> getContainerPropertyIds()
Gets the property Id collection from the container.- Specified by:
getContainerPropertyIds
in interfaceContainer
- Returns:
- the Collection of property ids.
-
getType
public Class<?> getType(Object propertyId)
Gets the property type.- Specified by:
getType
in interfaceContainer
- Parameters:
propertyId
- the Id identifying the property.- Returns:
- data type of the Properties
- See Also:
Container.getType(java.lang.Object)
-
size
public int size()
Gets the number of items in the container.- Specified by:
size
in interfaceContainer
- Returns:
- the Number of items in the container.
- See Also:
Container.size()
-
containsId
public boolean containsId(Object itemId)
Tests, if the collection contains an item with given id.- Specified by:
containsId
in interfaceContainer
- Parameters:
itemId
- the Id the of item to be tested.- Returns:
- boolean indicating if the Container holds the specified Item
-
getContainerProperty
public Property getContainerProperty(Object itemId, Object propertyId)
Gets the Property identified by the given itemId and propertyId from the Container- Specified by:
getContainerProperty
in interfaceContainer
- Parameters:
itemId
- ID of the visible Item which contains the PropertypropertyId
- ID of the Property to retrieve- Returns:
- Property with the given ID or
null
- See Also:
Container.getContainerProperty(Object, Object)
-
addContainerProperty
public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException
Adds the new property to all items. Adds a property with given id, type and default value to all items in the container. This functionality is optional. If the function is unsupported, it always returns false.- Specified by:
addContainerProperty
in interfaceContainer
- Parameters:
propertyId
- ID of the Propertytype
- Data type of the new PropertydefaultValue
- The value all created Properties are initialized to- Returns:
- True if the operation succeeded.
- Throws:
UnsupportedOperationException
- if the container does not support explicitly adding container properties- See Also:
Container.addContainerProperty(java.lang.Object, java.lang.Class, java.lang.Object)
-
removeAllItems
public boolean removeAllItems() throws UnsupportedOperationException
Removes all items from the container. This functionality is optional. If the function is unsupported, it always returns false.- Specified by:
removeAllItems
in interfaceContainer
- Returns:
- True if the operation succeeded.
- Throws:
UnsupportedOperationException
- if the container does not support removing all items- See Also:
Container.removeAllItems()
-
addItem
public Object addItem() throws UnsupportedOperationException
Creates a new item into container with container managed id. The id of the created new item is returned. The item can be fetched with getItem() method. if the creation fails, null is returned.- Specified by:
addItem
in interfaceContainer
- Returns:
- the Id of the created item or null in case of failure.
- Throws:
UnsupportedOperationException
- if adding an item without an explicit item ID is not supported by the container- See Also:
Container.addItem()
-
addItem
public Item addItem(Object itemId) throws UnsupportedOperationException
Create a new item into container. The created new item is returned and ready for setting property values. if the creation fails, null is returned. In case the container already contains the item, null is returned. This functionality is optional. If the function is unsupported, it always returns null.- Specified by:
addItem
in interfaceContainer
- Parameters:
itemId
- the Identification of the item to be created.- Returns:
- the Created item with the given id, or null in case of failure.
- Throws:
UnsupportedOperationException
- if adding an item with an explicit item ID is not supported by the container- See Also:
Container.addItem(java.lang.Object)
-
addItems
public void addItems(Object... itemId) throws UnsupportedOperationException
Adds given items with given item ids to container.- Parameters:
itemId
- item identifiers to be added to underlying container- Throws:
UnsupportedOperationException
- if the underlying container don't support adding items with identifiers- Since:
- 7.2
-
addItems
public void addItems(Collection<?> itemIds) throws UnsupportedOperationException
Adds given items with given item ids to container.- Parameters:
itemIds
- item identifiers to be added to underlying container- Throws:
UnsupportedOperationException
- if the underlying container don't support adding items with identifiers- Since:
- 7.2
-
removeItem
public boolean removeItem(Object itemId) throws UnsupportedOperationException
Description copied from interface:Container
Removes the Item identified byItemId
from the Container.Containers that support filtering should also allow removing an item that is currently filtered out.
This functionality is optional.
- Specified by:
removeItem
in interfaceContainer
- Parameters:
itemId
- ID of the Item to remove- Returns:
true
if the operation succeeded,false
if not- Throws:
UnsupportedOperationException
- if the container does not support removing individual items
-
sanitizeSelection
public void sanitizeSelection()
Checks that the current selection is valid, i.e. the selected item ids exist in the container. Updates the selection if one or several selected item ids are no longer available in the container.
-
removeContainerProperty
public boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException
Removes the property from all items. Removes a property with given id from all the items in the container. This functionality is optional. If the function is unsupported, it always returns false.- Specified by:
removeContainerProperty
in interfaceContainer
- Parameters:
propertyId
- ID of the Property to remove- Returns:
- True if the operation succeeded.
- Throws:
UnsupportedOperationException
- if the container does not support removing container properties- See Also:
Container.removeContainerProperty(java.lang.Object)
-
setContainerDataSource
public void setContainerDataSource(Container newDataSource)
Sets the Container that serves as the data source of the viewer. As a side-effect the fields value (selection) is set to null due old selection not necessary exists in new Container.- Specified by:
setContainerDataSource
in interfaceContainer.Viewer
- Parameters:
newDataSource
- the new data source.- See Also:
Container.Viewer.setContainerDataSource(Container)
-
getContainerDataSource
public Container getContainerDataSource()
Gets the viewing data-source container.- Specified by:
getContainerDataSource
in interfaceContainer.Viewer
- Returns:
- data source Container
- See Also:
Container.Viewer.getContainerDataSource()
-
isMultiSelect
public boolean isMultiSelect()
Is the select in multiselect mode? In multiselect mode- Returns:
- the Value of property multiSelect.
-
setMultiSelect
public void setMultiSelect(boolean multiSelect)
Sets the multiselect mode. Setting multiselect mode false may lose selection information: if selected items set contains one or more selected items, only one of the selected items is kept as selected. Subclasses of AbstractSelect can choose not to support changing the multiselect mode, and may throwUnsupportedOperationException
.- Parameters:
multiSelect
- the New value of property multiSelect.
-
isNewItemsAllowed
public boolean isNewItemsAllowed()
Does the select allow adding new options by the user. If true, the new options can be added to the Container. The text entered by the user is used as id. Note that data-source must allow adding new items.- Returns:
- True if additions are allowed.
-
setNewItemsAllowed
public void setNewItemsAllowed(boolean allowNewOptions)
Enables or disables possibility to add new options by the user.- Parameters:
allowNewOptions
- the New value of property allowNewOptions.
-
setItemCaption
public void setItemCaption(Object itemId, String caption)
Override the caption of an item. Setting caption explicitly overrides id, item and index captions.- Parameters:
itemId
- the id of the item to be recaptioned.caption
- the New caption.
-
getItemCaption
public String getItemCaption(Object itemId)
Gets the caption of an item. The caption is generated as specified by the item caption mode. SeesetItemCaptionMode()
for more details.- Parameters:
itemId
- the id of the item to be queried.- Returns:
- the caption for specified item.
-
setItemIcon
public void setItemIcon(Object itemId, Resource icon)
Sets the icon for an item.- Parameters:
itemId
- the id of the item to be assigned an icon.icon
- the icon to use or null.
-
getItemIcon
public Resource getItemIcon(Object itemId)
Gets the item icon.- Parameters:
itemId
- the id of the item to be assigned an icon.- Returns:
- the icon for the item or null, if not specified.
-
setItemCaptionMode
public void setItemCaptionMode(AbstractSelect.ItemCaptionMode mode)
Sets the item caption mode. SeeAbstractSelect.ItemCaptionMode
for a description of the modes.AbstractSelect.ItemCaptionMode.EXPLICIT_DEFAULTS_ID
is the default mode.- Parameters:
mode
- the One of the modes listed above.
-
getItemCaptionMode
public AbstractSelect.ItemCaptionMode getItemCaptionMode()
Gets the item caption mode.The mode can be one of the following ones:
ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID
: Items Id-objectstoString
is used as item caption. If caption is explicitly specified, it overrides the id-caption.ITEM_CAPTION_MODE_ID
: Items Id-objectstoString
is used as item caption.ITEM_CAPTION_MODE_ITEM
: Item-objectstoString
is used as item caption.ITEM_CAPTION_MODE_INDEX
: The index of the item is used as item caption. The index mode can only be used with the containers implementingContainer.Indexed
interface.ITEM_CAPTION_MODE_EXPLICIT
: The item captions must be explicitly specified.ITEM_CAPTION_MODE_PROPERTY
: The item captions are read from property, that must be specified withsetItemCaptionPropertyId
.
ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID
is the default mode.- Returns:
- the One of the modes listed above.
-
setItemCaptionPropertyId
public void setItemCaptionPropertyId(Object propertyId)
Sets the item caption property.Setting the id to a existing property implicitly sets the item caption mode to
ITEM_CAPTION_MODE_PROPERTY
. If the object is inITEM_CAPTION_MODE_PROPERTY
mode, setting caption property id null resets the item caption mode toITEM_CAPTION_EXPLICIT_DEFAULTS_ID
.Note that the type of the property used for caption must be String
Setting the property id to null disables this feature. The id is null by default
.- Parameters:
propertyId
- the id of the property.
-
getItemCaptionPropertyId
public Object getItemCaptionPropertyId()
Gets the item caption property.- Returns:
- the Id of the property used as item caption source.
-
setItemIconPropertyId
public void setItemIconPropertyId(Object propertyId) throws IllegalArgumentException
Sets the item icon property.If the property id is set to a valid value, each item is given an icon got from the given property of the items. The type of the property must be assignable to Resource.
Note : The icons set with
setItemIcon
function override the icons from the property.Setting the property id to null disables this feature. The id is null by default
.- Parameters:
propertyId
- the id of the property that specifies icons for items or null- Throws:
IllegalArgumentException
- If the propertyId is not in the container or is not of a valid type
-
getItemIconPropertyId
public Object getItemIconPropertyId()
Gets the item icon property.If the property id is set to a valid value, each item is given an icon got from the given property of the items. The type of the property must be assignable to Icon.
Note : The icons set with
setItemIcon
function override the icons from the property.Setting the property id to null disables this feature. The id is null by default
.- Returns:
- the Id of the property containing the item icons.
-
isSelected
public boolean isSelected(Object itemId)
Tests if an item is selected.In single select mode testing selection status of the item identified by
getNullSelectionItemId()
returns true if the value of the property is null.- Parameters:
itemId
- the Id the of the item to be tested.- See Also:
getNullSelectionItemId()
,setNullSelectionItemId(Object)
-
select
public void select(Object itemId)
Selects an item.In single select mode selecting item identified by
getNullSelectionItemId()
sets the value of the property to null.- Parameters:
itemId
- the identifier of Item to be selected.- See Also:
getNullSelectionItemId()
,setNullSelectionItemId(Object)
-
unselect
public void unselect(Object itemId)
Unselects an item.- Parameters:
itemId
- the identifier of the Item to be unselected.- See Also:
getNullSelectionItemId()
,setNullSelectionItemId(Object)
-
containerPropertySetChange
public void containerPropertySetChange(Container.PropertySetChangeEvent event)
Notifies this listener that the Containers contents has changed.- Specified by:
containerPropertySetChange
in interfaceContainer.PropertySetChangeListener
- Parameters:
event
- Change event.- See Also:
Container.PropertySetChangeListener.containerPropertySetChange(Container.PropertySetChangeEvent)
-
addPropertySetChangeListener
public void addPropertySetChangeListener(Container.PropertySetChangeListener listener)
Adds a new Property set change listener for this Container.- Specified by:
addPropertySetChangeListener
in interfaceContainer.PropertySetChangeNotifier
- Parameters:
listener
- The new Listener to be registered- See Also:
Container.PropertySetChangeNotifier.addListener(Container.PropertySetChangeListener)
-
addListener
@Deprecated public void addListener(Container.PropertySetChangeListener listener)
Deprecated.As of 7.0, replaced byaddPropertySetChangeListener(Container.PropertySetChangeListener)
- Specified by:
addListener
in interfaceContainer.PropertySetChangeNotifier
-
removePropertySetChangeListener
public void removePropertySetChangeListener(Container.PropertySetChangeListener listener)
Removes a previously registered Property set change listener.- Specified by:
removePropertySetChangeListener
in interfaceContainer.PropertySetChangeNotifier
- Parameters:
listener
- Listener to be removed- See Also:
Container.PropertySetChangeNotifier.removeListener(Container.PropertySetChangeListener)
-
removeListener
@Deprecated public void removeListener(Container.PropertySetChangeListener listener)
Deprecated.As of 7.0, replaced byremovePropertySetChangeListener(Container.PropertySetChangeListener)
- Specified by:
removeListener
in interfaceContainer.PropertySetChangeNotifier
-
addItemSetChangeListener
public void addItemSetChangeListener(Container.ItemSetChangeListener listener)
Adds an Item set change listener for the object.- Specified by:
addItemSetChangeListener
in interfaceContainer.ItemSetChangeNotifier
- Parameters:
listener
- listener to be added- See Also:
Container.ItemSetChangeNotifier.addListener(Container.ItemSetChangeListener)
-
addListener
@Deprecated public void addListener(Container.ItemSetChangeListener listener)
Deprecated.As of 7.0, replaced byaddItemSetChangeListener(Container.ItemSetChangeListener)
- Specified by:
addListener
in interfaceContainer.ItemSetChangeNotifier
-
removeItemSetChangeListener
public void removeItemSetChangeListener(Container.ItemSetChangeListener listener)
Removes the Item set change listener from the object.- Specified by:
removeItemSetChangeListener
in interfaceContainer.ItemSetChangeNotifier
- Parameters:
listener
- listener to be removed- See Also:
Container.ItemSetChangeNotifier.removeListener(Container.ItemSetChangeListener)
-
removeListener
@Deprecated public void removeListener(Container.ItemSetChangeListener listener)
Deprecated.As of 7.0, replaced byremoveItemSetChangeListener(Container.ItemSetChangeListener)
- Specified by:
removeListener
in interfaceContainer.ItemSetChangeNotifier
-
getListeners
public Collection<?> getListeners(Class<?> eventType)
Description copied from class:AbstractClientConnector
Returns all listeners that are registered for the given event type or one of its subclasses.- Overrides:
getListeners
in classAbstractClientConnector
- Parameters:
eventType
- The type of event to return listeners for.- Returns:
- A collection with all registered listeners. Empty if no listeners are found.
-
containerItemSetChange
public void containerItemSetChange(Container.ItemSetChangeEvent event)
Lets the listener know a Containers Item set has changed.- Specified by:
containerItemSetChange
in interfaceContainer.ItemSetChangeListener
- Parameters:
event
- change event text- See Also:
Container.ItemSetChangeListener.containerItemSetChange(Container.ItemSetChangeEvent)
-
firePropertySetChange
protected void firePropertySetChange()
Fires the property set change event.
-
fireItemSetChange
protected void fireItemSetChange()
Fires the item set change event.
-
isEmpty
public boolean isEmpty()
For multi-selectable fields, also an empty collection of values is considered to be an empty field.
-
setNullSelectionAllowed
public void setNullSelectionAllowed(boolean nullSelectionAllowed)
Allow or disallow empty selection by the user. If the select is in single-select mode, you can make an item represent the empty selection by callingsetNullSelectionItemId()
. This way you can for instance set an icon and caption for the null selection item.- Parameters:
nullSelectionAllowed
- whether or not to allow empty selection- See Also:
setNullSelectionItemId(Object)
,isNullSelectionAllowed()
-
isNullSelectionAllowed
public boolean isNullSelectionAllowed()
Checks if null empty selection is allowed by the user.- Returns:
- whether or not empty selection is allowed
- See Also:
setNullSelectionAllowed(boolean)
-
getNullSelectionItemId
public Object getNullSelectionItemId()
Returns the item id that represents null value of this select in single select mode.Data interface does not support nulls as item ids. Selecting the item identified by this id is the same as selecting no items at all. This setting only affects the single select mode.
- Returns:
- the Object Null value item id.
- See Also:
setNullSelectionItemId(Object)
,isSelected(Object)
,select(Object)
-
setNullSelectionItemId
public void setNullSelectionItemId(Object nullSelectionItemId)
Sets the item id that represents null value of this select.Data interface does not support nulls as item ids. Selecting the item identified by this id is the same as selecting no items at all. This setting only affects the single select mode.
- Parameters:
nullSelectionItemId
- the nullSelectionItemId to set.- See Also:
getNullSelectionItemId()
,isSelected(Object)
,select(Object)
-
attach
public void attach()
Notifies the component that it is connected to an application.- Specified by:
attach
in interfaceClientConnector
- Specified by:
attach
in interfaceComponent
- Overrides:
attach
in classAbstractField<Object>
- See Also:
AbstractField.attach()
-
detach
public void detach()
Detaches the component from application.- Specified by:
detach
in interfaceClientConnector
- Overrides:
detach
in classAbstractField<Object>
- See Also:
AbstractComponent.detach()
-
getCaptionChangeListener
protected AbstractSelect.CaptionChangeListener getCaptionChangeListener()
-
readDesign
public void readDesign(org.jsoup.nodes.Element design, DesignContext context)
Description copied from interface:Component
Reads the component state from the given design.The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.
It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.
This method must not modify the design.
- Specified by:
readDesign
in interfaceComponent
- Overrides:
readDesign
in classAbstractField<Object>
- Parameters:
design
- The element to obtain the state fromcontext
- The DesignContext instance used for parsing the design
-
readItems
protected void readItems(org.jsoup.nodes.Element design, DesignContext context)
-
readItem
protected Object readItem(org.jsoup.nodes.Element child, Set<String> selected, DesignContext context)
Reads an Item from a design and inserts it into the data source. Hierarchical select components should override this method to recursively recursively read any child items as well.- Parameters:
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 parsing- Returns:
- the item id of the new item
- Throws:
DesignException
- if the tag name of thechild
element is notoption
.- Since:
- 7.5.0
-
writeDesign
public void writeDesign(org.jsoup.nodes.Element design, DesignContext context)
Description copied from interface:Component
Writes the component state to the given design.The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.
This method must not modify the component state.
- Specified by:
writeDesign
in interfaceComponent
- Overrides:
writeDesign
in classAbstractField<Object>
- Parameters:
design
- The element to write the component state to. Any previous attributes or child nodes are not cleared.context
- The DesignContext instance used for writing the design
-
writeItems
protected void writeItems(org.jsoup.nodes.Element design, DesignContext context)
Writes the data source items to a design. Hierarchical select components should override this method to only write the root items.- Parameters:
design
- the element into which to insert the itemscontext
- the DesignContext instance used in writing- Since:
- 7.5.0
-
writeItem
protected org.jsoup.nodes.Element writeItem(org.jsoup.nodes.Element design, Object itemId, DesignContext context)
Writes a data source Item to a design. Hierarchical select components should override this method to recursively write any child items as well.- Parameters:
design
- the element into which to insert the itemitemId
- the id of the item to writecontext
- the DesignContext instance used in writing- Returns:
- Since:
- 7.5.0
-
getState
protected AbstractSelectState getState()
Description copied from class:AbstractComponent
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().- Overrides:
getState
in classAbstractField<Object>
- Returns:
- updated component shared state
-
-