Package com.google.gwt.view.client
Class DefaultSelectionEventManager<T>
java.lang.Object
com.google.gwt.view.client.DefaultSelectionEventManager<T>
- Type Parameters:
T
- the data type of records in the list
- All Implemented Interfaces:
EventHandler
,CellPreviewEvent.Handler<T>
An implementation of
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An event translator that disables selection for the specified blacklisted columns.static class
Implementation ofDefaultSelectionEventManager.EventTranslator
that only triggers selection when any checkbox is selected.static interface
TranslatesCellPreviewEvent
s intoDefaultSelectionEventManager.SelectAction
s.static enum
The action that controls how selection is handled.static class
An event translator that allows selection only for the specified whitelisted columns. -
Constructor Summary
ModifierConstructorDescriptionprotected
Construct a newDefaultSelectionEventManager
using the specifiedDefaultSelectionEventManager.EventTranslator
to control whichDefaultSelectionEventManager.SelectAction
to take for each event. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
clearSelection
(MultiSelectionModel<? super T> selectionModel) Removes all items from the selection.static <T> DefaultSelectionEventManager
<T> createBlacklistManager
(int... blacklistedColumns) Construct a newDefaultSelectionEventManager
that ignores selection for the columns in the specified blacklist.static <T> DefaultSelectionEventManager
<T> Construct a newDefaultSelectionEventManager
that triggers selection when any checkbox in any column is clicked.static <T> DefaultSelectionEventManager
<T> createCheckboxManager
(int column) Construct a newDefaultSelectionEventManager
that triggers selection when a checkbox in the specified column is clicked.static <T> DefaultSelectionEventManager
<T> createCustomManager
(DefaultSelectionEventManager.EventTranslator<T> translator) Create a newDefaultSelectionEventManager
using the specifiedDefaultSelectionEventManager.EventTranslator
to control whichDefaultSelectionEventManager.SelectAction
to take for each event.static <T> DefaultSelectionEventManager
<T> Create a newDefaultSelectionEventManager
that handles selection via user interactions.static <T> DefaultSelectionEventManager
<T> createWhitelistManager
(int... whitelistedColumns) Construct a newDefaultSelectionEventManager
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 aMultiSelectionModel
.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 whenCellPreviewEvent
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.
-
Constructor Details
-
DefaultSelectionEventManager
Construct a newDefaultSelectionEventManager
using the specifiedDefaultSelectionEventManager.EventTranslator
to control whichDefaultSelectionEventManager.SelectAction
to take for each event.- Parameters:
translator
- theDefaultSelectionEventManager.EventTranslator
to use
-
-
Method Details
-
createBlacklistManager
Construct a newDefaultSelectionEventManager
that ignores selection for the columns in the specified blacklist.- Type Parameters:
T
- the data type of the display- Parameters:
blacklistedColumns
- the columns to include in the blacklist- Returns:
- a
DefaultSelectionEventManager
instance
-
createCheckboxManager
Construct a newDefaultSelectionEventManager
that triggers selection when any checkbox in any column is clicked.- Type Parameters:
T
- the data type of the display- Returns:
- a
DefaultSelectionEventManager
instance
-
createCheckboxManager
Construct a newDefaultSelectionEventManager
that triggers selection when a checkbox in the specified column is clicked.- Type Parameters:
T
- the data type of the display- Parameters:
column
- the column to handle- Returns:
- a
DefaultSelectionEventManager
instance
-
createCustomManager
public static <T> DefaultSelectionEventManager<T> createCustomManager(DefaultSelectionEventManager.EventTranslator<T> translator) Create a newDefaultSelectionEventManager
using the specifiedDefaultSelectionEventManager.EventTranslator
to control whichDefaultSelectionEventManager.SelectAction
to take for each event.- Type Parameters:
T
- the data type of the display- Parameters:
translator
- theDefaultSelectionEventManager.EventTranslator
to use- Returns:
- a
DefaultSelectionEventManager
instance
-
createDefaultManager
Create a newDefaultSelectionEventManager
that handles selection via user interactions.- Type Parameters:
T
- the data type of the display- Returns:
- a new
DefaultSelectionEventManager
instance
-
createWhitelistManager
Construct a newDefaultSelectionEventManager
that allows selection only for the columns in the specified whitelist.- Type Parameters:
T
- the data type of the display- Parameters:
whitelistedColumns
- the columns to include in the whitelist- Returns:
- a
DefaultSelectionEventManager
instance
-
doMultiSelection
public 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.- Parameters:
selectionModel
- the selection model to updaterow
- the absolute index of the selected rowrowValue
- the selected row valueaction
- theDefaultSelectionEventManager.SelectAction
to applyselectRange
- true to select the range from the last selected rowclearOthers
- true to clear the current selection
-
onCellPreview
Description copied from interface:CellPreviewEvent.Handler
Called whenCellPreviewEvent
is fired.- Specified by:
onCellPreview
in interfaceCellPreviewEvent.Handler<T>
- Parameters:
event
- theCellPreviewEvent
that was fired
-
clearSelection
Removes all items from the selection.- Parameters:
selectionModel
- theMultiSelectionModel
to clear
-
handleMultiSelectionEvent
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 aMultiSelectionModel
. 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.- Parameters:
event
- theCellPreviewEvent
that triggered selectionaction
- the action to handleselectionModel
- theSelectionModel
to update
-
handleSelectionEvent
protected void handleSelectionEvent(CellPreviewEvent<T> event, DefaultSelectionEventManager.SelectAction action, SelectionModel<? super T> selectionModel) Handle an event that could cause a value to be selected. This method works for anySelectionModel
. Pressing the space bar or ctrl+click will toggle the selection state. Clicking selects the row if it is not selected.- Parameters:
event
- theCellPreviewEvent
that triggered selectionaction
- the action to handleselectionModel
- theSelectionModel
to update
-
selectOne
protected void selectOne(MultiSelectionModel<? super T> selectionModel, T target, boolean selected, boolean clearOthers) Selects the given item, optionally clearing any prior selection.- Parameters:
selectionModel
- theMultiSelectionModel
to updatetarget
- the item to selectselected
- true to select, false to deselectclearOthers
- true to clear all other selected items
-
setRangeSelection
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.- Parameters:
selectionModel
- theMultiSelectionModel
to updatedisplay
- theHasData
source of the selection eventrange
- theRange
of rows to select or deselectaddToSelection
- true to select, false to deselect the rangeclearOthers
- true to deselect rows not in the range
-