Class FAbstractSelect
- 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,Field<Object>,Select,Validatable,Serializable
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classThis is a listener helper for Item and Property changes that should cause a repaint.classTODO refine doc This is a default class that handles adding new items that are typed by user to selects container.static interfaceInterface for option filtering, used to filter options based on user entered value.static enumstatic interfaceImplement 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 interfaceNested classes/interfaces inherited from interface com.vaadin.featurepack.data.Buffered
Buffered.SourceExceptionNested classes/interfaces inherited from interface com.vaadin.featurepack.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.ViewerNested classes/interfaces inherited from interface com.vaadin.featurepack.data.ui.Field
Field.ValueChangeEventNested classes/interfaces inherited from interface com.vaadin.featurepack.data.Property
Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeEvent, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty Select.FAbstractSelect(com.vaadin.flow.component.Component component) FAbstractSelect(String caption) Creates an empty Select with caption.FAbstractSelect(String caption, Container dataSource) Creates a new select that is connected to a data-source.FAbstractSelect(String caption, Collection<?> options) Creates a new select that is filled from a collection of option values. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddContainerProperty(Object propertyId, Class<?> type, Object defaultValue) Adds the new property to all items.addItem()Creates a new item into container with container managed id.Create a new item into container.voidAdds given items with given item ids to container.voidaddItems(Collection<?> itemIds) Adds given items with given item ids to container.voidAdds an Item set change listener for the object.voidAdds a new Property set change listener for this Container.voidLets the listener know a Containers Item set has changed.voidNotifies this listener that the Containers contents has changed.booleancontainsId(Object itemId) Tests, if the collection contains an item with given id.protected voidFires the item set change event.protected voidFires the property set change event.protected FAbstractSelect.CaptionChangeListenerGets the viewing data-source container.getContainerProperty(Object itemId, Object propertyId) Gets the Property identified by the given itemId and propertyId from the ContainerCollection<?> Gets the property Id collection from the container.Gets the item from the container with given id.getItemCaption(Object itemId) Gets the caption of an item.Gets the item caption mode.Gets the item caption property.getItemIcon(Object itemId) Gets the item icon.Gets the item icon property.Collection<?> Gets the item Id collection from the container.Collection<?> getListeners(Class<? extends com.vaadin.flow.component.ComponentEvent> eventType) TODO refine docReturns the item id that represents null value of this select in single select mode.Class<?> getType()Returns the type of the property.Class<?> Gets the property type.getValue()Gets the selected item id or in multiselect mode a set of selected ids.Collection<?> Gets the visible item ids.booleanbooleanisEmpty()For multi-selectable fields, also an empty collection of values is considered to be an empty field.booleanIs the select in multiselect mode?booleanDoes the select allow adding new options by the user.booleanChecks if null empty selection is allowed by the user.booleanisSelected(Object itemId) Tests if an item is selected.booleanRemoves all items from the container.booleanremoveContainerProperty(Object propertyId) Removes the property from all items.booleanremoveItem(Object itemId) Removes the Item identified byItemIdfrom the Container.voidRemoves the Item set change listener from the object.voidRemoves a previously registered Property set change listener.voidChecks that the current selection is valid, i.e. the selected item ids exist in the container.voidSelects an item.voidsetComponentOverridesSetValue(boolean componentOverridesSetValue) voidsetContainerDataSource(Container newDataSource) Sets the Container that serves as the data source of the viewer.voidsetItemCaption(Object itemId, String caption) Override the caption of an item.voidSets the item caption mode.voidsetItemCaptionPropertyId(Object propertyId) Sets the item caption property.voidsetItemIcon(Object itemId, Resource icon) Sets the icon for an item.voidsetItemIconPropertyId(Object propertyId) Sets the item icon property.voidsetMultiSelect(boolean multiSelect) Sets the multiselect mode.voidsetNewItemHandler(FAbstractSelect.NewItemHandler newItemHandler) TODO refine doc Setter for new item handler that is called when user adds new item in newItemAllowed mode.voidsetNewItemsAllowed(boolean allowNewOptions) Enables or disables possibility to add new options by the user.voidsetNullSelectionAllowed(boolean nullSelectionAllowed) Allow or disallow empty selection by the user.voidsetNullSelectionItemId(Object nullSelectionItemId) Sets the item id that represents null value of this select.voidSets the visible value of the property.protected voidprotected voidSets the visible value of the property.intsize()Gets the number of items in the container.voidUnselects an item.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.featurepack.data.ui.Field
addValidator, addValueChangeListener, commit, discard, getConvertedValue, getConverter, getFAbstractField, getPropertyDataSource, getRequiredError, getValidators, isBuffered, isInvalidAllowed, isInvalidCommitted, isModified, isPropertyReadOnly, isRequired, isValid, removeAllValidators, removeValidator, removeValueChangeListener, setBuffered, setConverter, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setPropertyReadOnly, setRequired, setRequiredError, valueChangeMethods inherited from interface com.vaadin.featurepack.data.ui.Select
addReadOnlyStatusChangeListener, getFAbstractSelect, getItemIdByItem, readOnlyStatusChange, removeReadOnlyStatusChangeListener, validate
-
Field Details
-
items
Select options. -
itemIdMapper
Keymapper used to map key values.
-
-
Constructor Details
-
FAbstractSelect
public FAbstractSelect(com.vaadin.flow.component.Component component) -
FAbstractSelect
public FAbstractSelect()Creates an empty Select. The caption is not used. -
FAbstractSelect
Creates an empty Select with caption. -
FAbstractSelect
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.
-
FAbstractSelect
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 Details
-
setComponentOverridesSetValue
public void setComponentOverridesSetValue(boolean componentOverridesSetValue) -
isComponentOverridesSetValue
public boolean isComponentOverridesSetValue() -
setNewItemHandler
TODO refine doc Setter for new item handler that is called when user adds new item in newItemAllowed mode.- Parameters:
newItemHandler-
-
getNewItemHandler
TODO refine doc- Returns:
-
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
Returns the type of the property.getValueandsetValuemethods must be compatible with this type: one can safely castgetValueto given type and pass any variable assignable to this type as a parameter tosetValue. -
getValue
Gets the selected item id or in multiselect mode a set of selected ids. -
setValue
-
setValue
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.
-
setValue
protected void setValue(Object newFieldValue, boolean repaintIsNotNeeded, boolean ignoreReadOnly) throws Property.ReadOnlyException, 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.
- Parameters:
repaintIsNotNeeded- True if caller is sure that repaint is not needed.ignoreReadOnly- True if read-only check should be omitted.newValue- the New selected item or collection of selected items.- Throws:
Property.ReadOnlyExceptionConversionExceptionValidator.InvalidValueException- Since:
- 7.5.7
- See Also:
-
getItem
Gets the item from the container with given id. If the container does not contain the requested item, null is returned. -
getItemIds
Gets the item Id collection from the container.- Specified by:
getItemIdsin interfaceContainer- Specified by:
getItemIdsin interfaceSelect- Returns:
- the Collection of item ids.
-
getContainerPropertyIds
Gets the property Id collection from the container.- Specified by:
getContainerPropertyIdsin interfaceContainer- Specified by:
getContainerPropertyIdsin interfaceSelect- Returns:
- the Collection of property ids.
-
getType
Gets the property type. -
size
public int size()Gets the number of items in the container. -
containsId
Tests, if the collection contains an item with given id.- Specified by:
containsIdin interfaceContainer- Specified by:
containsIdin interfaceSelect- Parameters:
itemId- the Id the of item to be tested.- Returns:
- boolean indicating if the Container holds the specified Item
-
getContainerProperty
Gets the Property identified by the given itemId and propertyId from the Container- Specified by:
getContainerPropertyin interfaceContainer- Specified by:
getContainerPropertyin interfaceSelect- 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:
-
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:
addContainerPropertyin interfaceContainer- Specified by:
addContainerPropertyin interfaceSelect- 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:
-
removeAllItems
Removes all items from the container. This functionality is optional. If the function is unsupported, it always returns false.- Specified by:
removeAllItemsin interfaceContainer- Specified by:
removeAllItemsin interfaceSelect- Returns:
- True if the operation succeeded.
- Throws:
UnsupportedOperationException- if the container does not support removing all items- See Also:
-
addItem
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:
addItemin interfaceContainer- Specified by:
addItemin interfaceSelect- 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:
-
addItem
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:
addItemin interfaceContainer- Specified by:
addItemin interfaceSelect- 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:
-
addItems
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
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
Description copied from interface:ContainerRemoves the Item identified byItemIdfrom the Container.Containers that support filtering should also allow removing an item that is currently filtered out.
This functionality is optional.
- Specified by:
removeItemin interfaceContainer- Specified by:
removeItemin interfaceSelect- Parameters:
itemId- ID of the Item to remove- Returns:
trueif the operation succeeded,falseif 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
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:
removeContainerPropertyin interfaceContainer- Specified by:
removeContainerPropertyin interfaceSelect- Parameters:
propertyId- ID of the Property to remove- Returns:
- True if the operation succeeded.
- See Also:
-
setContainerDataSource
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:
setContainerDataSourcein interfaceContainer.Viewer- Specified by:
setContainerDataSourcein interfaceSelect- Parameters:
newDataSource- the new data source.- See Also:
-
getContainerDataSource
Gets the viewing data-source container.- Specified by:
getContainerDataSourcein interfaceContainer.Viewer- Specified by:
getContainerDataSourcein interfaceSelect- Returns:
- data source Container
- See Also:
-
isMultiSelect
public boolean isMultiSelect()Is the select in multiselect mode? In multiselect mode- Specified by:
isMultiSelectin interfaceSelect- 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.- Specified by:
setMultiSelectin interfaceSelect- 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.- Specified by:
isNewItemsAllowedin interfaceSelect- Returns:
- True if additions are allowed.
-
setNewItemsAllowed
public void setNewItemsAllowed(boolean allowNewOptions) Enables or disables possibility to add new options by the user.- Specified by:
setNewItemsAllowedin interfaceSelect- Parameters:
allowNewOptions- the New value of property allowNewOptions.
-
setItemCaption
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
Gets the caption of an item. The caption is generated as specified by the item caption mode. SeesetItemCaptionMode()for more details.- Specified by:
getItemCaptionin interfaceSelect- Parameters:
itemId- the id of the item to be queried.- Returns:
- the caption for specified item.
-
setItemIcon
Sets the icon for an item.- Specified by:
setItemIconin interfaceSelect- Parameters:
itemId- the id of the item to be assigned an icon.icon- the icon to use or null.
-
getItemIcon
Gets the item icon.- Specified by:
getItemIconin interfaceSelect- Parameters:
itemId- the id of the item to be assigned an icon.- Returns:
- the icon for the item or null, if not specified.
-
setItemCaptionMode
Sets the item caption mode. SeeFAbstractSelect.ItemCaptionModefor a description of the modes.FAbstractSelect.ItemCaptionMode.EXPLICIT_DEFAULTS_IDis the default mode.- Specified by:
setItemCaptionModein interfaceSelect- Parameters:
mode- the One of the modes listed above.
-
getItemCaptionMode
Gets the item caption mode.The mode can be one of the following ones:
ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID: Items Id-objectstoStringis used as item caption. If caption is explicitly specified, it overrides the id-caption.ITEM_CAPTION_MODE_ID: Items Id-objectstoStringis used as item caption.ITEM_CAPTION_MODE_ITEM: Item-objectstoStringis 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.Indexedinterface.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_IDis the default mode.- Specified by:
getItemCaptionModein interfaceSelect- Returns:
- the One of the modes listed above.
-
setItemCaptionPropertyId
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_PROPERTYmode, 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
.- Specified by:
setItemCaptionPropertyIdin interfaceSelect- Parameters:
propertyId- the id of the property.
-
getItemCaptionPropertyId
Gets the item caption property.- Specified by:
getItemCaptionPropertyIdin interfaceSelect- Returns:
- the Id of the property used as item caption source.
-
setItemIconPropertyId
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
setItemIconfunction override the icons from the property.Setting the property id to null disables this feature. The id is null by default
.- Specified by:
setItemIconPropertyIdin interfaceSelect- 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
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
setItemIconfunction override the icons from the property.Setting the property id to null disables this feature. The id is null by default
.- Specified by:
getItemIconPropertyIdin interfaceSelect- Returns:
- the Id of the property containing the item icons.
-
isSelected
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:
-
select
Selects an item.In single select mode selecting item identified by
getNullSelectionItemId()sets the value of the property to null. -
unselect
Unselects an item.- Parameters:
itemId- the identifier of the Item to be unselected.- See Also:
-
containerPropertySetChange
Notifies this listener that the Containers contents has changed.- Specified by:
containerPropertySetChangein interfaceContainer.PropertySetChangeListener- Specified by:
containerPropertySetChangein interfaceSelect- Parameters:
event- Change event.- See Also:
-
addPropertySetChangeListener
Adds a new Property set change listener for this Container.- Specified by:
addPropertySetChangeListenerin interfaceContainer.PropertySetChangeNotifier- Specified by:
addPropertySetChangeListenerin interfaceSelect- Parameters:
listener- The new Listener to be registered- See Also:
-
removePropertySetChangeListener
Removes a previously registered Property set change listener.- Specified by:
removePropertySetChangeListenerin interfaceContainer.PropertySetChangeNotifier- Specified by:
removePropertySetChangeListenerin interfaceSelect- Parameters:
listener- Listener to be removed- See Also:
-
addItemSetChangeListener
Adds an Item set change listener for the object.- Specified by:
addItemSetChangeListenerin interfaceContainer.ItemSetChangeNotifier- Specified by:
addItemSetChangeListenerin interfaceSelect- Parameters:
listener- listener to be added- See Also:
-
removeItemSetChangeListener
Removes the Item set change listener from the object.- Specified by:
removeItemSetChangeListenerin interfaceContainer.ItemSetChangeNotifier- Specified by:
removeItemSetChangeListenerin interfaceSelect- Parameters:
listener- listener to be removed- See Also:
-
getListeners
public Collection<?> getListeners(Class<? extends com.vaadin.flow.component.ComponentEvent> eventType) -
containerItemSetChange
Lets the listener know a Containers Item set has changed.- Specified by:
containerItemSetChangein interfaceContainer.ItemSetChangeListener- Specified by:
containerItemSetChangein interfaceSelect- Parameters:
event- change event text- See Also:
-
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.- Specified by:
setNullSelectionAllowedin interfaceSelect- Parameters:
nullSelectionAllowed- whether or not to allow empty selection- See Also:
-
isNullSelectionAllowed
public boolean isNullSelectionAllowed()Checks if null empty selection is allowed by the user.- Specified by:
isNullSelectionAllowedin interfaceSelect- Returns:
- whether or not empty selection is allowed
- See Also:
-
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.
- Specified by:
getNullSelectionItemIdin interfaceSelect- Returns:
- the Object Null value item id.
- See Also:
-
setNullSelectionItemId
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.
- Specified by:
setNullSelectionItemIdin interfaceSelect- Parameters:
nullSelectionItemId- the nullSelectionItemId to set.- See Also:
-
getCaptionChangeListener
-