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>

      public class DefaultSelectionEventManager<T>
      extends java.lang.Object
      implements 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

    Nested Classes
    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.

  - ### Constructor Summary

    Constructors
    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.

  - ### Method Summary

    Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultSelectionEventManager

          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.
      Parameters:
        `translator` - the `DefaultSelectionEventManager.EventTranslator` to use

  - ### Method Detail

    - #### createBlacklistManager

          public static <T> DefaultSelectionEventManager<T> createBlacklistManager(int... blacklistedColumns)

      Construct a new `DefaultSelectionEventManager` 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

          public static <T> DefaultSelectionEventManager<T> createCheckboxManager()

      Construct a new `DefaultSelectionEventManager` 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

          public static <T> DefaultSelectionEventManager<T> createCheckboxManager(int column)

      Construct a new `DefaultSelectionEventManager` 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 new `DefaultSelectionEventManager` using the specified `DefaultSelectionEventManager.EventTranslator` to control which `DefaultSelectionEventManager.SelectAction` to take for each event.
      Type Parameters:
        `T` - the data type of the display
      Parameters:
        `translator` - the `DefaultSelectionEventManager.EventTranslator` to use
      Returns:
        a `DefaultSelectionEventManager` instance

    - #### createDefaultManager

          public static <T> DefaultSelectionEventManager<T> createDefaultManager()

      Create a new `DefaultSelectionEventManager` that handles selection via user interactions.
      Type Parameters:
        `T` - the data type of the display
      Returns:
        a new `DefaultSelectionEventManager` instance

    - #### createWhitelistManager

          public static <T> DefaultSelectionEventManager<T> createWhitelistManager(int... whitelistedColumns)

      Construct a new `DefaultSelectionEventManager` 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 update
        `row` - the absolute index of the selected row
        `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

    - #### onCellPreview

          public void onCellPreview(CellPreviewEvent<T> event)

      Description copied from interface: `CellPreviewEvent.Handler`
      Called when `CellPreviewEvent` is fired.
      Specified by:
        `onCellPreview` in interface `CellPreviewEvent.Handler<T>`
      Parameters:
        `event` - the `CellPreviewEvent` that was fired

    - #### clearSelection

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

      Removes all items from the selection.
      Parameters:
        `selectionModel` - the `MultiSelectionModel` 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 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

    - #### 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 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

    - #### 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` - the `MultiSelectionModel` to update
        `target` - the item to select
        `selected` - true to select, false to deselect
        `clearOthers` - 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` - 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