From be9ccb89d82178a0c54979063b830c3d484b42c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Manuel=20Carrasco=20Mo=C3=B1ino?= Date: Fri, 15 Mar 2013 21:07:55 +0100 Subject: [PATCH] Change constructors of DeferredPromiseImpl. Some cosmetic changes --- .../com/google/gwt/query/client/Promise.java | 2 +- .../gwt/query/client/plugins/Deferred.java | 57 ++++++++++--------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Promise.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Promise.java index 3efccd90..7d14b439 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Promise.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Promise.java @@ -95,4 +95,4 @@ public interface Promise { * 3rd one will be called when progress notifications are sent. */ Promise then(Function... f); -} \ No newline at end of file +} diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Deferred.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Deferred.java index 69c89573..2c60b104 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Deferred.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Deferred.java @@ -31,30 +31,27 @@ public class Deferred extends GQuery implements Promise.Deferred { * public class used to create customized promises which can manipulate * the asociated deferred object. *
-
-    Promise doSomething = new PromiseFunction() {
-      @Override
-      public void f(Deferred dfd) {
-        dfd.notify("hi");
-        dfd.resolve("done");
-      }
-    };
-    
-    doSomething.progress(new Function() {
-      public void f() {
-        Window.alert("" + arguments[0]);
-      }
-    }).done(new Function() {
-      public void f() {
-        Window.alert("" + arguments[0]);
-      }
-    });
-   
+   *    Promise doSomething = new PromiseFunction() {
+   *      @Override
+   *      public void f(Deferred dfd) {
+   *        dfd.notify("hi");
+   *        dfd.resolve("done");
+   *      }
+   *    };
+   *    
+   *    doSomething.progress(new Function() {
+   *      public void f() {
+   *        Window.alert("" + arguments[0]);
+   *      }
+   *    }).done(new Function() {
+   *      public void f() {
+   *        Window.alert("" + arguments[0]);
+   *      }
+   *    });
    * 
*/ public static abstract class PromiseFunction extends DeferredPromiseImpl { public PromiseFunction() { - super(null); f(dfd); } @@ -71,14 +68,16 @@ public class Deferred extends GQuery implements Promise.Deferred { private static class DeferredPromiseImpl implements Promise { protected com.google.gwt.query.client.plugins.Deferred dfd; - protected DeferredPromiseImpl(Object o) { - if (o instanceof com.google.gwt.query.client.plugins.Deferred) { - dfd = (com.google.gwt.query.client.plugins.Deferred) o; - } else if (o instanceof DeferredPromiseImpl) { - dfd = ((DeferredPromiseImpl)o).dfd;; - } else { - dfd = new com.google.gwt.query.client.plugins.Deferred(); - } + protected DeferredPromiseImpl(com.google.gwt.query.client.plugins.Deferred o) { + dfd = o; + } + + protected DeferredPromiseImpl(DeferredPromiseImpl o) { + dfd = o.dfd; + } + + protected DeferredPromiseImpl() { + dfd = new com.google.gwt.query.client.plugins.Deferred(); } public Promise always(Function... f) { @@ -129,9 +128,11 @@ public class Deferred extends GQuery implements Promise.Deferred { */ private class DoneFnc extends Function { final int idx; + public DoneFnc(int i, Deferred d) { idx = i; } + public Object f(Object... args) { values[idx] = args; if (--remaining == 0) { -- 2.39.5