SelectionChangeEvent currently is tightly coupled with SelectionModel. There is no way to fire a SelectionChangeEvent outside of something that implements SelectionModel. This patch fixes that and resuses the HasFooHandlers pattern that is seen in most other gwt events.

Review at http://gwt-code-reviews.appspot.com/1426801/

Author: larsenje@gmail.com (Jeff Larsen)
Review by: jlabanca


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10188 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/view/client/SelectionChangeEvent.java b/user/src/com/google/gwt/view/client/SelectionChangeEvent.java
index a99e7a2..19af412 100644
--- a/user/src/com/google/gwt/view/client/SelectionChangeEvent.java
+++ b/user/src/com/google/gwt/view/client/SelectionChangeEvent.java
@@ -17,6 +17,8 @@
 
 import com.google.gwt.event.shared.EventHandler;
 import com.google.gwt.event.shared.GwtEvent;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.HasHandlers;
 
 /**
  * Represents a selection change event.
@@ -38,6 +40,20 @@
   }
 
   /**
+   * Interface specifying that a class can add
+   * {@code SelectionChangeEvent.Handler}s.
+   */
+  public interface HasSelectionChangedHandlers extends HasHandlers {
+    /**
+     * Adds a {@link SelectionChangeEvent} handler.
+     * 
+     * @param handler the handler
+     * @return {@link HandlerRegistration} used to remove this handler
+     */
+    HandlerRegistration addSelectionChangeHandler(Handler handler);
+  }
+
+  /**
    * Handler type.
    */
   private static Type<SelectionChangeEvent.Handler> TYPE;
@@ -48,7 +64,7 @@
    *
    * @param source the source of the handlers
    */
-  public static void fire(SelectionModel<?> source) {
+  public static void fire(HasSelectionChangedHandlers source) {
     if (TYPE != null) {
       SelectionChangeEvent event = new SelectionChangeEvent();
       source.fireEvent(event);
diff --git a/user/src/com/google/gwt/view/client/SelectionModel.java b/user/src/com/google/gwt/view/client/SelectionModel.java
index e00d3f7..9768b8f 100644
--- a/user/src/com/google/gwt/view/client/SelectionModel.java
+++ b/user/src/com/google/gwt/view/client/SelectionModel.java
@@ -20,14 +20,14 @@
 import com.google.gwt.event.shared.GwtEvent;
 import com.google.gwt.event.shared.HandlerManager;
 import com.google.gwt.event.shared.HandlerRegistration;
-import com.google.gwt.event.shared.HasHandlers;
+import com.google.gwt.view.client.SelectionChangeEvent.HasSelectionChangedHandlers;
 
 /**
  * A model for selection within a list.
  * 
  * @param <T> the data type of records in the list
  */
-public interface SelectionModel<T> extends HasHandlers, ProvidesKey<T> {
+public interface SelectionModel<T> extends HasSelectionChangedHandlers, ProvidesKey<T> {
 
   /**
    * A default implementation of {@link SelectionModel} that provides listener