Reduce the use of old event bus classes. The only public api that
still mentions the gwt EventBus explicitly at this point is the
Activity interface. Not much to be done about that, and maybe
DrivesWidgets will grow to make the point moot.

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

Review by: robertvawter@google.com

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10342 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/activity/shared/ActivityManager.java b/user/src/com/google/gwt/activity/shared/ActivityManager.java
index 200357b..c961357 100644
--- a/user/src/com/google/gwt/activity/shared/ActivityManager.java
+++ b/user/src/com/google/gwt/activity/shared/ActivityManager.java
@@ -15,14 +15,14 @@
  */
 package com.google.gwt.activity.shared;
 
-import com.google.gwt.event.shared.EventBus;
-import com.google.gwt.event.shared.HandlerRegistration;
 import com.google.gwt.event.shared.ResettableEventBus;
 import com.google.gwt.event.shared.UmbrellaException;
 import com.google.gwt.place.shared.PlaceChangeEvent;
 import com.google.gwt.place.shared.PlaceChangeRequestEvent;
 import com.google.gwt.user.client.ui.AcceptsOneWidget;
 import com.google.gwt.user.client.ui.IsWidget;
+import com.google.web.bindery.event.shared.EventBus;
+import com.google.web.bindery.event.shared.HandlerRegistration;
 
 import java.util.LinkedHashSet;
 import java.util.Set;
@@ -32,8 +32,7 @@
  * {@link PlaceChangeEvent} events. Each activity can start itself
  * asynchronously, and provides a widget to be shown when it's ready to run.
  */
-public class ActivityManager implements PlaceChangeEvent.Handler,
-    PlaceChangeRequestEvent.Handler {
+public class ActivityManager implements PlaceChangeEvent.Handler, PlaceChangeRequestEvent.Handler {
 
   /**
    * Wraps our real display to prevent an Activity from taking it over if it is
@@ -55,13 +54,18 @@
   }
 
   private static final Activity NULL_ACTIVITY = new AbstractActivity() {
-    public void start(AcceptsOneWidget panel, EventBus eventBus) {
+    public void start(AcceptsOneWidget panel, com.google.gwt.event.shared.EventBus eventBus) {
     }
   };
 
   private final ActivityMapper mapper;
 
   private final EventBus eventBus;
+
+  /*
+   * Note that we use the legacy class from com.google.gwt.event.shared, because
+   * we can't change the Activity interface.
+   */
   private final ResettableEventBus stopperedEventBus;
 
   private Activity currentActivity = NULL_ACTIVITY;
@@ -136,7 +140,7 @@
       startingNext = true;
       caughtOnStart = tryStart();
     }
-    
+
     if (caughtOnStart != null || caughtOnCancel != null || caughtOnStop != null) {
       Set<Throwable> causes = new LinkedHashSet<Throwable>();
       if (caughtOnStop != null) {
@@ -202,12 +206,12 @@
   private Throwable tryStart() {
     Throwable caughtOnStart = null;
     try {
-      /* Wrap the actual display with a per-call instance
-       * that protects the display from canceled or stopped activities, and which
-       * maintains our startingNext state.
+      /*
+       * Wrap the actual display with a per-call instance that protects the
+       * display from canceled or stopped activities, and which maintains our
+       * startingNext state.
        */
-      currentActivity.start(new ProtectedDisplay(currentActivity),
-          stopperedEventBus);
+      currentActivity.start(new ProtectedDisplay(currentActivity), stopperedEventBus);
     } catch (Throwable t) {
       caughtOnStart = t;
     }
@@ -236,10 +240,9 @@
 
   private void updateHandlers(boolean activate) {
     if (activate) {
-      final HandlerRegistration placeReg = eventBus.addHandler(
-          PlaceChangeEvent.TYPE, this);
-      final HandlerRegistration placeRequestReg = eventBus.addHandler(
-          PlaceChangeRequestEvent.TYPE, this);
+      final HandlerRegistration placeReg = eventBus.addHandler(PlaceChangeEvent.TYPE, this);
+      final HandlerRegistration placeRequestReg =
+          eventBus.addHandler(PlaceChangeRequestEvent.TYPE, this);
 
       this.handlerRegistration = new HandlerRegistration() {
         public void removeHandler() {
diff --git a/user/src/com/google/gwt/event/shared/LegacyHandlerWrapper.java b/user/src/com/google/gwt/event/shared/LegacyHandlerWrapper.java
index b5396da..92e7277 100644
--- a/user/src/com/google/gwt/event/shared/LegacyHandlerWrapper.java
+++ b/user/src/com/google/gwt/event/shared/LegacyHandlerWrapper.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2011 Google Inc.
- *
+ * 
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- *
+ * 
  * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,10 +15,14 @@
  */
 package com.google.gwt.event.shared;
 
-class LegacyHandlerWrapper implements HandlerRegistration {
+/**
+ * Wrapper class to ease the transition to
+ * {@link com.google.web.bindery.event.shared.HandlerRegistration}.
+ */
+public class LegacyHandlerWrapper implements HandlerRegistration {
   private final com.google.web.bindery.event.shared.HandlerRegistration real;
-  
-  LegacyHandlerWrapper(com.google.web.bindery.event.shared.HandlerRegistration real) {
+
+  public LegacyHandlerWrapper(com.google.web.bindery.event.shared.HandlerRegistration real) {
     this.real = real;
   }
 
diff --git a/user/src/com/google/gwt/event/shared/ResettableEventBus.java b/user/src/com/google/gwt/event/shared/ResettableEventBus.java
index ca063e1..96760cf 100644
--- a/user/src/com/google/gwt/event/shared/ResettableEventBus.java
+++ b/user/src/com/google/gwt/event/shared/ResettableEventBus.java
@@ -25,10 +25,7 @@
  */
 public class ResettableEventBus extends EventBus {
   private static class TestableResettableEventBus extends com.google.web.bindery.event.shared.ResettableEventBus {
-    /**
-     * @param wrappedBus
-     */
-    public TestableResettableEventBus(EventBus wrappedBus) {
+    private TestableResettableEventBus(com.google.web.bindery.event.shared.EventBus wrappedBus) {
       super(wrappedBus);
     }
 
@@ -40,7 +37,7 @@
 
   private final TestableResettableEventBus real;
 
-  public ResettableEventBus(EventBus wrappedBus) {
+  public ResettableEventBus(com.google.web.bindery.event.shared.EventBus wrappedBus) {
     real = new TestableResettableEventBus(wrappedBus);
   }
 
diff --git a/user/src/com/google/gwt/place/shared/PlaceController.java b/user/src/com/google/gwt/place/shared/PlaceController.java
index 294a963..21b80eb 100644
--- a/user/src/com/google/gwt/place/shared/PlaceController.java
+++ b/user/src/com/google/gwt/place/shared/PlaceController.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2010 Google Inc.
- *
+ * 
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- *
+ * 
  * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -16,11 +16,11 @@
 package com.google.gwt.place.shared;
 
 import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.shared.EventBus;
 import com.google.gwt.event.shared.HandlerRegistration;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.Window.ClosingEvent;
 import com.google.gwt.user.client.Window.ClosingHandler;
+import com.google.web.bindery.event.shared.EventBus;
 
 import java.util.logging.Logger;
 
@@ -49,7 +49,7 @@
   public interface Delegate {
     /**
      * Adds a {@link ClosingHandler} to the Delegate.
-     *
+     * 
      * @param handler a {@link ClosingHandler} instance
      * @return a {@link HandlerRegistration} instance
      */
@@ -57,7 +57,7 @@
 
     /**
      * Called to confirm a window closing event.
-     *
+     * 
      * @param message a warning message
      * @return true to allow the window closing
      */
@@ -72,6 +72,26 @@
   private Place where = Place.NOWHERE;
 
   /**
+   * Legacy method tied to the old location for {@link EventBus}.
+   * 
+   * @deprecated use {@link #PlaceController(EventBus)}
+   */
+  @Deprecated
+  public PlaceController(com.google.gwt.event.shared.EventBus eventBus) {
+    this((EventBus) eventBus);
+  }
+
+  /**
+   * Legacy method tied to the old location for {@link EventBus}.
+   * 
+   * @deprecated use {@link #PlaceController(EventBus, Delegate)}
+   */
+  @Deprecated
+  public PlaceController(com.google.gwt.event.shared.EventBus eventBus, Delegate delegate) {
+    this((EventBus) eventBus, delegate);
+  }
+
+  /**
    * Create a new PlaceController with a {@link DefaultDelegate}. The
    * DefaultDelegate is created via a call to GWT.create(), so an alternative
    * default implementation can be provided through &lt;replace-with&gt; rules
@@ -113,13 +133,13 @@
 
   /**
    * Request a change to a new place. It is not a given that we'll actually get
-   * there. First a {@link PlaceChangeRequestEvent} will be posted to the
-   * event bus. If any receivers post a warning message to that event, it will
-   * be presented to the user via {@link Delegate#confirm(String)} (which is
+   * there. First a {@link PlaceChangeRequestEvent} will be posted to the event
+   * bus. If any receivers post a warning message to that event, it will be
+   * presented to the user via {@link Delegate#confirm(String)} (which is
    * typically a call to {@link Window#confirm(String)}). If she cancels, the
    * current location will not change. Otherwise, the location changes and a
    * {@link PlaceChangeEvent} is posted announcing the new place.
-   *
+   * 
    * @param newPlace a {@link Place} instance
    */
   public void goTo(Place newPlace) {
@@ -145,8 +165,7 @@
   }
 
   private String maybeGoTo(Place newPlace) {
-    PlaceChangeRequestEvent willChange = new PlaceChangeRequestEvent(
-        newPlace);
+    PlaceChangeRequestEvent willChange = new PlaceChangeRequestEvent(newPlace);
     eventBus.fireEvent(willChange);
     String warning = willChange.getWarning();
     return warning;
diff --git a/user/src/com/google/gwt/place/shared/PlaceHistoryHandler.java b/user/src/com/google/gwt/place/shared/PlaceHistoryHandler.java
index 7117169..af138bd 100644
--- a/user/src/com/google/gwt/place/shared/PlaceHistoryHandler.java
+++ b/user/src/com/google/gwt/place/shared/PlaceHistoryHandler.java
@@ -18,9 +18,10 @@
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.event.logical.shared.ValueChangeEvent;
 import com.google.gwt.event.logical.shared.ValueChangeHandler;
-import com.google.gwt.event.shared.EventBus;
-import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.LegacyHandlerWrapper;
 import com.google.gwt.user.client.History;
+import com.google.web.bindery.event.shared.EventBus;
+import com.google.web.bindery.event.shared.HandlerRegistration;
 
 import java.util.logging.Logger;
 
@@ -35,7 +36,7 @@
    * Default implementation of {@link Historian}, based on {@link History}.
    */
   public static class DefaultHistorian implements Historian {
-    public HandlerRegistration addValueChangeHandler(
+    public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(
         ValueChangeHandler<String> valueChangeHandler) {
       return History.addValueChangeHandler(valueChangeHandler);
     }
@@ -62,7 +63,7 @@
      * @param valueChangeHandler the handler
      * @return the registration used to remove this value change handler
      */
-    HandlerRegistration addValueChangeHandler(
+    com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(
         ValueChangeHandler<String> valueChangeHandler);
 
     /**
@@ -118,29 +119,41 @@
   }
 
   /**
+   * Legacy method tied to the old location for {@link EventBus}.
+   * 
+   * @deprecated use {@link #register(PlaceController, EventBus, Place)}
+   */
+  @Deprecated
+  public com.google.gwt.event.shared.HandlerRegistration register(PlaceController placeController,
+      com.google.gwt.event.shared.EventBus eventBus, Place defaultPlace) {
+    return new LegacyHandlerWrapper(register(placeController, (EventBus) eventBus, defaultPlace));
+  }
+
+  /**
    * Initialize this place history handler.
    * 
    * @return a registration object to de-register the handler
    */
-  public HandlerRegistration register(PlaceController placeController,
-      EventBus eventBus, Place defaultPlace) {
+  public HandlerRegistration register(PlaceController placeController, EventBus eventBus,
+      Place defaultPlace) {
     this.placeController = placeController;
     this.defaultPlace = defaultPlace;
 
-    final HandlerRegistration placeReg = eventBus.addHandler(
-        PlaceChangeEvent.TYPE, new PlaceChangeEvent.Handler() {
+    final HandlerRegistration placeReg =
+        eventBus.addHandler(PlaceChangeEvent.TYPE, new PlaceChangeEvent.Handler() {
           public void onPlaceChange(PlaceChangeEvent event) {
             Place newPlace = event.getNewPlace();
             historian.newItem(tokenForPlace(newPlace), false);
           }
         });
 
-    final HandlerRegistration historyReg = historian.addValueChangeHandler(new ValueChangeHandler<String>() {
-      public void onValueChange(ValueChangeEvent<String> event) {
-        String token = event.getValue();
-        handleHistoryToken(token);
-      }
-    });
+    final HandlerRegistration historyReg =
+        historian.addValueChangeHandler(new ValueChangeHandler<String>() {
+          public void onValueChange(ValueChangeEvent<String> event) {
+            String token = event.getValue();
+            handleHistoryToken(token);
+          }
+        });
 
     return new HandlerRegistration() {
       public void removeHandler() {
diff --git a/user/src/com/google/web/bindery/requestfactory/vm/RequestFactorySource.java b/user/src/com/google/web/bindery/requestfactory/vm/RequestFactorySource.java
index bc4e146..6bc4a6c 100644
--- a/user/src/com/google/web/bindery/requestfactory/vm/RequestFactorySource.java
+++ b/user/src/com/google/web/bindery/requestfactory/vm/RequestFactorySource.java
@@ -31,7 +31,7 @@
    * initialized with an explicit
    * {@link com.google.web.bindery.requestfactory.shared.RequestTransport
    * RequestTransport} via the
-   * {@link RequestFactory#initialize(com.google.gwt.event.shared.EventBus, com.google.web.bindery.requestfactory.shared.RequestTransport)
+   * {@link RequestFactory#initialize(com.google.web.bindery.event.shared.EventBus, com.google.web.bindery.requestfactory.shared.RequestTransport)
    * initialize(EventBus, RequestTransport} method.
    * 
    * @param <T> the RequestFactory type