public class

DefaultSelectionEventManager

extends Object
implements CellPreviewEvent.Handler<T>
java.lang.Object
   ↳ com.google.gwt.view.client.DefaultSelectionEventManager<T>

Class Overview

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.

Summary

Nested Classes
class DefaultSelectionEventManager.CheckboxEventTranslator<T> Implementation of DefaultSelectionEventManager.CheckboxEventTranslator that only triggers selection when any checkbox is selected. 
interface DefaultSelectionEventManager.EventTranslator<T> Translates CellPreviewEvents into DefaultSelectionEventManager.SelectActions. 
enum DefaultSelectionEventManager.SelectAction The action that controls how selection is handled. 
Protected Constructors
DefaultSelectionEventManager(EventTranslator<T> translator)
Construct a new DefaultSelectionEventManager using the specified DefaultSelectionEventManager.EventTranslator to control which DefaultSelectionEventManager.SelectAction to take for each event.
Public Methods
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> createCheckboxManager()
Construct a new DefaultSelectionEventManager that triggers selection when any checkbox in any column is clicked.
static <T> DefaultSelectionEventManager<T> createCustomManager(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.
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.
void onCellPreview(CellPreviewEvent<T> event)
Called when CellPreviewEvent is fired.
Protected Methods
void clearSelection(MultiSelectionModel<? super T> selectionModel)
Removes all items from the selection.
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.
void handleSelectionEvent(CellPreviewEvent<T> event, DefaultSelectionEventManager.SelectAction action, SelectionModel<? super T> selectionModel)
Handle an event that could cause a value to be selected.
void selectOne(MultiSelectionModel<? super T> selectionModel, T target, boolean selected, boolean clearOthers)
Selects the given item, optionally clearing any prior selection.
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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.gwt.view.client.CellPreviewEvent.Handler

Protected Constructors

protected DefaultSelectionEventManager (EventTranslator<T> translator)

Construct a new DefaultSelectionEventManager using the specified DefaultSelectionEventManager.EventTranslator to control which DefaultSelectionEventManager.SelectAction to take for each event.

Parameters
translator the DefaultSelectionEventManager.EventTranslator to use

Public Methods

public static DefaultSelectionEventManager<T> createCheckboxManager (int column)

Construct a new DefaultSelectionEventManager that triggers selection when a checkbox in the specified column is clicked.

Parameters
column the column to handle
Returns

public static DefaultSelectionEventManager<T> createCheckboxManager ()

Construct a new DefaultSelectionEventManager that triggers selection when any checkbox in any column is clicked.

Returns

public static DefaultSelectionEventManager<T> createCustomManager (EventTranslator<T> translator)

Create a new DefaultSelectionEventManager using the specified DefaultSelectionEventManager.EventTranslator to control which DefaultSelectionEventManager.SelectAction to take for each event.

Parameters
translator the DefaultSelectionEventManager.EventTranslator to use
Returns

public static DefaultSelectionEventManager<T> createDefaultManager ()

Create a new DefaultSelectionEventManager that handles selection via user interactions.

Returns

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 update
row the selected row index relative to the page start
rowValue the selected row value
action the DefaultSelectionEventManager.SelectAction to apply
selectRange true to select the range from the last selected row
clearOthers true to clear the current selection

public void onCellPreview (CellPreviewEvent<T> event)

Called when CellPreviewEvent is fired.

Parameters
event the CellPreviewEvent that was fired

Protected Methods

protected void clearSelection (MultiSelectionModel<? super T> selectionModel)

Removes all items from the selection.

Parameters
selectionModel the MultiSelectionModel to clear

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. 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 the CellPreviewEvent that triggered selection
action the action to handle
selectionModel the SelectionModel to update

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 any SelectionModel. Pressing the space bar or ctrl+click will toggle the selection state. Clicking selects the row if it is not selected.

Parameters
event the CellPreviewEvent that triggered selection
action the action to handle
selectionModel the SelectionModel to update

protected void selectOne (MultiSelectionModel<? super T> selectionModel, T target, boolean selected, boolean clearOthers)

Selects the given item, optionally clearing any prior selection.

Parameters
selectionModel the MultiSelectionModel to update
target the item to select
selected true to select, false to deselect
clearOthers true to clear all other selected items

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 the MultiSelectionModel to update
display the HasData source of the selection event
range the Range of rows to select or deselect
addToSelection true to select, false to deselect the range
clearOthers true to deselect rows not in the range