T - the bean type of gridpublic class GridMultiSelect<T> extends Object implements MultiSelect<T>
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<V>| Constructor and Description |
|---|
GridMultiSelect(Grid<T> grid)
Constructs a MultiSelect wrapper for given Grid.
|
| Modifier and Type | Method and Description |
|---|---|
Registration |
addMultiSelectionListener(MultiSelectionListener<T> listener)
Adds a selection listener that will be called when the selection is
changed either by the user or programmatically.
|
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 |
addSelectionListener(SelectionListener<T> listener)
Adds a generic listener to this selection model, accepting both single
and multiselection events.
|
Registration |
addValueChangeListener(HasValue.ValueChangeListener<Set<T>> listener)
Adds a value change listener.
|
void |
deselect(T item)
Selects the given item.
|
void |
deselectAll()
Deselects all currently selected items, if any.
|
void |
deselectItems(T... items)
Removes the given items from the set of currently selected items.
|
Optional<T> |
getFirstSelectedItem()
Get first selected data item.
|
MultiSelectionModel.SelectAllCheckBoxVisibility |
getSelectAllCheckBoxVisibility()
Gets the current mode for the select all checkbox visibility.
|
Set<T> |
getSelectedItems()
Returns an immutable set of the currently selected items.
|
Set<T> |
getValue()
Returns the current value of this object.
|
boolean |
isReadOnly()
Returns whether this
HasValue is in read-only mode or not. |
boolean |
isRequiredIndicatorVisible()
Checks whether the required indicator is visible.
|
boolean |
isSelectAllCheckBoxVisible()
Returns whether the select all checkbox will be visible with the current
setting of
#setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility). |
boolean |
isUserSelectionAllowed()
Checks if the user is allowed to change the selection.
|
void |
select(T item)
Selects the given item.
|
void |
selectAll()
Selects all available the items.
|
void |
selectItems(T... items)
Adds the given items to the set of currently selected items.
|
void |
setReadOnly(boolean readOnly)
Sets the read-only mode of this
HasValue to given mode. |
void |
setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
Sets the required indicator visible or not.
|
void |
setSelectAllCheckBoxVisibility(MultiSelectionModel.SelectAllCheckBoxVisibility visibility)
Sets the select all checkbox visibility mode.
|
void |
setUserSelectionAllowed(boolean allowed)
Sets whether the user is allowed to change the selection.
|
void |
setValue(Set<T> value)
Sets the value of this object.
|
void |
updateSelection(Set<T> addedItems,
Set<T> removedItems)
Updates the selection by adding and removing the given items from it.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdeselect, getEmptyValue, isSelected, selectclear, getDefaultValidator, getOptionalValue, isEmptypublic Optional<T> getFirstSelectedItem()
public void selectAll()
public void deselect(T item)
item - the item to select, not nullpublic void select(T item)
item - the item to selectpublic void deselectAll()
deselectAll in interface MultiSelect<T>public void selectItems(T... items)
By default this does not clear any previous selection. To do that, use
deselectAll().
If the all the items were already selected, this is a NO-OP.
This is a short-hand for updateSelection(Set, Set) with nothing
to deselect.
items - to add to selection, not nullpublic void deselectItems(T... items)
If the none of the items were selected, this is a NO-OP.
This is a short-hand for updateSelection(Set, Set) with nothing
to select.
items - to remove from selection, not nullpublic void setSelectAllCheckBoxVisibility(MultiSelectionModel.SelectAllCheckBoxVisibility visibility)
The default value is MultiSelectionModel.SelectAllCheckBoxVisibility.DEFAULT, which
means that the checkbox is only visible if the grid's data provider is
in- memory.
visibility - the visiblity mode to useMultiSelectionModel.SelectAllCheckBoxVisibilitypublic MultiSelectionModel.SelectAllCheckBoxVisibility getSelectAllCheckBoxVisibility()
MultiSelectionModel.SelectAllCheckBoxVisibility,
isSelectAllCheckBoxVisible()public boolean isSelectAllCheckBoxVisible()
#setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility).true if the checkbox will be visible with the current
settingsMultiSelectionModel.SelectAllCheckBoxVisibility,
#setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility)public void setUserSelectionAllowed(boolean allowed)
The check is done only for the client side actions. It doesn't affect selection requests sent from the server side.
allowed - true if the user is allowed to change the
selection, false otherwisepublic boolean isUserSelectionAllowed()
The check is done only for the client side actions. It doesn't affect selection requests sent from the server side.
true if the user is allowed to change the selection,
false otherwisepublic Registration addSelectionListener(SelectionListener<T> listener)
listener - the listener to addpublic Registration addMultiSelectionListener(MultiSelectionListener<T> listener)
listener - the value change listener, not nullpublic void setValue(Set<T> value)
HasValuegetValue(), fires a value change event. May throw
IllegalArgumentException if the value is not acceptable.
Implementation note: the implementing class should document whether null values are accepted or not.
public Set<T> getValue()
HasValueImplementation note: the implementing class should document whether null values may be returned or not.
public Registration addValueChangeListener(HasValue.ValueChangeListener<Set<T>> listener)
HasValueHasValue is changed either by the user or programmatically.addValueChangeListener in interface HasValue<Set<T>>listener - the value change listener, not nullpublic void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
HasValueIf set visible, it is visually indicated in the user interface.
setRequiredIndicatorVisible in interface HasValue<Set<T>>requiredIndicatorVisible - true to make the required indicator visible,
false if notpublic boolean isRequiredIndicatorVisible()
HasValueisRequiredIndicatorVisible in interface HasValue<Set<T>>true if visible, false if notpublic void setReadOnly(boolean readOnly)
HasValueHasValue to given mode. The user
can't change the value when in read-only mode.
A HasValue with a visual component in read-only mode typically
looks visually different to signal to the user that the value cannot be
edited.
setReadOnly in interface HasValue<Set<T>>readOnly - a boolean value specifying whether the component is put
read-only mode or notpublic boolean isReadOnly()
HasValueHasValue is in read-only mode or not.isReadOnly in interface HasValue<Set<T>>false if the user can modify the value, true if
not.public void updateSelection(Set<T> addedItems, Set<T> removedItems)
MultiSelectIf 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 nullremovedItems - the items to remove, not nullpublic Set<T> getSelectedItems()
MultiSelectSelectionModel 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 Registration addSelectionListener(MultiSelectionListener<T> listener)
MultiSelectaddSelectionListener in interface MultiSelect<T>listener - the value change listener, not nullCopyright © 2019 Vaadin Ltd. All rights reserved.