]> source.dussan.org Git - gwtquery.git/commitdiff
make GQueryQueue methods return the type of the plugin instead of itself
authorManolo Carrasco <manolo@apache.org>
Wed, 23 Jun 2010 14:15:15 +0000 (14:15 +0000)
committerManolo Carrasco <manolo@apache.org>
Wed, 23 Jun 2010 14:15:15 +0000 (14:15 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/GQueryQueue.java
samples/src/main/java/gwtquery/samples/client/GwtQueryImageZoom.java

index 1df09436968bd5868cd2616ea3a51591b79b3446..1c95f833a2272a5e05de2cb94b5a4e2bf98940f0 100755 (executable)
@@ -30,7 +30,7 @@ import com.google.gwt.query.client.plugins.PropertiesAnimation.Easing;
 /**\r
  *  Effects plugin for Gwt Query. \r
  */\r
-public class Effects extends GQueryQueue  {\r
+public class Effects extends GQueryQueue<Effects>  {\r
   \r
   /**\r
    * Just a class to store predefined speed constant values.\r
index 1193ebec79eb6d2457f93d383b25bf2cc1d5d7d2..ba7c3a9db28ae8a065e668394701f8f40c9695a9 100644 (file)
@@ -27,7 +27,7 @@ import com.google.gwt.query.client.JSArray;
 /**
  * Class used in plugins which need a queue system.
  */
-public abstract class GQueryQueue extends GQuery {
+public abstract class GQueryQueue<T extends GQueryQueue<?>> extends GQuery {
   
   private static final String QUEUE_DATA_PREFIX = "GQueryQueue_";
 
@@ -50,43 +50,47 @@ public abstract class GQueryQueue extends GQuery {
   /**
    * Removes a queued function from the front of the queue and executes it.
    */
-  public GQueryQueue dequeue() {
+  @SuppressWarnings("unchecked")
+  public T dequeue() {
     for (Element e : elements()) {
       dequeue(e);
     }
-    return this;
+    return (T)this;
   }
 
   /**
    * Adds a new function, to be executed, onto the end of the queue of all
    * matched elements.
    */
-  public GQueryQueue queue(Function func) {
+  @SuppressWarnings("unchecked")
+  public T queue(Function func) {
     for (Element e : elements()) {
       queue(e, func);
     }
-    return this;
+    return (T)this;
   }
 
   /**
    * Replaces the current queue with the given queue on all matched elements.
    */
-  public GQueryQueue queue(Queue<?> queue) {
+  @SuppressWarnings("unchecked")
+  public T queue(Queue<?> queue) {
     for (Element e : elements()) {
       replacequeue(e, queue);
     }
-    return this;
+    return (T)this;
   }
   
   /**
    * Stop the function which is currently in execution, remove it
    * from the queue an start the next one.  
    */
-  public GQueryQueue stop() {
+  @SuppressWarnings("unchecked")
+  public T stop() {
     for (Element e : elements()) {
       stop(e);
     }
-    return this;
+    return (T)this;
   }
 
   protected String getQueueType() {
index 84aafdf9e3e044b6f350d4beb2a06715f1a93f25..7b4679791b5c7d8a66b1b2cdacdaf16bb4c4f5be 100644 (file)
@@ -18,12 +18,12 @@ public class GwtQueryImageZoom implements EntryPoint {
     $("ul.thumb li").hover(new Function() {\r
       public void f(Element e) {\r
       $(e).css("z-index", "10").find("img").addClass("hover")\r
-        .as(Effects.Effects).stop().as(Effects.Effects)\r
+        .as(Effects.Effects).stop()\r
         .animate("marginTop: '-110px', marginLeft: '-110px', top: '50%', left: '50%', width: '174px', height: '174px', padding: '20px'", 200);\r
       }} , new Function() {\r
         public void f(Element e) {\r
       $(e).css("z-index", "0").find("img").removeClass("hover")\r
-        .as(Effects.Effects).stop().as(Effects.Effects)\r
+        .as(Effects.Effects).stop()\r
         .animate("marginTop: '0', marginLeft: '0', top: '0%', left: '0%', width: '100px', height: '100px', padding: '5px'", 600);\r
     }});\r
     \r