Revision: 8930
Author: rj...@google.com
Date: Mon Oct  4 10:12:28 2010
Log: Fix exit on cancel from create activity. Wasn't going to a
new place, so you couldn't try to create again.

Also restore old behavior of not trying to save w/no changes,
didn't mean to delete it.

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

Review by: cromwell...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=8930

Modified:
 /trunk/user/src/com/google/gwt/app/place/AbstractProxyEditActivity.java
 /trunk/user/src/com/google/gwt/app/place/CreateAndEditProxy.java

=======================================
--- /trunk/user/src/com/google/gwt/app/place/AbstractProxyEditActivity.java Sun Oct 3 19:15:33 2010 +++ /trunk/user/src/com/google/gwt/app/place/AbstractProxyEditActivity.java Mon Oct 4 10:12:28 2010
@@ -63,8 +63,7 @@
   }

   public String mayStop() {
-    if (isWaiting()
-        || (editorDriver != null && editorDriver.flush().isChanged())) {
+    if (isWaiting() || changed()) {
       return "Are you sure you want to abandon your changes?";
     }

@@ -80,6 +79,10 @@
   }

   public void saveClicked() {
+    if (!changed()) {
+      return;
+    }
+
     setWaiting(true);
     editorDriver.flush().fire(new Receiver<Void>() {
       /*
@@ -157,6 +160,10 @@
   protected EntityProxyId<P> getProxyId() {
     return (EntityProxyId<P>) getProxy().stableId();
   }
+
+  private boolean changed() {
+    return editorDriver != null && editorDriver.flush().isChanged();
+  }

   /**
    * @return true if we're waiting for an rpc response.
=======================================
--- /trunk/user/src/com/google/gwt/app/place/CreateAndEditProxy.java Sun Oct 3 19:15:33 2010 +++ /trunk/user/src/com/google/gwt/app/place/CreateAndEditProxy.java Mon Oct 4 10:12:28 2010
@@ -27,18 +27,20 @@
  */
public abstract class CreateAndEditProxy<P extends EntityProxy> extends AbstractProxyEditActivity<P> {

-  private AcceptsOneWidget display;
   private final P proxy;
+  private final PlaceController placeController;
+  private Class<P> proxyClass;

   public CreateAndEditProxy(Class<P> proxyClass, RequestContext request,
       ProxyEditView<P, ?> view, PlaceController placeController) {
     super(view, placeController);
     this.proxy = request.create(proxyClass);
+    this.placeController = placeController;
+    this.proxyClass = proxyClass;
   }

   @Override
   public void start(AcceptsOneWidget display, EventBus eventBus) {
-    this.display = display;
     super.start(display, eventBus);
   }

@@ -51,10 +53,10 @@
   @Override
   protected void exit(boolean saved) {
     if (!saved) {
-      display.setWidget(null);
-    }
-
-    super.exit(saved);
+      placeController.goTo(new ProxyListPlace(proxyClass));
+    } else {
+      super.exit(saved);
+    }
   }

   @Override

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

Reply via email to