T
- the data type of records in the listpublic class DefaultSelectionEventManager<T> extends java.lang.Object implements CellPreviewEvent.Handler<T>
CellPreviewEvent.Handler
that adds selection
support via the spacebar and mouse clicks and handles the control key.
If the HasData
source of the selection event uses a
MultiSelectionModel
, this manager additionally provides support for
shift key to select a range of values. For all other SelectionModel
s,
only the control key is supported.
Modifier and Type | Class and Description |
---|---|
static class |
DefaultSelectionEventManager.BlacklistEventTranslator<T>
An event translator that disables selection for the specified blacklisted
columns.
|
static class |
DefaultSelectionEventManager.CheckboxEventTranslator<T>
Implementation of
DefaultSelectionEventManager.EventTranslator that only triggers selection when
any checkbox is selected. |
static interface |
DefaultSelectionEventManager.EventTranslator<T>
Translates
CellPreviewEvent s into DefaultSelectionEventManager.SelectAction s. |
static class |
DefaultSelectionEventManager.SelectAction
The action that controls how selection is handled.
|
static class |
DefaultSelectionEventManager.WhitelistEventTranslator<T>
An event translator that allows selection only for the specified
whitelisted columns.
|
Modifier | Constructor and Description |
---|---|
protected |
DefaultSelectionEventManager(DefaultSelectionEventManager.EventTranslator<T> translator)
Construct a new
DefaultSelectionEventManager using the specified
DefaultSelectionEventManager.EventTranslator to control which DefaultSelectionEventManager.SelectAction to take for
each event. |
Modifier and Type | Method and Description |
---|---|
protected void |
clearSelection(MultiSelectionModel<? super T> selectionModel)
Removes all items from the selection.
|
static <T> DefaultSelectionEventManager<T> |
createBlacklistManager(int... blacklistedColumns)
Construct a new
DefaultSelectionEventManager that ignores selection
for the columns in the specified blacklist. |
static <T> DefaultSelectionEventManager<T> |
createCheckboxManager()
Construct a new
DefaultSelectionEventManager that triggers
selection when any checkbox in any column is clicked. |
static <T> DefaultSelectionEventManager<T> |
createCheckboxManager(int column)
Construct a new
DefaultSelectionEventManager that triggers
selection when a checkbox in the specified column is clicked. |
static <T> DefaultSelectionEventManager<T> |
createCustomManager(DefaultSelectionEventManager.EventTranslator<T> translator)
Create a new
DefaultSelectionEventManager using the specified
DefaultSelectionEventManager.EventTranslator to control which DefaultSelectionEventManager.SelectAction to take for
each event. |
static <T> DefaultSelectionEventManager<T> |
createDefaultManager()
Create a new
DefaultSelectionEventManager that handles selection
via user interactions. |
static <T> DefaultSelectionEventManager<T> |
createWhitelistManager(int... whitelistedColumns)
Construct a new
DefaultSelectionEventManager that allows selection
only for the columns in the specified whitelist. |
void |
doMultiSelection(MultiSelectionModel<? super T> selectionModel,
HasData<T> display,
int row,
T rowValue,
DefaultSelectionEventManager.SelectAction action,
boolean selectRange,
boolean clearOthers)
Update the selection model based on a user selection event.
|
protected void |
handleMultiSelectionEvent(CellPreviewEvent<T> event,
DefaultSelectionEventManager.SelectAction action,
MultiSelectionModel<? super T> selectionModel)
Handle an event that could cause a value to be selected for a
MultiSelectionModel . |
protected void |
handleSelectionEvent(CellPreviewEvent<T> event,
DefaultSelectionEventManager.SelectAction action,
SelectionModel<? super T> selectionModel)
Handle an event that could cause a value to be selected.
|
void |
onCellPreview(CellPreviewEvent<T> event)
Called when
CellPreviewEvent is fired. |
protected void |
selectOne(MultiSelectionModel<? super T> selectionModel,
T target,
boolean selected,
boolean clearOthers)
Selects the given item, optionally clearing any prior selection.
|
protected void |
setRangeSelection(MultiSelectionModel<? super T> selectionModel,
HasData<T> display,
Range range,
boolean addToSelection,
boolean clearOthers)
Select or deselect a range of row indexes, optionally deselecting all other
values.
|
protected DefaultSelectionEventManager(DefaultSelectionEventManager.EventTranslator<T> translator)
DefaultSelectionEventManager
using the specified
DefaultSelectionEventManager.EventTranslator
to control which DefaultSelectionEventManager.SelectAction
to take for
each event.translator
- the DefaultSelectionEventManager.EventTranslator
to usepublic static <T> DefaultSelectionEventManager<T> createBlacklistManager(int... blacklistedColumns)
DefaultSelectionEventManager
that ignores selection
for the columns in the specified blacklist.T
- the data type of the displayblacklistedColumns
- the columns to include in the blacklistDefaultSelectionEventManager
instancepublic static <T> DefaultSelectionEventManager<T> createCheckboxManager()
DefaultSelectionEventManager
that triggers
selection when any checkbox in any column is clicked.T
- the data type of the displayDefaultSelectionEventManager
instancepublic static <T> DefaultSelectionEventManager<T> createCheckboxManager(int column)
DefaultSelectionEventManager
that triggers
selection when a checkbox in the specified column is clicked.T
- the data type of the displaycolumn
- the column to handleDefaultSelectionEventManager
instancepublic static <T> DefaultSelectionEventManager<T> createCustomManager(DefaultSelectionEventManager.EventTranslator<T> translator)
DefaultSelectionEventManager
using the specified
DefaultSelectionEventManager.EventTranslator
to control which DefaultSelectionEventManager.SelectAction
to take for
each event.T
- the data type of the displaytranslator
- the DefaultSelectionEventManager.EventTranslator
to useDefaultSelectionEventManager
instancepublic static <T> DefaultSelectionEventManager<T> createDefaultManager()
DefaultSelectionEventManager
that handles selection
via user interactions.T
- the data type of the displayDefaultSelectionEventManager
instancepublic static <T> DefaultSelectionEventManager<T> createWhitelistManager(int... whitelistedColumns)
DefaultSelectionEventManager
that allows selection
only for the columns in the specified whitelist.T
- the data type of the displaywhitelistedColumns
- the columns to include in the whitelistDefaultSelectionEventManager
instancepublic void doMultiSelection(MultiSelectionModel<? super T> selectionModel, HasData<T> display, int row, T rowValue, DefaultSelectionEventManager.SelectAction action, boolean selectRange, boolean clearOthers)
selectionModel
- the selection model to updaterow
- the absolute index of the selected rowrowValue
- the selected row valueaction
- the DefaultSelectionEventManager.SelectAction
to applyselectRange
- true to select the range from the last selected rowclearOthers
- true to clear the current selectionpublic void onCellPreview(CellPreviewEvent<T> event)
CellPreviewEvent.Handler
CellPreviewEvent
is fired.onCellPreview
in interface CellPreviewEvent.Handler<T>
event
- the CellPreviewEvent
that was firedprotected void clearSelection(MultiSelectionModel<? super T> selectionModel)
selectionModel
- the MultiSelectionModel
to clearprotected void handleMultiSelectionEvent(CellPreviewEvent<T> event, DefaultSelectionEventManager.SelectAction action, MultiSelectionModel<? super T> selectionModel)
MultiSelectionModel
. This overloaded method adds support for both
the control and shift keys. If the shift key is held down, all rows between
the previous selected row and the current row are selected.event
- the CellPreviewEvent
that triggered selectionaction
- the action to handleselectionModel
- the SelectionModel
to updateprotected void handleSelectionEvent(CellPreviewEvent<T> event, DefaultSelectionEventManager.SelectAction action, SelectionModel<? super T> selectionModel)
SelectionModel
. Pressing the space bar or ctrl+click will
toggle the selection state. Clicking selects the row if it is not selected.event
- the CellPreviewEvent
that triggered selectionaction
- the action to handleselectionModel
- the SelectionModel
to updateprotected void selectOne(MultiSelectionModel<? super T> selectionModel, T target, boolean selected, boolean clearOthers)
selectionModel
- the MultiSelectionModel
to updatetarget
- the item to selectselected
- true to select, false to deselectclearOthers
- true to clear all other selected itemsprotected void setRangeSelection(MultiSelectionModel<? super T> selectionModel, HasData<T> display, Range range, boolean addToSelection, boolean clearOthers)
selectionModel
- the MultiSelectionModel
to updatedisplay
- the HasData
source of the selection eventrange
- the Range
of rows to select or deselectaddToSelection
- true to select, false to deselect the rangeclearOthers
- true to deselect rows not in the range