From 87a50b9638d27a578f5ff1289581d31b7653b3df Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Thu, 15 Mar 2012 09:57:24 +0000 Subject: [PATCH] move JsFunction to JsUtils and make it public --- .../query/client/builders/JsonBuilderBase.java | 9 +-------- .../google/gwt/query/client/js/JsUtils.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java index 8620501a..e1064332 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java @@ -90,14 +90,7 @@ public abstract class JsonBuilderBase> implements J return (Function)o; } else if (o instanceof JavaScriptObject && JsUtils.isFunction((JavaScriptObject)o)) { - return new Function() { - private native void exec(JavaScriptObject f, Object data) /*-{ - f(data); - }-*/; - public void f() { - exec((JavaScriptObject)o, getData()[0]); - } - }; + return new JsUtils.JsFunction((JavaScriptObject)o); } } return null; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java index b8c3e4e3..488e693b 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java @@ -22,6 +22,7 @@ import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.NodeList; +import com.google.gwt.query.client.Function; import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.Properties; import com.google.gwt.user.client.DOM; @@ -33,6 +34,23 @@ public class JsUtils { private static JsUtilsImpl utilsImpl = GWT.create(JsUtilsImpl.class); + public static class JsFunction extends Function { + private JavaScriptObject jso = null; + public JsFunction(JavaScriptObject f) { + if (JsUtils.isFunction(f)) { + jso = f; + } + } + private native void exec(JavaScriptObject f, Object data) /*-{ + f(data); + }-*/; + public void f() { + if (jso != null) { + exec(jso, getData()[0]); + } + } + } + public static class JsUtilsImpl { public native Element parseXML(String xml) /*-{ return new DOMParser().parseFromString(xml, "text/xml").documentElement; -- 2.39.5