T
- the grid typepublic abstract class AbstractGridMultiSelectionModel<T> extends Grid.AbstractGridExtension<T> implements GridMultiSelectionModel<T>
GridMultiSelectionModel.SelectAllCheckboxVisibility
SelectionModel.Multi<C extends Component,T>, SelectionModel.Single<C extends Component,T>
Constructor and Description |
---|
AbstractGridMultiSelectionModel(Grid<T> grid)
Constructor for passing a reference of the grid to this implementation.
|
Modifier and Type | Method and Description |
---|---|
Registration |
addMultiSelectionListener(MultiSelectionListener<Grid<T>,T> listener)
Adds a selection listener that will be called when the selection is
changed either by the user or programmatically.
|
Registration |
addSelectionListener(SelectionListener<Grid<T>,T> listener)
Adds a generic listener to this selection model, accepting both single
and multiselection events.
|
MultiSelect<Grid<T>,T> |
asMultiSelect()
Gets a wrapper to use this multiselection model as a multiselect in
Binder . |
void |
deselect(T item)
Deselects the given item.
|
void |
deselectAll()
Deselects all currently selected items, if any.
|
void |
deselectFromClient(T item)
Handles the deselection of an item that originates from the client.
|
protected abstract void |
fireSelectionEvent(SelectionEvent<Grid<T>,T> event)
Method for handling the firing of selection events.
|
void |
generateData(T item,
elemental.json.JsonObject jsonObject)
Adds custom data for the given item to its serialized
JsonObject
representation. |
Optional<T> |
getFirstSelectedItem()
Get first selected data item.
|
GridMultiSelectionModel.SelectAllCheckboxVisibility |
getSelectAllCheckboxVisibility()
Gets the current mode for the select all checkbox visibility.
|
Set<T> |
getSelectedItems()
Returns an immutable set of the currently selected items.
|
boolean |
isSelectAllCheckboxVisible()
Returns whether the select all checkbox will be visible with the current
setting of
GridMultiSelectionModel.setSelectAllCheckboxVisibility(SelectAllCheckboxVisibility) and
the type of data set to the Grid (in-memory or lazy). |
boolean |
isSelected(T item)
Returns whether the given item is currently selected.
|
boolean |
isSelectionColumnFrozen()
Gets the the selection column's frozen state.
|
protected void |
remove()
Remove this extension from its target.
|
void |
select(T item)
Selects the given item.
|
void |
selectAll()
Selects all available the items.
|
void |
selectFromClient(T item)
Handles the selection of an item that originates from the client.
|
void |
setSelectAllCheckboxVisibility(GridMultiSelectionModel.SelectAllCheckboxVisibility selectAllCheckBoxVisibility)
Sets the select all checkbox visibility mode.
|
void |
setSelectionColumnFrozen(boolean frozen)
Sets the selection column's frozen state.
|
void |
updateSelection(Set<T> addedItems,
Set<T> removedItems)
Updates the selection by adding and removing the given items from it.
|
extend, getGrid, refresh
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
deselectItems, selectItems
destroyAllData, destroyData, refreshData
protected void remove()
Grid.AbstractGridExtension
remove
in class Grid.AbstractGridExtension<T>
public void selectFromClient(T item)
GridSelectionModel
selectFromClient
in interface GridSelectionModel<T>
item
- the item being selectedpublic void deselectFromClient(T item)
GridSelectionModel
deselectFromClient
in interface GridSelectionModel<T>
item
- the item beign deselectedpublic Set<T> getSelectedItems()
SelectionModel
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 SelectionModel<Grid<T>,T>
public Optional<T> getFirstSelectedItem()
SelectionModel
This is the same as SelectionModel.Single.getSelectedItem()
in case of single
selection and the first selected item from
SelectionModel.getSelectedItems()
in case of multiselection.
getFirstSelectedItem
in interface SelectionModel<Grid<T>,T>
getFirstSelectedItem
in interface SelectionModel.Multi<Grid<T>,T>
public void select(T item)
SelectionModel
select
in interface SelectionModel<Grid<T>,T>
select
in interface SelectionModel.Multi<Grid<T>,T>
item
- the item to select, not nullpublic void deselect(T item)
SelectionModel
deselect
in interface SelectionModel<Grid<T>,T>
deselect
in interface SelectionModel.Multi<Grid<T>,T>
item
- the item to deselect, not nullpublic void selectAll()
SelectionModel.Multi
selectAll
in interface SelectionModel.Multi<Grid<T>,T>
public void deselectAll()
SelectionModel
deselectAll
in interface SelectionModel<Grid<T>,T>
public void updateSelection(Set<T> addedItems, Set<T> removedItems)
SelectionModel.Multi
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 SelectionModel.Multi<Grid<T>,T>
addedItems
- the items to add, not null
removedItems
- the items to remove, not null
public boolean isSelected(T item)
SelectionModel
isSelected
in interface SelectionModel<Grid<T>,T>
item
- the item to check, not nulltrue
if the item is selected, false
otherwisepublic MultiSelect<Grid<T>,T> asMultiSelect()
GridMultiSelectionModel
Binder
.asMultiSelect
in interface GridMultiSelectionModel<T>
public Registration addSelectionListener(SelectionListener<Grid<T>,T> listener)
SelectionModel
addSelectionListener
in interface SelectionModel<Grid<T>,T>
listener
- the listener to add, not null
public Registration addMultiSelectionListener(MultiSelectionListener<Grid<T>,T> listener)
GridMultiSelectionModel
addMultiSelectionListener
in interface GridMultiSelectionModel<T>
listener
- the multi selection listener, not null
public void setSelectAllCheckboxVisibility(GridMultiSelectionModel.SelectAllCheckboxVisibility selectAllCheckBoxVisibility)
GridMultiSelectionModel
The default value is GridMultiSelectionModel.SelectAllCheckboxVisibility.DEFAULT
, which
means that the checkbox is only visible if the grid's data provider is
in-memory.
The select all checkbox will never be shown if the Grid uses lazy loading
with unknown item count, i.e. no items count query provided to it, and
even setting GridMultiSelectionModel.SelectAllCheckboxVisibility.VISIBLE
won't make it
visible.
setSelectAllCheckboxVisibility
in interface GridMultiSelectionModel<T>
selectAllCheckBoxVisibility
- the visiblity mode to useGridMultiSelectionModel.SelectAllCheckboxVisibility
public GridMultiSelectionModel.SelectAllCheckboxVisibility getSelectAllCheckboxVisibility()
GridMultiSelectionModel
getSelectAllCheckboxVisibility
in interface GridMultiSelectionModel<T>
GridMultiSelectionModel.SelectAllCheckboxVisibility
,
GridMultiSelectionModel.isSelectAllCheckboxVisible()
public boolean isSelectAllCheckboxVisible()
GridMultiSelectionModel
GridMultiSelectionModel.setSelectAllCheckboxVisibility(SelectAllCheckboxVisibility)
and
the type of data set to the Grid (in-memory or lazy).
The select all checkbox will never be shown if the Grid uses lazy loading with unknown item count, meaning that no count callback has been provided.
isSelectAllCheckboxVisible
in interface GridMultiSelectionModel<T>
true
if the checkbox will be visible with the current
settingsGridMultiSelectionModel.SelectAllCheckboxVisibility
,
GridMultiSelectionModel.setSelectAllCheckboxVisibility(SelectAllCheckboxVisibility)
public void generateData(T item, elemental.json.JsonObject jsonObject)
DataGenerator
JsonObject
representation. This JSON object will be sent to client-side
DataProvider.generateData
in interface DataGenerator<T>
item
- the data item being serializedjsonObject
- the JSON object being sent to the clientpublic void setSelectionColumnFrozen(boolean frozen)
GridMultiSelectionModel
setSelectionColumnFrozen
in interface GridMultiSelectionModel<T>
frozen
- whether to freeze or unfreeze the selection columnpublic boolean isSelectionColumnFrozen()
GridMultiSelectionModel
isSelectionColumnFrozen
in interface GridMultiSelectionModel<T>
protected abstract void fireSelectionEvent(SelectionEvent<Grid<T>,T> event)
event
- the selection event to fireCopyright © 2020. All rights reserved.