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 SelectionModels,
only the control key is supported.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn event translator that disables selection for the specified blacklisted columns.static classImplementation ofDefaultSelectionEventManager.EventTranslatorthat only triggers selection when any checkbox is selected.static interfaceTranslatesCellPreviewEvents intoDefaultSelectionEventManager.SelectActions.static enumThe action that controls how selection is handled.static classAn event translator that allows selection only for the specified whitelisted columns. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstruct a newDefaultSelectionEventManagerusing the specifiedDefaultSelectionEventManager.EventTranslatorto control whichDefaultSelectionEventManager.SelectActionto take for each event. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclearSelection(MultiSelectionModel<? super T> selectionModel) Removes all items from the selection.static <T> DefaultSelectionEventManager<T> createBlacklistManager(int... blacklistedColumns) Construct a newDefaultSelectionEventManagerthat ignores selection for the columns in the specified blacklist.static <T> DefaultSelectionEventManager<T> Construct a newDefaultSelectionEventManagerthat triggers selection when any checkbox in any column is clicked.static <T> DefaultSelectionEventManager<T> createCheckboxManager(int column) Construct a newDefaultSelectionEventManagerthat triggers selection when a checkbox in the specified column is clicked.static <T> DefaultSelectionEventManager<T> createCustomManager(DefaultSelectionEventManager.EventTranslator<T> translator) Create a newDefaultSelectionEventManagerusing the specifiedDefaultSelectionEventManager.EventTranslatorto control whichDefaultSelectionEventManager.SelectActionto take for each event.static <T> DefaultSelectionEventManager<T> Create a newDefaultSelectionEventManagerthat handles selection via user interactions.static <T> DefaultSelectionEventManager<T> createWhitelistManager(int... whitelistedColumns) Construct a newDefaultSelectionEventManagerthat allows selection only for the columns in the specified whitelist.voiddoMultiSelection(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 voidhandleMultiSelectionEvent(CellPreviewEvent<T> event, DefaultSelectionEventManager.SelectAction action, MultiSelectionModel<? super T> selectionModel) Handle an event that could cause a value to be selected for aMultiSelectionModel.protected voidhandleSelectionEvent(CellPreviewEvent<T> event, DefaultSelectionEventManager.SelectAction action, SelectionModel<? super T> selectionModel) Handle an event that could cause a value to be selected.voidonCellPreview(CellPreviewEvent<T> event) Called whenCellPreviewEventis fired.protected voidselectOne(MultiSelectionModel<? super T> selectionModel, T target, boolean selected, boolean clearOthers) Selects the given item, optionally clearing any prior selection.protected voidsetRangeSelection(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 newDefaultSelectionEventManagerusing the specifiedDefaultSelectionEventManager.EventTranslatorto control whichDefaultSelectionEventManager.SelectActionto take for each event.- Parameters:
translator- theDefaultSelectionEventManager.EventTranslatorto use
-
-
Method Details
-
createBlacklistManager
Construct a newDefaultSelectionEventManagerthat 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
DefaultSelectionEventManagerinstance
-
createCheckboxManager
Construct a newDefaultSelectionEventManagerthat triggers selection when any checkbox in any column is clicked.- Type Parameters:
T- the data type of the display- Returns:
- a
DefaultSelectionEventManagerinstance
-
createCheckboxManager
Construct a newDefaultSelectionEventManagerthat 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
DefaultSelectionEventManagerinstance
-
createCustomManager
public static <T> DefaultSelectionEventManager<T> createCustomManager(DefaultSelectionEventManager.EventTranslator<T> translator) Create a newDefaultSelectionEventManagerusing the specifiedDefaultSelectionEventManager.EventTranslatorto control whichDefaultSelectionEventManager.SelectActionto take for each event.- Type Parameters:
T- the data type of the display- Parameters:
translator- theDefaultSelectionEventManager.EventTranslatorto use- Returns:
- a
DefaultSelectionEventManagerinstance
-
createDefaultManager
Create a newDefaultSelectionEventManagerthat handles selection via user interactions.- Type Parameters:
T- the data type of the display- Returns:
- a new
DefaultSelectionEventManagerinstance
-
createWhitelistManager
Construct a newDefaultSelectionEventManagerthat 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
DefaultSelectionEventManagerinstance
-
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.SelectActionto applyselectRange- true to select the range from the last selected rowclearOthers- true to clear the current selection
-
onCellPreview
Description copied from interface:CellPreviewEvent.HandlerCalled whenCellPreviewEventis fired.- Specified by:
onCellPreviewin interfaceCellPreviewEvent.Handler<T>- Parameters:
event- theCellPreviewEventthat was fired
-
clearSelection
Removes all items from the selection.- Parameters:
selectionModel- theMultiSelectionModelto 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- theCellPreviewEventthat triggered selectionaction- the action to handleselectionModel- theSelectionModelto 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- theCellPreviewEventthat triggered selectionaction- the action to handleselectionModel- theSelectionModelto 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- theMultiSelectionModelto 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- theMultiSelectionModelto updatedisplay- theHasDatasource of the selection eventrange- theRangeof rows to select or deselectaddToSelection- true to select, false to deselect the rangeclearOthers- true to deselect rows not in the range
-