Package com.vaadin.event.selection
Class SingleSelectionEvent<T>
- java.lang.Object
-
- java.util.EventObject
-
- com.vaadin.data.HasValue.ValueChangeEvent<T>
-
- com.vaadin.event.selection.SingleSelectionEvent<T>
-
- Type Parameters:
T- the type of the selected item
- All Implemented Interfaces:
HasUserOriginated,SelectionEvent<T>,Serializable
public class SingleSelectionEvent<T> extends HasValue.ValueChangeEvent<T> implements SelectionEvent<T>
Fired when the selection changes in a listing component.- Since:
- 8.0
- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor Description SingleSelectionEvent(AbstractSingleSelect<T> source, T oldSelection, boolean userOriginated)Creates a new selection change event.SingleSelectionEvent(Component component, SingleSelect<T> source, T oldSelection, boolean userOriginated)Creates a new selection change event in a component.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<T>getAllSelectedItems()Gets all the currently selected items.Optional<T>getFirstSelectedItem()Get first selected data item.Optional<T>getSelectedItem()Returns an optional of the item that was selected, or an empty optional if a previously selected item was deselected.SingleSelect<T>getSource()The single select on which the Event initially occurred.-
Methods inherited from class com.vaadin.data.HasValue.ValueChangeEvent
getComponent, getOldValue, getValue, isUserOriginated
-
Methods inherited from class java.util.EventObject
toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.vaadin.event.HasUserOriginated
isUserOriginated
-
-
-
-
Constructor Detail
-
SingleSelectionEvent
public SingleSelectionEvent(AbstractSingleSelect<T> source, T oldSelection, boolean userOriginated)
Creates a new selection change event.- Parameters:
source- the listing that fired the eventoldSelection- the item that was previously selecteduserOriginated-trueif this event originates from the client,falseotherwise.
-
SingleSelectionEvent
public SingleSelectionEvent(Component component, SingleSelect<T> source, T oldSelection, boolean userOriginated)
Creates a new selection change event in a component.- Parameters:
component- the component where the event originatedsource- the single select sourceoldSelection- the item that was previously selecteduserOriginated-trueif this event originates from the client,falseotherwise.
-
-
Method Detail
-
getSelectedItem
public Optional<T> getSelectedItem()
Returns an optional of the item that was selected, or an empty optional if a previously selected item was deselected.The result is the current selection of the source
AbstractSingleSelectobject. So it's always exactly the same as optional describingAbstractSingleSelect.getValue().- Returns:
- the selected item or an empty optional if deselected
- See Also:
HasValue.ValueChangeEvent.getValue(),SelectionModel.Single#getSelectedItem()
-
getSource
public SingleSelect<T> getSource()
The single select on which the Event initially occurred.- Overrides:
getSourcein classHasValue.ValueChangeEvent<T>- Returns:
- The single select on which the Event initially occurred.
-
getFirstSelectedItem
public Optional<T> getFirstSelectedItem()
Description copied from interface:SelectionEventGet first selected data item.This is the same as
getSelectedItem()in case of single selection and the first selected item fromMultiSelectionEvent.getNewSelection()in case of multi selection.- Specified by:
getFirstSelectedItemin interfaceSelectionEvent<T>- Returns:
- the first selected item.
-
getAllSelectedItems
public Set<T> getAllSelectedItems()
Description copied from interface:SelectionEventGets all the currently selected items.This method applies more to multiselection - for single select it returns either an empty set or a set containing the only selected item.
- Specified by:
getAllSelectedItemsin interfaceSelectionEvent<T>- Returns:
- return all the selected items, if any, never
null
-
-