Package com.google.gwt.query.client

Examples of com.google.gwt.query.client.Function


  public void testThen() {
    new PromiseFunction() {
      public void f(final Deferred dfd) {
        dfd.resolve(5d);
      }
    }.done(new Function() {
      public void f() {
        assertEquals(5d, arguments(0));
      }
    }).then(new Function() {
      public Object f(Object... args) {
        return (Double)args[0] * 2;
      }
    }).done(new Function() {
      public void f() {
        assertEquals(10d, arguments(0));
      }
    });
  }
View Full Code Here


    done = false;
    delayTestFinish(5000);
   
    when(new PromiseFunction() {public void f(Deferred dfd) {
      dfd.resolve("Hi");
    }}).done(new Function(){public void f() {
      assertEquals("Hi", arguments(0));
      finishTest();
      done = true;
    }});
   
View Full Code Here

      .then(new FunctionDeferred() {
          public void f(Deferred dfd) {
            dfd.resolve("then2 " + arguments[0]);
          }
      })
      .fail(new Function() {
        public void f() {
          finishTest();
          fail();
        }
      })
      .done(new Function() {
        public void f() {
          assertEquals("then2 then1 message", arguments(0));
          finishTest();
          done = true;
        }
View Full Code Here

      .when(new PromiseFunction() {
        public void f(Deferred dfd) {
          dfd.resolve("message");
        }
      })
      .and(new Function(){
        public Object f(Object... data) {
          return (arguments[0] + " then1");
        }
      })
      .then(new Function(){
        public void f() {
          // should return the previous value
        }
      })
      .then(new FunctionDeferred() {
          public void f(Deferred dfd) {
            dfd.reject("then2 " + arguments[0]);
          }
      })
      .then(new FunctionDeferred() {
          public void f(Deferred dfd) {
            dfd.resolve("then3 " + arguments[0]);
          }
      })
      .done(new Function() {
        public void f() {
          finishTest();
          fail();
        }
      })
      .fail(new Function() {
        public void f() {
          assertEquals("then2 message then1", arguments(0));
          finishTest();
          done = true;
        }
View Full Code Here

      .or(new FunctionDeferred() {
        public void f(Deferred dfd) {
          dfd.reject(arguments[0] + " or5");
        }
      })
      .done(new Function() {
        public void f() {
          assertEquals("reject-when reject-or1 reject-or2 resolve-or3", arguments(0));
          finishTest();
          done = true;
        }
      })
      .fail(new Function() {
        public void f() {
          finishTest();
          fail();
        }
      });
View Full Code Here

  public void testProtected() {
    delayTestFinish(20);
    GQuery.when(new PromiseFunction() {
      public void f(final Deferred dfd) {
        GQuery.when(new Function() {
          public void f() {
            // This causes an '...IllegalAccessError: tried to access class ...Deferred$DeferredPromiseImpl ...'
            // in dev-mode when resolve is protected. It works in JRE and production though.
            resolve.f();
          }
        });
      }
    }).then(new FunctionDeferred() {
      protected void f(Deferred dfd) {
        GQuery.when(new Function() {
          public void f() {
            resolve.f();
          }
        });
      }
    }).done(new Function() {
      public void f() {
        finishTest();
      }
    });
  }
View Full Code Here

      protected void f(Deferred dfd) {
        dfd.resolve(deferredData);
      }
    };

    Function setDeferredDataToTrue = new Function(){
      public void f() {
        deferredData = true;
      }
    };

    Function setDeferredDataToFalse = new Function() {
      public void f() {
        deferredData = false;
      }
    };

    Function assertDeferredDataIsFalse = new Function() {
      public void f() {
        Boolean data = arguments(0);
        assertFalse(data);
      }
    };

    Function assertDeferredDataIsTrue = new Function() {
      public void f() {
        Boolean data = arguments(0);
        assertTrue(data);
      }
    };
View Full Code Here

    final String ease = easing == null ? "ease" : easing.toString();
    final List<String> transProps = filterTransitionPropertyNames(cssProps);
    final double queuedAt = delay > 0 ? Duration.currentTimeMillis() : 0;

    // Use gQuery queue, so as we can chain transitions, animations etc.
    queue(new Function(){
      public void f() {
        // This is called once per element
        final String oldTransitionValue = $(this).css(transition);
        // Recompute delay based on the time spent in the queue
        int d = Math.max(0, delay - (int)(Duration.currentTimeMillis() - queuedAt));
View Full Code Here

      eventName = hook != null ? hook.getDelegateType() : eventName;
      String originalEventName = hook != null ? hook.getOriginalType() : null;

      int b = Event.getTypeInt(eventName);
      for (Function function : funcs) {
        Function handler = hook != null ? hook.createDelegateHandler(function) : function;
        bind(b, nameSpace, eventName, originalEventName, data, handler, -1);
      }
    }
  }
View Full Code Here

      eventName = hook != null ? hook.getDelegateType() : eventName;
      String originalEventName = hook != null ? hook.getOriginalType() : null;

      int b = Event.getTypeInt(eventName);
      for (Function function : funcs) {
        Function handler = hook != null ? hook.createDelegateHandler(function) : function;
        live(b, nameSpace, eventName, originalEventName, cssSelector, data, handler);
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.query.client.Function

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.