Revision: 8811
Author: [email protected]
Date: Fri Sep 17 09:11:27 2010
Log: Rename PlaceChangeRequesteEvent to PlaceChangeRequestEvent

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

Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=8811

Added:
 /trunk/user/src/com/google/gwt/app/place/PlaceChangeRequestEvent.java
 /trunk/user/test/com/google/gwt/app/place/PlaceChangeRequestEventTest.java
Deleted:
 /trunk/user/src/com/google/gwt/app/place/PlaceChangeRequesteEvent.java
/trunk/user/test/com/google/gwt/app/place/PlaceChangeRequestedEventTest.java
Modified:
 /trunk/user/src/com/google/gwt/app/place/ActivityManager.java
 /trunk/user/src/com/google/gwt/app/place/PlaceController.java
 /trunk/user/test/com/google/gwt/app/AppJreSuite.java
 /trunk/user/test/com/google/gwt/app/place/ActivityManagerTest.java
 /trunk/user/test/com/google/gwt/app/place/PlaceControllerTest.java

=======================================
--- /dev/null
+++ /trunk/user/src/com/google/gwt/app/place/PlaceChangeRequestEvent.java Fri Sep 17 09:11:27 2010
@@ -0,0 +1,94 @@
+/*
+ * 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
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.app.place;
+
+import com.google.gwt.event.shared.EventHandler;
+import com.google.gwt.event.shared.GwtEvent;
+
+/**
+ * <p>
+ * <span style="color:red">Experimental API: This class is still under rapid
+ * development, and is very likely to be deleted. Use it at your own risk.
+ * </span>
+ * </p>
+ * Event thrown when the user may go to a new place in the app, or tries to
+ * leave it. Receivers can call {...@link #setWarning(String)} request that the
+ * user be prompted to confirm the change.
+ */
+public class PlaceChangeRequestEvent extends
+    GwtEvent<PlaceChangeRequestEvent.Handler> {
+
+  /**
+   * Implemented by handlers of PlaceChangeRequestEvent.
+   *
+   * @param <P> the type of the requested Place
+   */
+  public interface Handler extends EventHandler {
+    void onPlaceChangeRequest(PlaceChangeRequestEvent event);
+  }
+
+  public static final Type<Handler> TYPE = new Type<Handler>();
+
+  private String warning;
+
+  private final Place newPlace;
+
+  public PlaceChangeRequestEvent(Place newPlace) {
+    this.newPlace = newPlace;
+  }
+
+  @Override
+  public Type<Handler> getAssociatedType() {
+    return TYPE;
+  }
+
+  /**
+   * @return the place we may navigate to, or null on window close
+   */
+  public Place getNewPlace() {
+    return newPlace;
+  }
+
+  /**
+   * @return the warning message to show the user before allowing the place
+   *         change, or null if none has been set
+   */
+  public String getWarning() {
+    return warning;
+  }
+
+  /**
+ * Set a message to warn the user that it might be unwise to navigate away + * from the current place, e.g. due to unsaved changes. If the user clicks
+   * okay to that message, navigation will be canceled.
+   * <p>
+ * Calling with a null warning is the same as not calling the method at all --
+   * the user will not be prompted.
+   * <p>
+ * Only the first non-null call to setWarning has any effect. That is, once
+   * the warning message has been set it cannot be cleared.
+   */
+  public void setWarning(String warning) {
+    if (this.warning == null) {
+      this.warning = warning;
+    }
+  }
+
+  @Override
+  protected void dispatch(Handler handler) {
+    handler.onPlaceChangeRequest(this);
+  }
+}
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/app/place/PlaceChangeRequestEventTest.java Fri Sep 17 09:11:27 2010
@@ -0,0 +1,38 @@
+/*
+ * 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
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.app.place;
+
+import junit.framework.TestCase;
+
+/**
+ * Eponymous test class.
+ */
+public class PlaceChangeRequestEventTest extends TestCase {
+  private static final String W1 = "foo";
+
+  public void testNoClobberWarning() {
+    PlaceChangeRequestEvent e = new PlaceChangeRequestEvent(new Place() {
+    });
+
+    assertNull(e.getWarning());
+    e.setWarning(W1);
+    assertEquals(W1, e.getWarning());
+    e.setWarning("bar");
+    assertEquals(W1, e.getWarning());
+    e.setWarning(null);
+    assertEquals(W1, e.getWarning());
+  }
+}
=======================================
--- /trunk/user/src/com/google/gwt/app/place/PlaceChangeRequesteEvent.java Mon Aug 16 20:22:31 2010
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.app.place;
-
-import com.google.gwt.event.shared.EventHandler;
-import com.google.gwt.event.shared.GwtEvent;
-
-/**
- * <p>
- * <span style="color:red">Experimental API: This class is still under rapid
- * development, and is very likely to be deleted. Use it at your own risk.
- * </span>
- * </p>
- * Event thrown when the user may go to a new place in the app, or tries to
- * leave it. Receivers can call {...@link #setWarning(String)} request that the
- * user be prompted to confirm the change.
- */
-public class PlaceChangeRequesteEvent extends
-    GwtEvent<PlaceChangeRequesteEvent.Handler> {
-
-  /**
-   * Implemented by handlers of PlaceChangeRequestedEvent.
-   *
-   * @param <P> the type of the requested Place
-   */
-  public interface Handler extends EventHandler {
-    void onPlaceChangeRequest(PlaceChangeRequesteEvent event);
-  }
-
-  public static final Type<Handler> TYPE = new Type<Handler>();
-
-  private String warning;
-
-  private final Place newPlace;
-
-  public PlaceChangeRequesteEvent(Place newPlace) {
-    this.newPlace = newPlace;
-  }
-
-  @Override
-  public Type<Handler> getAssociatedType() {
-    return TYPE;
-  }
-
-  /**
-   * @return the place we may navigate to, or null on window close
-   */
-  public Place getNewPlace() {
-    return newPlace;
-  }
-
-  /**
-   * @return the warning message to show the user before allowing the place
-   *         change, or null if none has been set
-   */
-  public String getWarning() {
-    return warning;
-  }
-
-  /**
- * Set a message to warn the user that it might be unwise to navigate away - * from the current place, e.g. due to unsaved changes. If the user clicks
-   * okay to that message, navigation will be canceled.
-   * <p>
- * Calling with a null warning is the same as not calling the method at all --
-   * the user will not be prompted.
-   * <p>
- * Only the first non-null call to setWarning has any effect. That is, once
-   * the warning message has been set it cannot be cleared.
-   */
-  public void setWarning(String warning) {
-    if (this.warning == null) {
-      this.warning = warning;
-    }
-  }
-
-  @Override
-  protected void dispatch(Handler handler) {
-    handler.onPlaceChangeRequest(this);
-  }
-}
=======================================
--- /trunk/user/test/com/google/gwt/app/place/PlaceChangeRequestedEventTest.java Mon Aug 16 20:22:31 2010
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.app.place;
-
-import junit.framework.TestCase;
-
-/**
- * Eponymous test class.
- */
-public class PlaceChangeRequestedEventTest extends TestCase {
-  private static final String W1 = "foo";
-
-  public void testNoClobberWarning() {
-    PlaceChangeRequesteEvent e = new PlaceChangeRequesteEvent(new Place() {
-    });
-
-    assertNull(e.getWarning());
-    e.setWarning(W1);
-    assertEquals(W1, e.getWarning());
-    e.setWarning("bar");
-    assertEquals(W1, e.getWarning());
-    e.setWarning(null);
-    assertEquals(W1, e.getWarning());
-  }
-}
=======================================
--- /trunk/user/src/com/google/gwt/app/place/ActivityManager.java Mon Sep 13 10:28:49 2010 +++ /trunk/user/src/com/google/gwt/app/place/ActivityManager.java Fri Sep 17 09:11:27 2010
@@ -36,7 +36,7 @@
* asynchronously, and provides a widget to be shown when it's ready to run.
  */
 public class ActivityManager implements PlaceChangeEvent.Handler,
-    PlaceChangeRequesteEvent.Handler {
+    PlaceChangeRequestEvent.Handler {

   /**
* Wraps our real display to prevent an Activity from taking it over if it is
@@ -77,10 +77,10 @@

   /**
    * Create an ActivityManager. Next call {...@link #setDisplay}.
-   *
+   *
    * @param mapper finds the {...@link Activity} for a given {...@link Place}
    * @param eventBus source of {...@link PlaceChangeEvent} and
-   *          {...@link PlaceChangeRequesteEvent} events.
+   *          {...@link PlaceChangeRequestEvent} events.
    */
   public ActivityManager(ActivityMapper mapper, EventBus eventBus) {
     this.mapper = mapper;
@@ -91,7 +91,7 @@
   /**
* Deactive the current activity, find the next one from our ActivityMapper,
    * and start it.
-   *
+   *
    * @see PlaceChangeEvent.Handler#onPlaceChange(PlaceChangeEvent)
    */
   public void onPlaceChange(PlaceChangeEvent event) {
@@ -176,10 +176,10 @@

   /**
* Reject the place change if the current activity is not willing to stop.
-   *
- * @see PlaceChangeRequesteEvent.Handler#onPlaceChangeRequest(PlaceChangeRequesteEvent)
+   *
+ * @see PlaceChangeRequestEvent.Handler#onPlaceChangeRequest(PlaceChangeRequestEvent)
    */
-  public void onPlaceChangeRequest(PlaceChangeRequesteEvent event) {
+  public void onPlaceChangeRequest(PlaceChangeRequestEvent event) {
     if (!currentActivity.equals(NULL_ACTIVITY)) {
       event.setWarning(currentActivity.mayStop());
     }
@@ -192,7 +192,7 @@
    * If you are disposing of an ActivityManager, it is important to call
* setDisplay(null) to get it to deregister from the event bus, so that it can
    * be garbage collected.
-   *
+   *
    * @param display
    */
   public void setDisplay(AcceptsOneWidget display) {
@@ -209,8 +209,8 @@
       final HandlerRegistration placeReg = eventBus.addHandler(
           PlaceChangeEvent.TYPE, this);
       final HandlerRegistration placeRequestReg = eventBus.addHandler(
-          PlaceChangeRequesteEvent.TYPE, this);
-
+          PlaceChangeRequestEvent.TYPE, this);
+
       this.handlerRegistration = new HandlerRegistration() {
         public void removeHandler() {
           placeReg.removeHandler();
=======================================
--- /trunk/user/src/com/google/gwt/app/place/PlaceController.java Mon Aug 16 20:22:31 2010 +++ /trunk/user/src/com/google/gwt/app/place/PlaceController.java Fri Sep 17 09:11:27 2010
@@ -45,7 +45,7 @@
       return Window.confirm(message);
     }
   }
-
+
   /**
    * Optional delegate in charge of Window related events. Provides nice
    * isolation for unit testing, and allows customization of confirmation
@@ -99,7 +99,7 @@

   /**
* Request a change to a new place. It is not a given that we'll actually get
-   * there. First a {...@link PlaceChangeRequesteEvent} will be posted to the
+   * 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
@@ -129,7 +129,7 @@
   }

   private String maybeGoTo(Place newPlace) {
-    PlaceChangeRequesteEvent willChange = new PlaceChangeRequesteEvent(
+    PlaceChangeRequestEvent willChange = new PlaceChangeRequestEvent(
         newPlace);
     eventBus.fireEvent(willChange);
     String warning = willChange.getWarning();
=======================================
--- /trunk/user/test/com/google/gwt/app/AppJreSuite.java Mon Aug 16 20:22:31 2010 +++ /trunk/user/test/com/google/gwt/app/AppJreSuite.java Fri Sep 17 09:11:27 2010
@@ -17,7 +17,7 @@

 import com.google.gwt.app.place.ActivityManagerTest;
 import com.google.gwt.app.place.AbstractPlaceHistoryHandlerTest;
-import com.google.gwt.app.place.PlaceChangeRequestedEventTest;
+import com.google.gwt.app.place.PlaceChangeRequestEventTest;
 import com.google.gwt.app.place.PlaceControllerTest;

 import junit.framework.Test;
@@ -32,7 +32,7 @@
     suite.addTestSuite(ActivityManagerTest.class);
     suite.addTestSuite(AbstractPlaceHistoryHandlerTest.class);
     suite.addTestSuite(PlaceControllerTest.class);
-    suite.addTestSuite(PlaceChangeRequestedEventTest.class);
+    suite.addTestSuite(PlaceChangeRequestEventTest.class);
     return suite;
   }
 }
=======================================
--- /trunk/user/test/com/google/gwt/app/place/ActivityManagerTest.java Thu Sep 16 04:46:26 2010 +++ /trunk/user/test/com/google/gwt/app/place/ActivityManagerTest.java Fri Sep 17 09:11:27 2010
@@ -155,7 +155,7 @@
     manager = new ActivityManager(map, eventBus);
     manager.setDisplay(realDisplay);

-    PlaceChangeRequesteEvent event = new PlaceChangeRequesteEvent(
+    PlaceChangeRequestEvent event = new PlaceChangeRequestEvent(
         place1);
     eventBus.fireEvent(event);
     assertNull(event.getWarning());
@@ -175,7 +175,7 @@
     assertFalse(asyncActivity1.stopped);
     assertFalse(asyncActivity1.canceled);

-    event = new PlaceChangeRequesteEvent(place2);
+    event = new PlaceChangeRequestEvent(place2);
     eventBus.fireEvent(event);
     assertNull(event.getWarning());
     assertEquals(asyncActivity1.view, realDisplay.widget);
@@ -221,7 +221,7 @@
     manager = new ActivityManager(map, eventBus);
     manager.setDisplay(realDisplay);

-    PlaceChangeRequesteEvent event = new PlaceChangeRequesteEvent(
+    PlaceChangeRequestEvent event = new PlaceChangeRequestEvent(
         place1);
     eventBus.fireEvent(event);
     assertNull(event.getWarning());
@@ -236,7 +236,7 @@
     assertFalse(asyncActivity1.canceled);
     assertNotNull(asyncActivity1.display);

-    event = new PlaceChangeRequesteEvent(place2);
+    event = new PlaceChangeRequestEvent(place2);
     eventBus.fireEvent(event);
     assertNull(event.getWarning());
     assertNull(realDisplay.widget);
@@ -287,22 +287,22 @@

     // Make sure we didn't nuke the ActivityManager's own handlers
     assertEquals(1, eventBus.getCount(PlaceChangeEvent.TYPE));
-    assertEquals(1, eventBus.getCount(PlaceChangeRequesteEvent.TYPE));
+    assertEquals(1, eventBus.getCount(PlaceChangeRequestEvent.TYPE));
   }

   public void testEventSetupAndTeardown() {
     assertEquals(0, eventBus.getCount(PlaceChangeEvent.TYPE));
-    assertEquals(0, eventBus.getCount(PlaceChangeRequesteEvent.TYPE));
+    assertEquals(0, eventBus.getCount(PlaceChangeRequestEvent.TYPE));

     manager.setDisplay(realDisplay);

     assertEquals(1, eventBus.getCount(PlaceChangeEvent.TYPE));
-    assertEquals(1, eventBus.getCount(PlaceChangeRequesteEvent.TYPE));
+    assertEquals(1, eventBus.getCount(PlaceChangeRequestEvent.TYPE));

     manager.setDisplay(null);

     assertEquals(0, eventBus.getCount(PlaceChangeEvent.TYPE));
-    assertEquals(0, eventBus.getCount(PlaceChangeRequesteEvent.TYPE));
+    assertEquals(0, eventBus.getCount(PlaceChangeRequestEvent.TYPE));
   }

   public void testExceptionsOnStopAndStart() {
@@ -357,7 +357,7 @@

     activity1.stopWarning = "Stop fool!";

-    PlaceChangeRequesteEvent event = new PlaceChangeRequesteEvent(
+    PlaceChangeRequestEvent event = new PlaceChangeRequestEvent(
         place1);
     eventBus.fireEvent(event);
     assertNull(event.getWarning());
@@ -366,7 +366,7 @@
     eventBus.fireEvent(new PlaceChangeEvent(place1));
     assertEquals(activity1.view, realDisplay.widget);

-    event = new PlaceChangeRequesteEvent(place2);
+    event = new PlaceChangeRequestEvent(place2);
     eventBus.fireEvent(event);
     assertEquals(activity1.stopWarning, event.getWarning());
     assertEquals(activity1.view, realDisplay.widget);
@@ -377,7 +377,7 @@
   public void testSyncDispatch() {
     manager.setDisplay(realDisplay);

-    PlaceChangeRequesteEvent event = new PlaceChangeRequesteEvent(
+    PlaceChangeRequestEvent event = new PlaceChangeRequestEvent(
         place1);
     eventBus.fireEvent(event);
     assertNull(event.getWarning());
@@ -390,7 +390,7 @@
     assertFalse(activity1.stopped);
     assertFalse(activity1.canceled);

-    event = new PlaceChangeRequesteEvent(place2);
+    event = new PlaceChangeRequestEvent(place2);
     eventBus.fireEvent(event);
     assertNull(event.getWarning());
     assertEquals(activity1.view, realDisplay.widget);
=======================================
--- /trunk/user/test/com/google/gwt/app/place/PlaceControllerTest.java Fri Sep 10 17:56:09 2010 +++ /trunk/user/test/com/google/gwt/app/place/PlaceControllerTest.java Fri Sep 17 09:11:27 2010
@@ -28,11 +28,11 @@
 public class PlaceControllerTest extends TestCase {

   private final class Canceler implements
-      PlaceChangeRequesteEvent.Handler {
+      PlaceChangeRequestEvent.Handler {
     Place calledWith = null;
     String warning = "Stop fool!";

-    public void onPlaceChangeRequest(PlaceChangeRequesteEvent event) {
+    public void onPlaceChangeRequest(PlaceChangeRequestEvent event) {
       calledWith = event.getNewPlace();
       event.setWarning(warning);
     }
@@ -67,7 +67,7 @@
     eventBus.addHandler(PlaceChangeEvent.TYPE, handler);

     Canceler canceler = new Canceler();
-    eventBus.addHandler(PlaceChangeRequesteEvent.TYPE, canceler);
+    eventBus.addHandler(PlaceChangeRequestEvent.TYPE, canceler);

     MyPlace place = new MyPlace();

@@ -81,13 +81,13 @@
     placeController.goTo(place);
     assertEquals(place, canceler.calledWith);
   }
-
+
   public void testConfirmCancelOnWindowClose() {
     SimpleHandler handler = new SimpleHandler();
     eventBus.addHandler(PlaceChangeEvent.TYPE, handler);

     Canceler canceler = new Canceler();
-    eventBus.addHandler(PlaceChangeRequesteEvent.TYPE, canceler);
+    eventBus.addHandler(PlaceChangeRequestEvent.TYPE, canceler);

     assertNull(handler.calledWith);
     assertNull(delegate.message);
@@ -95,7 +95,7 @@
     assertEquals(canceler.warning, delegate.message);
     assertNull(handler.calledWith);
   }
-
+
   public void testSimple() {
     SimpleHandler handler = new SimpleHandler();
     eventBus.addHandler(PlaceChangeEvent.TYPE, handler);

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to