com.google.gwt.view.client

## Class MultiSelectionModel<T>

- java.lang.Object
- - com.google.gwt.view.client.SelectionModel.AbstractSelectionModel<T>
  - - com.google.gwt.view.client.MultiSelectionModel<T>

- Type Parameters:
    `T` - the data type of the items
  All Implemented Interfaces:
    HasHandlers, ProvidesKey<T>, SelectionChangeEvent.HasSelectionChangedHandlers, SelectionModel<T>, SetSelectionModel<T>
  Direct Known Subclasses:
    OrderedMultiSelectionModel

      public class MultiSelectionModel<T>
      extends SelectionModel.AbstractSelectionModel<T>
      implements SetSelectionModel<T>

  A simple selection model that allows multiple items to be selected.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) static class` | `MultiSelectionModel.SelectionChange<T>` Stores an item and its pending selection state.

    - ### Nested classes/interfaces inherited from interface com.google.gwt.view.client.SelectionModel

      `SelectionModel.AbstractSelectionModel<T>`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) java.util.Map<java.lang.Object,T>` | `selectedSet`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MultiSelectionModel()` Constructs a MultiSelectionModel without a key provider.
    `MultiSelectionModel(ProvidesKey<T> keyProvider)` Constructs a MultiSelectionModel with the given key provider.
    `MultiSelectionModel(ProvidesKey<T> keyProvider, java.util.Map<java.lang.Object,T> selectedSet, java.util.Map<java.lang.Object,MultiSelectionModel.SelectionChange<T>> selectionChanges)` Construct a MultiSelectionModel with the given key provider and implementations of selectedSet and selectionChanges.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Deselect all selected values.
    `protected void` | `fireSelectionChangeEvent()` Fire a `SelectionChangeEvent`.
    `java.util.Set<T>` | `getSelectedSet()` Get the set of selected items as a copy.
    `boolean` | `isSelected(T item)` Check if an object is selected.
    `(package private) void` | `resolveChanges()`
    `void` | `setSelected(T item, boolean selected)` Set the selected state of an object and fire a `SelectionChangeEvent` if the selection has changed.

    - ### Methods inherited from class com.google.gwt.view.client.SelectionModel.AbstractSelectionModel

      `addSelectionChangeHandler, fireEvent, getKey, getKeyProvider, isEventCancelled, isEventScheduled, scheduleSelectionChangeEvent, setEventCancelled, setEventScheduled`

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

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

    - ### Methods inherited from interface com.google.gwt.view.client.SelectionModel

      `addSelectionChangeHandler`

    - ### Methods inherited from interface com.google.gwt.event.shared.HasHandlers

      `fireEvent`

    - ### Methods inherited from interface com.google.gwt.view.client.ProvidesKey

      `getKey`

- - ### Field Detail

    - #### selectedSet

          final java.util.Map<java.lang.Object,T> selectedSet

  - ### Constructor Detail

    - #### MultiSelectionModel

          public MultiSelectionModel()

      Constructs a MultiSelectionModel without a key provider.

    - #### MultiSelectionModel

          public MultiSelectionModel(ProvidesKey<T> keyProvider)

      Constructs a MultiSelectionModel with the given key provider.
      Parameters:
        `keyProvider` - an instance of ProvidesKey, or null if the item should act as its own key

    - #### MultiSelectionModel

          MultiSelectionModel(ProvidesKey<T> keyProvider,
                             java.util.Map<java.lang.Object,T> selectedSet,
                             java.util.Map<java.lang.Object,MultiSelectionModel.SelectionChange<T>> selectionChanges)

      Construct a MultiSelectionModel with the given key provider and implementations of selectedSet and selectionChanges. Different implementations allow for enforcing order on selection.
      Parameters:
        `keyProvider` - an instance of ProvidesKey, or null if the item should act as its own key
        `selectedSet` - an instance of Map
        `selectionChanges` - an instance of Map

  - ### Method Detail

    - #### clear

          public void clear()

      Deselect all selected values.
      Specified by:
        `clear` in interface `SetSelectionModel<T>`

    - #### getSelectedSet

          public java.util.Set<T> getSelectedSet()

      Get the set of selected items as a copy. If multiple selected items share the same key, only the last selected item is included in the set.
      Specified by:
        `getSelectedSet` in interface `SetSelectionModel<T>`
      Returns:
        the set of selected items

    - #### isSelected

          public boolean isSelected(T item)

      Description copied from interface: `SelectionModel`
      Check if an object is selected.
      Specified by:
        `isSelected` in interface `SelectionModel<T>`
      Parameters:
        `item` - the object
      Returns:
        true if selected, false if not

    - #### setSelected

          public void setSelected(T item,
                         boolean selected)

      Description copied from interface: `SelectionModel`
      Set the selected state of an object and fire a `SelectionChangeEvent` if the selection has changed. Subclasses should not fire an event in the case where selected is true and the object was already selected, or selected is false and the object was not previously selected.
      Specified by:
        `setSelected` in interface `SelectionModel<T>`
      Parameters:
        `item` - the object to select or deselect
        `selected` - true to select, false to deselect

    - #### fireSelectionChangeEvent

          protected void fireSelectionChangeEvent()

      Description copied from class: `SelectionModel.AbstractSelectionModel`
      Fire a `SelectionChangeEvent`. Multiple firings may be coalesced.
      Overrides:
        `fireSelectionChangeEvent` in class `SelectionModel.AbstractSelectionModel<T>`

    - #### resolveChanges

          void resolveChanges()