com.google.gwt.view.client
Class DefaultSelectionModel<T>

java.lang.Object
  extended by com.google.gwt.view.client.SelectionModel.AbstractSelectionModel<T>
      extended by com.google.gwt.view.client.DefaultSelectionModel<T>
Type Parameters:
T - the data type of records in the list
All Implemented Interfaces:
HasHandlers, ProvidesKey<T>, SelectionModel<T>

public abstract class DefaultSelectionModel<T>
extends SelectionModel.AbstractSelectionModel<T>

A convenience SelectionModel that allows records to be selected according to a subclass-defined rule, plus a list of positive or negative exceptions.

Note: This class is new and its interface subject to change.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.google.gwt.view.client.SelectionModel
SelectionModel.AbstractSelectionModel<T>, SelectionModel.SelectionChangeEvent, SelectionModel.SelectionChangeHandler
 
Constructor Summary
DefaultSelectionModel()
           
 
Method Summary
 void clearExceptions()
          Removes all exceptions.
abstract  boolean isDefaultSelected(T object)
          Returns true if the given object should be selected by default.
 boolean isSelected(T object)
          If the given object is marked as an exception, return the exception value.
 void setSelected(T object, boolean selected)
          Sets an object's selection state.
 
Methods inherited from class com.google.gwt.view.client.SelectionModel.AbstractSelectionModel
addSelectionChangeHandler, fireEvent, getKey, getKeyProvider, setKeyProvider
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSelectionModel

public DefaultSelectionModel()
Method Detail

clearExceptions

public void clearExceptions()
Removes all exceptions.


isDefaultSelected

public abstract boolean isDefaultSelected(T object)
Returns true if the given object should be selected by default. Subclasses implement this method in order to define the default selection behavior.


isSelected

public boolean isSelected(T object)
If the given object is marked as an exception, return the exception value. Otherwise, return the value of isDefaultSelected for the given object.

Parameters:
object - the object
Returns:
true if selected, false if not

setSelected

public void setSelected(T object,
                        boolean selected)
Sets an object's selection state. If the object is currently marked as an exception, and the new selected state differs from the previous selected state, the object is removed from the list of exceptions. Otherwise, the object is added to the list of exceptions with the given selected state.

Parameters:
object - the object to select or deselect
selected - true to select, false to deselect