From 9d1a308b92d23304f3843da7908f6851d83d38a0 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Thu, 25 Dec 2014 14:28:23 +0100 Subject: Implement GQuery.ready missing method --- .../java/com/google/gwt/query/client/GQuery.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'gwtquery-core') diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java index 098cb2da..d5fb0d99 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java @@ -13,6 +13,8 @@ */ package com.google.gwt.query.client; +import static com.google.gwt.query.client.GQuery.$; +import static com.google.gwt.query.client.GQuery.document; import static com.google.gwt.query.client.plugins.QueuePlugin.Queue; import com.google.gwt.core.client.GWT; @@ -54,6 +56,7 @@ import com.google.gwt.query.client.plugins.Widgets; import com.google.gwt.query.client.plugins.ajax.Ajax; import com.google.gwt.query.client.plugins.ajax.Ajax.Settings; import com.google.gwt.query.client.plugins.deferred.Deferred; +import com.google.gwt.query.client.plugins.deferred.PromiseFunction; import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.Easing; import com.google.gwt.query.client.plugins.events.EventsListener; import com.google.gwt.query.client.plugins.widgets.WidgetsUtils; @@ -3812,6 +3815,30 @@ public class GQuery implements Lazy { return as(Queue).queue(queueName, f); } + /** + * Specify a function to execute when the DOM is fully loaded. + * + * While JavaScript provides the load event for executing code when a page is rendered, this event + * is not seen if we attach an event listener after the document has been loaded. + * This guarantees that our gwt code will be executed either it's executed synchronously before the + * DOM has been rendered (ie: single script linker in header) or asynchronously. + */ + public Promise ready(Function... fncs) { + return new PromiseFunction() { + public void f(final com.google.gwt.query.client.Promise.Deferred dfd) { + if ("complete" == $(document).prop("readyState")) { + dfd.resolve(); + } else { + $(document).on("load", new Function() { + public void f() { + dfd.resolve(); + } + }); + } + } + }.done(fncs); + } + /** * Removes all matched elements from the DOM. */ -- cgit v1.2.3 From ea1d26c2ffc9d82a515b41636abd8b2da3af61b1 Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Wed, 24 Dec 2014 11:58:39 +0100 Subject: Parsing only methods specified in JsonBuilder interface from a given json. Signed-off-by: Manolo Carrasco --- .../gwt/query/client/builders/JsonBuilder.java | 6 +++ .../com/google/gwt/query/vm/JsonFactoryJre.java | 22 ++++++++++- .../google/gwt/query/vm/JsonFactoryParseTest.java | 46 ++++++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 gwtquery-core/src/test/java/com/google/gwt/query/vm/JsonFactoryParseTest.java (limited to 'gwtquery-core') diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilder.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilder.java index b5f30451..9dd3df78 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilder.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilder.java @@ -30,6 +30,12 @@ public interface JsonBuilder extends IsProperties { */ J parse(String json, boolean fix); + /** + * Parses a json string and loads the resulting properties object. + * It will parse only the json's properties which are in clz. + */ + J parseStrict(String json, Class clz); + /** * Returns the wrapped object, normally a Properties jso in client * but can be used to return the underlying Json implementation in JVM diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java index 7bd8c792..dfdb4cf2 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java @@ -199,8 +199,10 @@ public class JsonFactoryJre implements JsonFactory { Class[] classes = method.getParameterTypes(); int largs = classes.length; + String regexGetOrSet = "^[gs]et"; + Name name = method.getAnnotation(Name.class); - String attr = name != null ? name.value() : deCapitalize(mname.replaceFirst("^[gs]et", "")); + String attr = name != null ? name.value() : deCapitalize(mname.replaceFirst(regexGetOrSet, "")); if ("getFieldNames".equals(mname)) { return jsonObject.keys(); @@ -218,6 +220,11 @@ public class JsonFactoryJre implements JsonFactory { json = Properties.wrapPropertiesString(json); } jsonObject = Json.parse(json); + } else if (largs > 1 && ("parseStrict".equals(mname))) { + Class clz = (Class) args[1]; + Class proxie = (Class) Proxy.getProxyClass(clz.getClassLoader(), new Class[] {clz}); + JsonObject jsonArg = Json.parse((String)args[0]); + parseStrict(proxie, jsonArg, regexGetOrSet); } else if (mname.matches("toString")) { return jsonObject.toString(); } else if (mname.matches("toJsonWithName")) { @@ -244,6 +251,19 @@ public class JsonFactoryJre implements JsonFactory { return null; } + public void parseStrict(Class proxie, JsonObject jsonArg, + String regexGetOrSet) { + for(Method m: proxie.getMethods()) { + if (!m.getName().matches("^set.+")) { + continue; + } + String attrJs = deCapitalize(m.getName().replaceFirst(regexGetOrSet, "")); + Object value = jsonArg.get(attrJs); + setValue(null, jsonObject, attrJs, value); + } + + } + private String deCapitalize(String s) { return s != null && s.length() > 0 ? s.substring(0, 1).toLowerCase() + s.substring(1) : s; } diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/vm/JsonFactoryParseTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/vm/JsonFactoryParseTest.java new file mode 100644 index 00000000..48272a61 --- /dev/null +++ b/gwtquery-core/src/test/java/com/google/gwt/query/vm/JsonFactoryParseTest.java @@ -0,0 +1,46 @@ +package com.google.gwt.query.vm; + +import com.google.gwt.query.client.GQ; +import com.google.gwt.query.client.builders.JsonBuilder; + +import org.junit.Assert; +import org.junit.Test; + +public class JsonFactoryParseTest { + + public interface GUser extends JsonBuilder{ + int getAge(); + void setAge(int age); + + String getName(); + void setName(String name); + } + + public static final String JSON_USER_EXAMPLE = " { " + + " 'email': 'foo@bar.com', " + + " 'age': 27, " + + " 'name': 'Foo Bar' " + + " }"; + + @Test public void + test_parse_json() { + GUser entity = GQ.create(GUser.class); + entity.parse(JSON_USER_EXAMPLE); + System.out.println(entity.toJson()); + + Assert.assertEquals(27, entity.getAge()); + Assert.assertEquals("Foo Bar", entity.getName()); + Assert.assertTrue(entity.toJson().contains("email")); + } + + @Test public void + test_parse_strict_json() { + GUser entity = GQ.create(GUser.class); + entity.parseStrict(JSON_USER_EXAMPLE, GUser.class); + + Assert.assertEquals(27, entity.getAge()); + Assert.assertEquals("Foo Bar", entity.getName()); + Assert.assertFalse(entity.toJson().contains("email")); + } + +} -- cgit v1.2.3 From b0f52ef82a0e432eeab694add4924b21d103bdd6 Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Wed, 24 Dec 2014 16:23:39 +0100 Subject: Implementing strip() on isProperties Signed-off-by: Manolo Carrasco --- .../com/google/gwt/query/client/IsProperties.java | 7 +++- .../com/google/gwt/query/client/Properties.java | 6 +++ .../gwt/query/client/builders/JsonBuilder.java | 6 --- .../gwt/query/client/builders/JsonBuilderBase.java | 9 +++++ .../com/google/gwt/query/vm/JsonFactoryJre.java | 37 ++++++++++------- .../query/client/dbinding/DataBindingTestJre.java | 46 ++++++++++++++++++++++ .../google/gwt/query/vm/JsonFactoryParseTest.java | 16 +++++--- 7 files changed, 101 insertions(+), 26 deletions(-) (limited to 'gwtquery-core') diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/IsProperties.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/IsProperties.java index bcd79cdb..3b88edf5 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/IsProperties.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/IsProperties.java @@ -31,6 +31,12 @@ public interface IsProperties { * parses a json string and loads the resulting properties object. */ T parse(String json); + + /** + * Removes the extra JSON and leaves only the setters/getters described + * in the JsonBuilder interface. + */ + T strip(); /** * Returns the underlying object, normally a Properties jso in client @@ -77,7 +83,6 @@ public interface IsProperties { */ String getJsonName(); - /** * converts a JsonBuilder instance into another JsonBuilder type but * preserving the underlying data object. diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java index db35f5d6..91259103 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java @@ -219,6 +219,12 @@ public class Properties extends JavaScriptObject implements IsProperties { return getDataImpl(); } + @SuppressWarnings("unchecked") + @Override + public final J strip() { + return getDataImpl(); + } + public final J parse(String json) { return load(JsUtils.parseJSON(json)); } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilder.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilder.java index 9dd3df78..b5f30451 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilder.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilder.java @@ -30,12 +30,6 @@ public interface JsonBuilder extends IsProperties { */ J parse(String json, boolean fix); - /** - * Parses a json string and loads the resulting properties object. - * It will parse only the json's properties which are in clz. - */ - J parseStrict(String json, Class clz); - /** * Returns the wrapped object, normally a Properties jso in client * but can be used to return the underlying Json implementation in JVM 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 c09836a5..bd5ad66e 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 @@ -37,6 +37,15 @@ public abstract class JsonBuilderBase> implements J public J parse(String json, boolean fix) { return fix ? parse(Properties.wrapPropertiesString(json)) : parse(json); } + + @SuppressWarnings("unchecked") + @Override + public J strip() { + String[] methods = getFieldNames(); //EXCEPTION + String[] jsonMethods = p.getFieldNames(); // OK + System.out.println(methods); + return (J)this; + } @SuppressWarnings("unchecked") @Override diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java index dfdb4cf2..634a483d 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java @@ -15,6 +15,7 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.List; @@ -220,11 +221,10 @@ public class JsonFactoryJre implements JsonFactory { json = Properties.wrapPropertiesString(json); } jsonObject = Json.parse(json); - } else if (largs > 1 && ("parseStrict".equals(mname))) { - Class clz = (Class) args[1]; - Class proxie = (Class) Proxy.getProxyClass(clz.getClassLoader(), new Class[] {clz}); - JsonObject jsonArg = Json.parse((String)args[0]); - parseStrict(proxie, jsonArg, regexGetOrSet); + } else if ("strip".equals(mname)) { + List keys = Arrays.asList(jsonObject.keys()); + Class type = proxy.getClass().getInterfaces()[0]; + strip(keys, type.getMethods()); } else if (mname.matches("toString")) { return jsonObject.toString(); } else if (mname.matches("toJsonWithName")) { @@ -251,19 +251,28 @@ public class JsonFactoryJre implements JsonFactory { return null; } - public void parseStrict(Class proxie, JsonObject jsonArg, - String regexGetOrSet) { - for(Method m: proxie.getMethods()) { - if (!m.getName().matches("^set.+")) { - continue; + private void strip(List keys, Method[] methods) { + for (String key: keys) { + boolean isInType = isInType(key, methods); + if (!isInType) { + jsonObject.remove(key); } - String attrJs = deCapitalize(m.getName().replaceFirst(regexGetOrSet, "")); - Object value = jsonArg.get(attrJs); - setValue(null, jsonObject, attrJs, value); + } + } + + private boolean isInType(String key, Method[] methods) { + if (methods == null || methods.length == 0) { + return false; } + for(Method m : methods) { + if (m.getName().toLowerCase().contains(key)) { + return true; + } + } + return false; } - + private String deCapitalize(String s) { return s != null && s.length() > 0 ? s.substring(0, 1).toLowerCase() + s.substring(1) : s; } diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java index 7158fe8d..be0a83f7 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java @@ -29,6 +29,7 @@ import java.util.Arrays; import java.util.Date; import java.util.List; + /** * Tests for Deferred which can run either in JVM and GWT */ @@ -152,4 +153,49 @@ public class DataBindingTestJre extends GWTTestCase { assertEquals(1, c.get("a").intValue()); } + + public interface GUser extends JsonBuilder{ + int getAge(); + void setAge(int age); + + String getName(); + void setName(String name); + + GUser address(String address); + String address(); + } + + public static final String JSON_USER_EXAMPLE = " { " + + " 'email': 'foo@bar.com', " + + " 'age': 27, " + + " 'name': 'Foo Bar', " + + " 'address': 'Street Foo N6' " + + " }"; + + public void + test_parse_json() { + GUser entity = GQ.create(GUser.class); + entity.parse(JSON_USER_EXAMPLE, true); + + assertEquals(27, entity.getAge()); + assertEquals("Foo Bar", entity.getName()); + assertEquals("Street Foo N6", entity.address()); + assertTrue(entity.toJson().contains("email")); + } + + public void + test_parse_strict_json() { + GUser entity = GQ.create(GUser.class); + entity.parse(JSON_USER_EXAMPLE, true); + for(String s: entity.getFieldNames()) { + System.out.println("Moe: "+s); + } + + entity.strip(); + System.out.println(entity.toJson()); + assertEquals(27, entity.getAge()); + assertEquals("Foo Bar", entity.getName()); + assertEquals("Street Foo N6", entity.address()); + assertFalse(entity.toJson().contains("email")); + } } \ No newline at end of file diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/vm/JsonFactoryParseTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/vm/JsonFactoryParseTest.java index 48272a61..b4ea332f 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/vm/JsonFactoryParseTest.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/vm/JsonFactoryParseTest.java @@ -14,32 +14,38 @@ public class JsonFactoryParseTest { String getName(); void setName(String name); + + GUser address(String address); + String address(); } public static final String JSON_USER_EXAMPLE = " { " + " 'email': 'foo@bar.com', " + " 'age': 27, " + - " 'name': 'Foo Bar' " + + " 'name': 'Foo Bar', " + + " 'address': 'Street Foo N6' " + " }"; @Test public void test_parse_json() { GUser entity = GQ.create(GUser.class); entity.parse(JSON_USER_EXAMPLE); - System.out.println(entity.toJson()); - + Assert.assertEquals(27, entity.getAge()); Assert.assertEquals("Foo Bar", entity.getName()); + Assert.assertEquals("Street Foo N6", entity.address()); Assert.assertTrue(entity.toJson().contains("email")); } @Test public void test_parse_strict_json() { GUser entity = GQ.create(GUser.class); - entity.parseStrict(JSON_USER_EXAMPLE, GUser.class); - + entity.parse(JSON_USER_EXAMPLE); + entity.strip(); + System.out.println(entity.toJson()); Assert.assertEquals(27, entity.getAge()); Assert.assertEquals("Foo Bar", entity.getName()); + Assert.assertEquals("Street Foo N6", entity.address()); Assert.assertFalse(entity.toJson().contains("email")); } -- cgit v1.2.3 From 44702affcd643c1ddb85c7ac0cce88da75f9a3dc Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Wed, 24 Dec 2014 19:05:29 +0100 Subject: Fix client-side code Signed-off-by: Manolo Carrasco --- .../com/google/gwt/query/client/Properties.java | 14 +++--- .../gwt/query/client/builders/JsonBuilderBase.java | 33 +++++++++----- .../gwt/query/rebind/JsonBuilderGenerator.java | 2 +- .../query/client/dbinding/DataBindingTestJre.java | 20 +++------ .../google/gwt/query/vm/JsonFactoryParseTest.java | 52 ---------------------- 5 files changed, 36 insertions(+), 85 deletions(-) delete mode 100644 gwtquery-core/src/test/java/com/google/gwt/query/vm/JsonFactoryParseTest.java (limited to 'gwtquery-core') diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java index 91259103..0b978548 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java @@ -142,7 +142,7 @@ public class Properties extends JavaScriptObject implements IsProperties { public final Object getObject(Object name) { return c().get(String.valueOf(name)); } - + public final Properties getProperties(Object name) { return getJavaScriptObject(name); } @@ -176,9 +176,9 @@ public class Properties extends JavaScriptObject implements IsProperties { /** * Adds a new native js function to the properties object. * This native function will wrap the passed java Function. - * + * * Its useful for exporting or importing to javascript. - * + * */ public final native void setFunction(T name, Function f) /*-{ if (!f) return; @@ -219,12 +219,10 @@ public class Properties extends JavaScriptObject implements IsProperties { return getDataImpl(); } - @SuppressWarnings("unchecked") - @Override public final J strip() { return getDataImpl(); } - + public final J parse(String json) { return load(JsUtils.parseJSON(json)); } @@ -236,11 +234,11 @@ public class Properties extends JavaScriptObject implements IsProperties { public final String toJson() { return toJsonString(); } - + public final String toJsonWithName() { return toJsonWithName(getJsonName()); } - + public final String toJsonWithName(String name) { return "{\"" + name + "\":{" + toJson() + "}"; } 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 bd5ad66e..baf42181 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 @@ -19,12 +19,18 @@ import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.query.client.IsProperties; import com.google.gwt.query.client.Properties; +import com.google.gwt.query.client.js.JsCache; import com.google.gwt.query.client.js.JsObjectArray; import com.google.gwt.query.client.js.JsUtils; +import com.google.gwt.user.client.Window; + +import java.util.Arrays; +import java.util.List; public abstract class JsonBuilderBase> implements JsonBuilder { protected Properties p = Properties.create(); + protected String[] fieldNames = new String[] {}; @SuppressWarnings("unchecked") @Override @@ -37,13 +43,16 @@ public abstract class JsonBuilderBase> implements J public J parse(String json, boolean fix) { return fix ? parse(Properties.wrapPropertiesString(json)) : parse(json); } - + @SuppressWarnings("unchecked") @Override public J strip() { - String[] methods = getFieldNames(); //EXCEPTION - String[] jsonMethods = p.getFieldNames(); // OK - System.out.println(methods); + List names = Arrays.asList(getFieldNames()); + for (String jsonName : p.getFieldNames()) { + if (!names.contains(jsonName)) { + p.cast().delete(jsonName); + } + } return (J)this; } @@ -107,7 +116,7 @@ public abstract class JsonBuilderBase> implements J public String toJson() { return p.tostring(); } - + public String toJsonWithName() { return "{\"" + getJsonName() + "\":" + p.tostring() + "}"; } @@ -117,22 +126,22 @@ public abstract class JsonBuilderBase> implements J public Properties getProperties() { return p; } - + @Override public String toQueryString() { return p.toQueryString(); } - + @SuppressWarnings("unchecked") @Override public Properties getDataImpl() { return p; } - + public T get(Object key) { return p.get(key); } - + @SuppressWarnings("unchecked") public T set(Object key, Object val) { if (val instanceof IsProperties) { @@ -142,8 +151,12 @@ public abstract class JsonBuilderBase> implements J } return (T)this; } - + public T as(Class clz) { return p.as(clz); } + + public final String[] getFieldNames() { + return fieldNames; + } } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java index c2383c19..197e23b8 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java @@ -143,7 +143,7 @@ public class JsonBuilderGenerator extends Generator { for (Iterator it = attrs.iterator(); it.hasNext();) { ret += (ret.isEmpty() ? "" : ",") + "\"" + it.next() + "\""; } - sw.println("public final String[] getFieldNames() {return new String[]{" + ret + "};}"); + sw.println("{ fieldNames = new String[]{" + ret + "}; }"); } public void generateMethod(SourceWriter sw, JMethod method, String name, TreeLogger logger) diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java index be0a83f7..5aeaacb7 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java @@ -15,7 +15,6 @@ */ package com.google.gwt.query.client.dbinding; -import com.google.gwt.core.shared.GWT; import com.google.gwt.junit.client.GWTTestCase; import com.google.gwt.query.client.Function; import com.google.gwt.query.client.GQ; @@ -23,8 +22,6 @@ import com.google.gwt.query.client.IsProperties; import com.google.gwt.query.client.builders.JsonBuilder; import com.google.gwt.query.client.builders.Name; -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; import java.util.Arrays; import java.util.Date; import java.util.List; @@ -153,46 +150,41 @@ public class DataBindingTestJre extends GWTTestCase { assertEquals(1, c.get("a").intValue()); } - + public interface GUser extends JsonBuilder{ int getAge(); void setAge(int age); String getName(); void setName(String name); - + GUser address(String address); String address(); } - + public static final String JSON_USER_EXAMPLE = " { " + " 'email': 'foo@bar.com', " + " 'age': 27, " + " 'name': 'Foo Bar', " + " 'address': 'Street Foo N6' " + " }"; - + public void test_parse_json() { GUser entity = GQ.create(GUser.class); entity.parse(JSON_USER_EXAMPLE, true); - + assertEquals(27, entity.getAge()); assertEquals("Foo Bar", entity.getName()); assertEquals("Street Foo N6", entity.address()); assertTrue(entity.toJson().contains("email")); } - + public void test_parse_strict_json() { GUser entity = GQ.create(GUser.class); entity.parse(JSON_USER_EXAMPLE, true); - for(String s: entity.getFieldNames()) { - System.out.println("Moe: "+s); - } - entity.strip(); - System.out.println(entity.toJson()); assertEquals(27, entity.getAge()); assertEquals("Foo Bar", entity.getName()); assertEquals("Street Foo N6", entity.address()); diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/vm/JsonFactoryParseTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/vm/JsonFactoryParseTest.java deleted file mode 100644 index b4ea332f..00000000 --- a/gwtquery-core/src/test/java/com/google/gwt/query/vm/JsonFactoryParseTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.google.gwt.query.vm; - -import com.google.gwt.query.client.GQ; -import com.google.gwt.query.client.builders.JsonBuilder; - -import org.junit.Assert; -import org.junit.Test; - -public class JsonFactoryParseTest { - - public interface GUser extends JsonBuilder{ - int getAge(); - void setAge(int age); - - String getName(); - void setName(String name); - - GUser address(String address); - String address(); - } - - public static final String JSON_USER_EXAMPLE = " { " + - " 'email': 'foo@bar.com', " + - " 'age': 27, " + - " 'name': 'Foo Bar', " + - " 'address': 'Street Foo N6' " + - " }"; - - @Test public void - test_parse_json() { - GUser entity = GQ.create(GUser.class); - entity.parse(JSON_USER_EXAMPLE); - - Assert.assertEquals(27, entity.getAge()); - Assert.assertEquals("Foo Bar", entity.getName()); - Assert.assertEquals("Street Foo N6", entity.address()); - Assert.assertTrue(entity.toJson().contains("email")); - } - - @Test public void - test_parse_strict_json() { - GUser entity = GQ.create(GUser.class); - entity.parse(JSON_USER_EXAMPLE); - entity.strip(); - System.out.println(entity.toJson()); - Assert.assertEquals(27, entity.getAge()); - Assert.assertEquals("Foo Bar", entity.getName()); - Assert.assertEquals("Street Foo N6", entity.address()); - Assert.assertFalse(entity.toJson().contains("email")); - } - -} -- cgit v1.2.3 From 8b5e7e3ca0f571ca048c04b02e29f342d125a198 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Thu, 25 Dec 2014 21:18:10 +0100 Subject: Make strip recursive in server side. Signed-off-by: Manolo Carrasco --- .../gwt/query/client/builders/JsonBuilderBase.java | 2 + .../com/google/gwt/query/vm/JsonFactoryJre.java | 71 +++++++++++++--------- .../query/client/dbinding/DataBindingTestJre.java | 47 ++++++++------ 3 files changed, 73 insertions(+), 47 deletions(-) (limited to 'gwtquery-core') 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 baf42181..57f5a909 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 @@ -49,6 +49,8 @@ public abstract class JsonBuilderBase> implements J public J strip() { List names = Arrays.asList(getFieldNames()); for (String jsonName : p.getFieldNames()) { + // TODO: figure out a way so as we can generate some marks in generated class in + // order to call getters to return JsonBuilder object given an an attribute name if (!names.contains(jsonName)) { p.cast().delete(jsonName); } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java index 634a483d..479b09d2 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java @@ -1,13 +1,5 @@ package com.google.gwt.query.vm; -import com.google.gwt.query.client.Function; -import com.google.gwt.query.client.IsProperties; -import com.google.gwt.query.client.Properties; -import com.google.gwt.query.client.builders.JsonBuilder; -import com.google.gwt.query.client.builders.JsonFactory; -import com.google.gwt.query.client.builders.Name; -import com.google.gwt.query.rebind.JsonBuilderGenerator; - import java.lang.reflect.Array; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; @@ -15,10 +7,19 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.util.ArrayList; -import java.util.Arrays; import java.util.Date; +import java.util.HashSet; +import java.util.Hashtable; import java.util.List; +import com.google.gwt.query.client.Function; +import com.google.gwt.query.client.IsProperties; +import com.google.gwt.query.client.Properties; +import com.google.gwt.query.client.builders.JsonBuilder; +import com.google.gwt.query.client.builders.JsonFactory; +import com.google.gwt.query.client.builders.Name; +import com.google.gwt.query.rebind.JsonBuilderGenerator; + import elemental.json.Json; import elemental.json.JsonArray; import elemental.json.JsonBoolean; @@ -200,10 +201,8 @@ public class JsonFactoryJre implements JsonFactory { Class[] classes = method.getParameterTypes(); int largs = classes.length; - String regexGetOrSet = "^[gs]et"; - Name name = method.getAnnotation(Name.class); - String attr = name != null ? name.value() : deCapitalize(mname.replaceFirst(regexGetOrSet, "")); + String attr = name != null ? name.value() : methodName2AttrName(mname); if ("getFieldNames".equals(mname)) { return jsonObject.keys(); @@ -222,9 +221,7 @@ public class JsonFactoryJre implements JsonFactory { } jsonObject = Json.parse(json); } else if ("strip".equals(mname)) { - List keys = Arrays.asList(jsonObject.keys()); - Class type = proxy.getClass().getInterfaces()[0]; - strip(keys, type.getMethods()); + stripProxy((JsonBuilder)proxy); } else if (mname.matches("toString")) { return jsonObject.toString(); } else if (mname.matches("toJsonWithName")) { @@ -251,26 +248,40 @@ public class JsonFactoryJre implements JsonFactory { return null; } - private void strip(List keys, Method[] methods) { - for (String key: keys) { - boolean isInType = isInType(key, methods); - if (!isInType) { + /** + * @param proxy + */ + private void stripProxy(JsonBuilder proxy) { + Class type = proxy.getClass().getInterfaces()[0]; + HashSet valid = new HashSet(); + Hashtable getters = new Hashtable(); + for (Method m : type.getMethods()) { + String attr = methodName2AttrName(m.getName()); + valid.add(attr); + Class[] classes = m.getParameterTypes(); + if (classes.length == 0) { + if (IsProperties.class.isAssignableFrom(m.getReturnType())) { + getters.put(attr, m); + } + } + } + for (String key: jsonObject.keys()) { + String name = methodName2AttrName(key); + Method getter = getters.get(name); + if (!valid.contains(name)) { jsonObject.remove(key); + } else if (getter != null) { + try { + ((IsProperties)invoke(proxy, getter, new Object[]{})).strip(); + } catch (Throwable e) { + e.printStackTrace(); + } } } } - private boolean isInType(String key, Method[] methods) { - if (methods == null || methods.length == 0) { - return false; - } - - for(Method m : methods) { - if (m.getName().toLowerCase().contains(key)) { - return true; - } - } - return false; + private String methodName2AttrName(String s) { + return deCapitalize(s.replaceFirst("^[gs]et", "")); } private String deCapitalize(String s) { diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java index 5aeaacb7..3d1273c1 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java @@ -15,6 +15,7 @@ */ package com.google.gwt.query.client.dbinding; +import com.google.gwt.core.shared.GWT; import com.google.gwt.junit.client.GWTTestCase; import com.google.gwt.query.client.Function; import com.google.gwt.query.client.GQ; @@ -151,33 +152,38 @@ public class DataBindingTestJre extends GWTTestCase { assertEquals(1, c.get("a").intValue()); } - public interface GUser extends JsonBuilder{ - int getAge(); - void setAge(int age); + public interface GAddress extends JsonBuilder { + String street(); + String city(); + } + public interface GUser extends JsonBuilder { + int getAge(); String getName(); - void setName(String name); - - GUser address(String address); - String address(); + GAddress address(); } - public static final String JSON_USER_EXAMPLE = " { " + - " 'email': 'foo@bar.com', " + - " 'age': 27, " + - " 'name': 'Foo Bar', " + - " 'address': 'Street Foo N6' " + - " }"; + public static final String JSON_USER_EXAMPLE = " { " + + " 'email': 'foo@bar.com', " + + " 'age': 27, " + + " 'name': 'Foo Bar', " + + " 'address': {" + + " 'street': 'Street Foo N6', " + + " 'phone': '670'" + + " }" + + "}"; public void test_parse_json() { GUser entity = GQ.create(GUser.class); entity.parse(JSON_USER_EXAMPLE, true); + assertNotNull(entity.get("email")); assertEquals(27, entity.getAge()); assertEquals("Foo Bar", entity.getName()); - assertEquals("Street Foo N6", entity.address()); - assertTrue(entity.toJson().contains("email")); + assertNotNull(entity.address()); + assertEquals("Street Foo N6", entity.address().street()); + assertNotNull(entity.address().get("phone")); } public void @@ -185,9 +191,16 @@ public class DataBindingTestJre extends GWTTestCase { GUser entity = GQ.create(GUser.class); entity.parse(JSON_USER_EXAMPLE, true); entity.strip(); + + assertNull(entity.get("email")); assertEquals(27, entity.getAge()); assertEquals("Foo Bar", entity.getName()); - assertEquals("Street Foo N6", entity.address()); - assertFalse(entity.toJson().contains("email")); + assertNotNull(entity.address()); + assertEquals("Street Foo N6", entity.address().street()); + + // Recursion not implemented in client side + if (GWT.isScript()) { + assertNull(entity.address().get("phone")); + } } } \ No newline at end of file -- cgit v1.2.3 From c6fd41796742df282f523bfddedba31a69883f44 Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Fri, 26 Dec 2014 14:26:07 +0100 Subject: Fix for @Name in strip() implementation on the VM (added some refactors) --- .../com/google/gwt/query/client/Properties.java | 5 +- .../com/google/gwt/query/vm/JsonFactoryJre.java | 62 ++++++++++------------ .../google/gwt/query/vm/strip/JsonStripJre.java | 61 +++++++++++++++++++++ .../google/gwt/query/vm/util/MethodNameParser.java | 12 +++++ .../query/client/dbinding/DataBindingTestJre.java | 6 +++ 5 files changed, 109 insertions(+), 37 deletions(-) create mode 100644 gwtquery-core/src/main/java/com/google/gwt/query/vm/strip/JsonStripJre.java create mode 100644 gwtquery-core/src/main/java/com/google/gwt/query/vm/util/MethodNameParser.java (limited to 'gwtquery-core') diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java index 0b978548..2c2ba54c 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java @@ -218,9 +218,10 @@ public class Properties extends JavaScriptObject implements IsProperties { } return getDataImpl(); } - + + @SuppressWarnings("unchecked") public final J strip() { - return getDataImpl(); + return (J)this; } public final J parse(String json) { diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java index 479b09d2..799cf256 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java @@ -1,5 +1,15 @@ package com.google.gwt.query.vm; +import com.google.gwt.query.client.Function; +import com.google.gwt.query.client.IsProperties; +import com.google.gwt.query.client.Properties; +import com.google.gwt.query.client.builders.JsonBuilder; +import com.google.gwt.query.client.builders.JsonFactory; +import com.google.gwt.query.client.builders.Name; +import com.google.gwt.query.rebind.JsonBuilderGenerator; +import com.google.gwt.query.vm.strip.JsonStripJre; +import com.google.gwt.query.vm.util.MethodNameParser; + import java.lang.reflect.Array; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; @@ -12,14 +22,6 @@ import java.util.HashSet; import java.util.Hashtable; import java.util.List; -import com.google.gwt.query.client.Function; -import com.google.gwt.query.client.IsProperties; -import com.google.gwt.query.client.Properties; -import com.google.gwt.query.client.builders.JsonBuilder; -import com.google.gwt.query.client.builders.JsonFactory; -import com.google.gwt.query.client.builders.Name; -import com.google.gwt.query.rebind.JsonBuilderGenerator; - import elemental.json.Json; import elemental.json.JsonArray; import elemental.json.JsonBoolean; @@ -202,7 +204,7 @@ public class JsonFactoryJre implements JsonFactory { int largs = classes.length; Name name = method.getAnnotation(Name.class); - String attr = name != null ? name.value() : methodName2AttrName(mname); + String attr = name != null ? name.value() : MethodNameParser.methodName2AttrName(mname); if ("getFieldNames".equals(mname)) { return jsonObject.keys(); @@ -253,39 +255,29 @@ public class JsonFactoryJre implements JsonFactory { */ private void stripProxy(JsonBuilder proxy) { Class type = proxy.getClass().getInterfaces()[0]; - HashSet valid = new HashSet(); - Hashtable getters = new Hashtable(); - for (Method m : type.getMethods()) { - String attr = methodName2AttrName(m.getName()); - valid.add(attr); - Class[] classes = m.getParameterTypes(); - if (classes.length == 0) { - if (IsProperties.class.isAssignableFrom(m.getReturnType())) { - getters.put(attr, m); - } - } - } + + HashSet valid = JsonStripJre.getValidMethodsFrom(type.getMethods()); + Hashtable recursiveBuilders = JsonStripJre.getJsonBuildersFrom(type.getMethods()); + for (String key: jsonObject.keys()) { - String name = methodName2AttrName(key); - Method getter = getters.get(name); + String name = MethodNameParser.methodName2AttrName(key); if (!valid.contains(name)) { jsonObject.remove(key); - } else if (getter != null) { - try { - ((IsProperties)invoke(proxy, getter, new Object[]{})).strip(); - } catch (Throwable e) { - e.printStackTrace(); - } + continue; + } + Method recursiveBuilder = recursiveBuilders.get(name); + if (recursiveBuilder != null) { + callRecursiveStrip(proxy,recursiveBuilder); } } } - private String methodName2AttrName(String s) { - return deCapitalize(s.replaceFirst("^[gs]et", "")); - } - - private String deCapitalize(String s) { - return s != null && s.length() > 0 ? s.substring(0, 1).toLowerCase() + s.substring(1) : s; + private void callRecursiveStrip(JsonBuilder proxy, Method recursiveBuilder) { + try { + ((IsProperties)invoke(proxy, recursiveBuilder, new Object[]{})).strip(); + } catch (Throwable e) { + e.printStackTrace(); + } } private String getDataBindingClassName(Class type) { diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/strip/JsonStripJre.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/strip/JsonStripJre.java new file mode 100644 index 00000000..19e961af --- /dev/null +++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/strip/JsonStripJre.java @@ -0,0 +1,61 @@ +package com.google.gwt.query.vm.strip; + +import com.google.gwt.query.client.IsProperties; +import com.google.gwt.query.client.builders.Name; +import com.google.gwt.query.vm.util.MethodNameParser; + +import java.lang.reflect.Method; +import java.util.HashSet; +import java.util.Hashtable; + +public class JsonStripJre { + + public static HashSet getValidMethodsFrom(Method[] methods) { + HashSet valid = new HashSet(); + + if (!isValidArray(methods)) { + return valid; + } + + for (Method m : methods) { + String attr = MethodNameParser.methodName2AttrName(m.getName()); + Name annotation = m.getAnnotation(Name.class); + + if (annotation != null) { + attr = annotation.value(); + } + valid.add(attr); + } + return valid; + } + + + + public static Hashtable getJsonBuildersFrom(Method[] methods) { + Hashtable recursiveBuilders = new Hashtable(); + + if (!isValidArray(methods)) { + return recursiveBuilders; + } + + for (Method m : methods) { + if(isRecursiveJsonBuilder(m)) { + String attr = MethodNameParser.methodName2AttrName(m.getName()); + recursiveBuilders.put(attr, m); + } + } + + return recursiveBuilders; + } + + private static boolean isRecursiveJsonBuilder(Method m) { + Class[] classes = m.getParameterTypes(); + return classes.length == 0 && IsProperties.class.isAssignableFrom(m.getReturnType()); + } + + + private static boolean isValidArray(Object[] array) { + return array != null && array.length > 0; + } + +} diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/util/MethodNameParser.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/util/MethodNameParser.java new file mode 100644 index 00000000..99e9ff93 --- /dev/null +++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/util/MethodNameParser.java @@ -0,0 +1,12 @@ +package com.google.gwt.query.vm.util; + +public class MethodNameParser { + + public static String methodName2AttrName(String s) { + return deCapitalize(s.replaceFirst("^[gs]et", "")); + } + + private static String deCapitalize(String s) { + return s != null && s.length() > 0 ? s.substring(0, 1).toLowerCase() + s.substring(1) : s; + } +} diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java index 3d1273c1..5ea76a18 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java @@ -158,12 +158,16 @@ public class DataBindingTestJre extends GWTTestCase { } public interface GUser extends JsonBuilder { + @Name("_id") + String getId(); + int getAge(); String getName(); GAddress address(); } public static final String JSON_USER_EXAMPLE = " { " + + " '_id': 'aaabbbccc', " + " 'email': 'foo@bar.com', " + " 'age': 27, " + " 'name': 'Foo Bar', " @@ -179,6 +183,7 @@ public class DataBindingTestJre extends GWTTestCase { entity.parse(JSON_USER_EXAMPLE, true); assertNotNull(entity.get("email")); + assertEquals("aaabbbccc", entity.getId()); assertEquals(27, entity.getAge()); assertEquals("Foo Bar", entity.getName()); assertNotNull(entity.address()); @@ -192,6 +197,7 @@ public class DataBindingTestJre extends GWTTestCase { entity.parse(JSON_USER_EXAMPLE, true); entity.strip(); + assertEquals("aaabbbccc", entity.getId()); assertNull(entity.get("email")); assertEquals(27, entity.getAge()); assertEquals("Foo Bar", entity.getName()); -- cgit v1.2.3 From 195620f534fa11002f393ced2657fe80c37a9b29 Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Fri, 26 Dec 2014 16:15:44 +0100 Subject: Separating JsonBuilderHanler into a new class --- .../google/gwt/query/vm/JsonBuilderHandler.java | 333 +++++++++++++++++++++ .../com/google/gwt/query/vm/JsonFactoryJre.java | 273 +---------------- .../google/gwt/query/vm/strip/JsonStripJre.java | 61 ---- .../google/gwt/query/vm/util/MethodNameParser.java | 12 - 4 files changed, 334 insertions(+), 345 deletions(-) create mode 100644 gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java delete mode 100644 gwtquery-core/src/main/java/com/google/gwt/query/vm/strip/JsonStripJre.java delete mode 100644 gwtquery-core/src/main/java/com/google/gwt/query/vm/util/MethodNameParser.java (limited to 'gwtquery-core') diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java new file mode 100644 index 00000000..5e7e1e54 --- /dev/null +++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java @@ -0,0 +1,333 @@ +package com.google.gwt.query.vm; + +import com.google.gwt.query.client.Function; +import com.google.gwt.query.client.IsProperties; +import com.google.gwt.query.client.Properties; +import com.google.gwt.query.client.builders.JsonBuilder; +import com.google.gwt.query.client.builders.Name; +import com.google.gwt.query.rebind.JsonBuilderGenerator; +import com.google.gwt.query.vm.JsonFactoryJre.JreJsonFunction; + +import java.lang.reflect.Array; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.List; + +import elemental.json.Json; +import elemental.json.JsonArray; +import elemental.json.JsonBoolean; +import elemental.json.JsonNull; +import elemental.json.JsonNumber; +import elemental.json.JsonObject; +import elemental.json.JsonString; +import elemental.json.JsonValue; + +public class JsonBuilderHandler implements InvocationHandler { + + static JsonFactoryJre jsonFactory = new JsonFactoryJre(); + + private JsonObject jsonObject; + + public JsonBuilderHandler() { + jsonObject = Json.createObject(); + } + + public JsonBuilderHandler(JsonObject j) { + jsonObject = j; + } + + public JsonBuilderHandler(String payload) throws Throwable { + jsonObject = Json.parse(payload); + } + + @SuppressWarnings("unchecked") + private Object jsonArrayToList(JsonArray j, Class ctype, boolean isArray) { + List l = new ArrayList(); + for (int i = 0; j != null && i < j.length(); i++) { + l.add((T) getValue(j, i, null, null, ctype, null)); + } + return l.isEmpty() ? null : isArray ? l.toArray((T[]) Array.newInstance(ctype, l.size())) : l; + } + + private Double toDouble(String attr, JsonArray arr, int idx, JsonObject obj) { + try { + return obj != null ? obj.getNumber(attr) : arr.getNumber(idx); + } catch (Exception e) { + return Double.valueOf(0d); + } + } + + private Object getValue(JsonArray arr, int idx, JsonObject obj, String attr, Class clz, + Method method) { + if (clz.equals(Boolean.class) || clz == Boolean.TYPE) { + try { + return obj != null ? obj.getBoolean(attr) : arr.getBoolean(idx); + } catch (Exception e) { + return Boolean.FALSE; + } + } else if (clz.equals(Date.class)) { + return new Date((long) (obj != null ? obj.getNumber(attr) : arr.getNumber(idx))); + } else if (clz.equals(Byte.class) || clz == Byte.TYPE) { + return toDouble(attr, arr, idx, obj).byteValue(); + } else if (clz.equals(Short.class) || clz == Short.TYPE) { + return toDouble(attr, arr, idx, obj).shortValue(); + } else if (clz.equals(Integer.class) || clz == Integer.TYPE) { + return toDouble(attr, arr, idx, obj).intValue(); + } else if (clz.equals(Double.class) || clz == Double.TYPE) { + return toDouble(attr, arr, idx, obj); + } else if (clz.equals(Float.class) || clz == Float.TYPE) { + return toDouble(attr, arr, idx, obj).floatValue(); + } else if (clz.equals(Long.class) || clz == Long.TYPE) { + return toDouble(attr, arr, idx, obj).longValue(); + } + + Object ret = obj != null ? obj.get(attr) : arr.get(idx); + if (ret instanceof JreJsonFunction || clz.equals(Function.class)) { + return ret != null && ret instanceof JreJsonFunction ? ((JreJsonFunction) ret).getFunction() + : null; + } else if (ret instanceof JsonNull) { + return null; + } else if (ret instanceof JsonString) { + return ((JsonString) ret).asString(); + } else if (ret instanceof JsonBoolean) { + return ((JsonBoolean) ret).asBoolean(); + } else if (ret instanceof JsonNumber) { + return toDouble(attr, arr, idx, obj); + } else if (ret instanceof JsonArray || clz.isArray() || clz.equals(List.class)) { + Class ctype = Object.class; + if (clz.isArray()) { + ctype = clz.getComponentType(); + } else { + Type returnType = method.getGenericReturnType(); + if (returnType instanceof ParameterizedType) { + ctype = (Class) ((ParameterizedType) returnType).getActualTypeArguments()[0]; + } + } + return jsonArrayToList(obj.getArray(attr), ctype, clz.isArray()); + } else if (ret instanceof JsonObject) { + if (clz == Object.class) { + return jsonFactory.createBinder((JsonObject) ret); + } else if (IsProperties.class.isAssignableFrom(clz) && !clz.isAssignableFrom(ret.getClass())) { + return jsonFactory.create(clz, (JsonObject) ret); + } + } + return ret; + } + + private JsonArray listToJsonArray(Object... l) throws Throwable { + JsonArray ret = Json.createArray(); + for (Object o : l) { + setValue(ret, null, null, o); + } + return ret; + } + + private Object setValue(JsonArray jsArr, JsonObject jsObj, String attr, Object val) { + if (val == null) { + return Json.createNull(); + } + + try { + Class valClaz = JsonValue.class; + if (val instanceof Number) { + val = ((Number) val).doubleValue(); + valClaz = Double.TYPE; + } else if (val instanceof Boolean) { + valClaz = Boolean.TYPE; + } else if (val instanceof Date) { + val = ((Date) val).getTime(); + valClaz = Double.TYPE; + } else if (val instanceof String) { + valClaz = String.class; + } else if (val instanceof IsProperties) { + val = ((IsProperties) val).getDataImpl(); + } else if (val.getClass().isArray() || val instanceof List) { + val = + listToJsonArray(val.getClass().isArray() ? (Object[]) val : ((List) val).toArray()); + } else if (val instanceof Function) { + val = new JreJsonFunction((Function) val); + } + + if (jsObj != null) { + Method mth = jsObj.getClass().getMethod("put", String.class, valClaz); + mth.invoke(jsObj, new Object[] {attr, val}); + return jsObj; + } else { + Method mth = jsArr.getClass().getMethod("set", Integer.TYPE, valClaz); + mth.invoke(jsArr, new Object[] {new Integer(jsArr.length()), val}); + return jsArr; + } + } catch (Throwable e) { + e.printStackTrace(); + } + return null; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + String mname = method.getName(); + Class[] classes = method.getParameterTypes(); + int largs = classes.length; + + Name name = method.getAnnotation(Name.class); + String attr = name != null ? name.value() : methodName2AttrName(mname); + + if ("getFieldNames".equals(mname)) { + return jsonObject.keys(); + } else if ("as".equals(mname)) { + @SuppressWarnings("unchecked") + Class clz = (Class) args[0]; + return jsonFactory.create(clz, jsonObject); + } else if ("getJsonName".equals(mname)) { + return JsonBuilderGenerator.classNameToJsonName(getDataBindingClassName(proxy.getClass())); + } else if (mname.matches("getProperties|getDataImpl")) { + return jsonObject; + } else if (largs > 0 && ("parse".equals(mname) || "load".equals(mname))) { + String json = String.valueOf(args[0]); + if (largs > 1 && Boolean.TRUE.equals(args[1])) { + json = Properties.wrapPropertiesString(json); + } + jsonObject = Json.parse(json); + } else if ("strip".equals(mname)) { + stripProxy((JsonBuilder) proxy); + } else if (mname.matches("toString")) { + return jsonObject.toString(); + } else if (mname.matches("toJsonWithName")) { + String jsonName = + JsonBuilderGenerator.classNameToJsonName(getDataBindingClassName(proxy.getClass())); + return "{\"" + jsonName + "\":" + jsonObject.toString() + "}"; + } else if (mname.matches("toJson")) { + return jsonObject.toString(); + } else if ("toQueryString".equals(mname)) { + return param(jsonObject); + } else if (largs == 1 && mname.equals("get")) { + Class ret = method.getReturnType(); + attr = String.valueOf(args[0]); + return getValue(null, 0, jsonObject, attr, ret, method); + } else if (largs == 0 || mname.startsWith("get")) { + Class ret = method.getReturnType(); + return getValue(null, 0, jsonObject, attr, ret, method); + } else if (largs == 2 && mname.equals("set")) { + setValue(null, jsonObject, String.valueOf(args[0]), args[1]); + return proxy; + } else if (largs == 1 || mname.startsWith("set")) { + setValue(null, jsonObject, attr, args[0]); + return proxy; + } + return null; + } + + public String methodName2AttrName(String s) { + return deCapitalize(s.replaceFirst("^[gs]et", "")); + } + + private String deCapitalize(String s) { + return s != null && s.length() > 0 ? s.substring(0, 1).toLowerCase() + s.substring(1) : s; + } + + /** + * @param proxy + */ + private void stripProxy(JsonBuilder proxy) { + Class type = proxy.getClass().getInterfaces()[0]; + + HashSet valid = getValidMethodsFrom(type.getMethods()); + Hashtable recursiveBuilders = getJsonBuildersFrom(type.getMethods()); + + for (String key : jsonObject.keys()) { + String name = methodName2AttrName(key); + if (!valid.contains(name)) { + jsonObject.remove(key); + continue; + } + Method recursiveBuilder = recursiveBuilders.get(name); + if (recursiveBuilder != null) { + callRecursiveStrip(proxy, recursiveBuilder); + } + } + } + + private void callRecursiveStrip(JsonBuilder proxy, Method recursiveBuilder) { + try { + ((IsProperties) invoke(proxy, recursiveBuilder, new Object[] {})).strip(); + } catch (Throwable e) { + e.printStackTrace(); + } + } + + private String getDataBindingClassName(Class type) { + for (Class c : type.getInterfaces()) { + if (c.equals(JsonBuilder.class)) { + return type.getName(); + } else { + return getDataBindingClassName(c); + } + } + return null; + } + + private String param(JsonObject o) { + String ret = ""; + for (String k : o.keys()) { + ret += ret.isEmpty() ? "" : "&"; + JsonValue v = o.get(k); + if (v instanceof JsonArray) { + for (int i = 0, l = ((JsonArray) v).length(); i < l; i++) { + ret += i > 0 ? "&" : ""; + JsonValue e = ((JsonArray) v).get(i); + ret += k + "[]=" + e.toJson(); + } + } else { + if (v != null && !(v instanceof JsonNull)) { + ret += k + "=" + v.toJson(); + } + } + } + return ret; + } + + private HashSet getValidMethodsFrom(Method[] methods) { + HashSet valid = new HashSet(); + + if (methods == null || methods.length == 0) { + return valid; + } + + for (Method m : methods) { + String attr = methodName2AttrName(m.getName()); + Name annotation = m.getAnnotation(Name.class); + + if (annotation != null) { + attr = annotation.value(); + } + valid.add(attr); + } + return valid; + } + + private Hashtable getJsonBuildersFrom(Method[] methods) { + Hashtable recursiveBuilders = new Hashtable(); + + if (methods == null || methods.length == 0) { + return recursiveBuilders; + } + + for (Method m : methods) { + Class[] classes = m.getParameterTypes(); + boolean isRecursiveJsonBuilder = + classes.length == 0 && IsProperties.class.isAssignableFrom(m.getReturnType()); + if (isRecursiveJsonBuilder) { + String attr = methodName2AttrName(m.getName()); + recursiveBuilders.put(attr, m); + } + } + + return recursiveBuilders; + } +} \ No newline at end of file diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java index 799cf256..54e8aab3 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java @@ -2,34 +2,13 @@ package com.google.gwt.query.vm; import com.google.gwt.query.client.Function; import com.google.gwt.query.client.IsProperties; -import com.google.gwt.query.client.Properties; import com.google.gwt.query.client.builders.JsonBuilder; import com.google.gwt.query.client.builders.JsonFactory; -import com.google.gwt.query.client.builders.Name; -import com.google.gwt.query.rebind.JsonBuilderGenerator; -import com.google.gwt.query.vm.strip.JsonStripJre; -import com.google.gwt.query.vm.util.MethodNameParser; -import java.lang.reflect.Array; import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; import java.lang.reflect.Proxy; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.List; -import elemental.json.Json; -import elemental.json.JsonArray; -import elemental.json.JsonBoolean; -import elemental.json.JsonNull; -import elemental.json.JsonNumber; import elemental.json.JsonObject; -import elemental.json.JsonString; -import elemental.json.JsonValue; import elemental.json.impl.JreJsonNull; /** @@ -40,7 +19,7 @@ import elemental.json.impl.JreJsonNull; */ public class JsonFactoryJre implements JsonFactory { - static JsonFactoryJre jsonFactory = new JsonFactoryJre(); + /** * Although functions cannot be serialized to json we use JsonBuilders @@ -62,256 +41,6 @@ public class JsonFactoryJre implements JsonFactory { } } - public static class JsonBuilderHandler implements InvocationHandler { - private JsonObject jsonObject; - - public JsonBuilderHandler() { - jsonObject = Json.createObject(); - } - - public JsonBuilderHandler(JsonObject j) { - jsonObject = j; - } - - public JsonBuilderHandler(String payload) throws Throwable { - jsonObject = Json.parse(payload); - } - - @SuppressWarnings("unchecked") - private Object jsonArrayToList(JsonArray j, Class ctype, boolean isArray) { - List l = new ArrayList(); - for (int i = 0; j != null && i < j.length() ; i++) { - l.add((T)getValue(j, i, null, null, ctype, null)); - } - return l.isEmpty() ? null : isArray ? l.toArray((T[])Array.newInstance(ctype, l.size())) : l; - } - - private Double toDouble(String attr, JsonArray arr, int idx, JsonObject obj) { - try { - return obj != null ? obj.getNumber(attr) : arr.getNumber(idx); - } catch (Exception e) { - return Double.valueOf(0d); - } - } - - private Object getValue(JsonArray arr, int idx, JsonObject obj, String attr, Class clz, Method method) { - if (clz.equals(Boolean.class) || clz == Boolean.TYPE) { - try { - return obj != null ? obj.getBoolean(attr): arr.getBoolean(idx); - } catch (Exception e) { - return Boolean.FALSE; - } - } else if (clz.equals(Date.class)) { - return new Date((long)(obj != null ? obj.getNumber(attr): arr.getNumber(idx))); - } else if (clz.equals(Byte.class) || clz == Byte.TYPE) { - return toDouble(attr, arr, idx, obj).byteValue(); - } else if (clz.equals(Short.class) || clz == Short.TYPE) { - return toDouble(attr, arr, idx, obj).shortValue(); - } else if (clz.equals(Integer.class) || clz == Integer.TYPE) { - return toDouble(attr, arr, idx, obj).intValue(); - } else if (clz.equals(Double.class) || clz == Double.TYPE) { - return toDouble(attr, arr, idx, obj); - } else if (clz.equals(Float.class) || clz == Float.TYPE) { - return toDouble(attr, arr, idx, obj).floatValue(); - } else if (clz.equals(Long.class) || clz == Long.TYPE) { - return toDouble(attr, arr, idx, obj).longValue(); - } - - Object ret = obj != null ? obj.get(attr): arr.get(idx); - if (ret instanceof JreJsonFunction || clz.equals(Function.class)) { - return ret != null && ret instanceof JreJsonFunction ? ((JreJsonFunction)ret).getFunction() : null; - } else if (ret instanceof JsonNull) { - return null; - } else if (ret instanceof JsonString) { - return ((JsonString)ret).asString(); - } else if (ret instanceof JsonBoolean) { - return ((JsonBoolean)ret).asBoolean(); - } else if (ret instanceof JsonNumber) { - return toDouble(attr, arr, idx, obj); - } else if (ret instanceof JsonArray || clz.isArray() || clz.equals(List.class)) { - Class ctype = Object.class; - if (clz.isArray()) { - ctype = clz.getComponentType(); - } else { - Type returnType = method.getGenericReturnType(); - if (returnType instanceof ParameterizedType) { - ctype = (Class)((ParameterizedType) returnType).getActualTypeArguments()[0]; - } - } - return jsonArrayToList(obj.getArray(attr), ctype, clz.isArray()); - } else if (ret instanceof JsonObject) { - if (clz == Object.class) { - return jsonFactory.createBinder((JsonObject)ret); - } else if (IsProperties.class.isAssignableFrom(clz) && !clz.isAssignableFrom(ret.getClass())) { - return jsonFactory.create(clz, (JsonObject)ret); - } - } - return ret; - } - - private JsonArray listToJsonArray(Object...l) throws Throwable { - JsonArray ret = Json.createArray(); - for (Object o: l) { - setValue(ret, null, null, o); - } - return ret; - } - - private Object setValue(JsonArray jsArr, JsonObject jsObj, String attr, Object val) { - if (val == null) { - return Json.createNull(); - } - - try { - Class valClaz = JsonValue.class; - if (val instanceof Number) { - val = ((Number)val).doubleValue(); - valClaz = Double.TYPE; - } else if (val instanceof Boolean) { - valClaz = Boolean.TYPE; - } else if (val instanceof Date) { - val = ((Date)val).getTime(); - valClaz = Double.TYPE; - } else if (val instanceof String) { - valClaz = String.class; - } else if (val instanceof IsProperties) { - val = ((IsProperties)val).getDataImpl(); - } else if (val.getClass().isArray() || val instanceof List) { - val = listToJsonArray(val.getClass().isArray() ? (Object[])val : ((List)val).toArray()); - } else if (val instanceof Function) { - val = new JreJsonFunction((Function)val); - } - - if (jsObj != null) { - Method mth = jsObj.getClass().getMethod("put", String.class, valClaz); - mth.invoke(jsObj, new Object[]{attr, val}); - return jsObj; - } else { - Method mth = jsArr.getClass().getMethod("set", Integer.TYPE, valClaz); - mth.invoke(jsArr, new Object[]{new Integer(jsArr.length()), val}); - return jsArr; - } - } catch (Throwable e) { - e.printStackTrace(); - } - return null; - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - String mname = method.getName(); - Class[] classes = method.getParameterTypes(); - int largs = classes.length; - - Name name = method.getAnnotation(Name.class); - String attr = name != null ? name.value() : MethodNameParser.methodName2AttrName(mname); - - if ("getFieldNames".equals(mname)) { - return jsonObject.keys(); - } else if ("as".equals(mname)) { - @SuppressWarnings("unchecked") - Class clz = (Class)args[0]; - return jsonFactory.create(clz, jsonObject); - } else if ("getJsonName".equals(mname)) { - return JsonBuilderGenerator.classNameToJsonName(getDataBindingClassName(proxy.getClass())); - } else if (mname.matches("getProperties|getDataImpl")) { - return jsonObject; - } else if (largs > 0 && ("parse".equals(mname) || "load".equals(mname))) { - String json = String.valueOf(args[0]); - if (largs > 1 && Boolean.TRUE.equals(args[1])) { - json = Properties.wrapPropertiesString(json); - } - jsonObject = Json.parse(json); - } else if ("strip".equals(mname)) { - stripProxy((JsonBuilder)proxy); - } else if (mname.matches("toString")) { - return jsonObject.toString(); - } else if (mname.matches("toJsonWithName")) { - String jsonName = JsonBuilderGenerator.classNameToJsonName(getDataBindingClassName(proxy.getClass())); - return "{\"" + jsonName + "\":"+ jsonObject.toString() + "}"; - } else if (mname.matches("toJson")) { - return jsonObject.toString() ; - } else if ("toQueryString".equals(mname)) { - return param(jsonObject); - } else if (largs == 1 && mname.equals("get")) { - Class ret = method.getReturnType(); - attr = String.valueOf(args[0]); - return getValue(null, 0, jsonObject, attr, ret, method); - } else if (largs == 0 || mname.startsWith("get")) { - Class ret = method.getReturnType(); - return getValue(null, 0, jsonObject, attr, ret, method); - } else if (largs == 2 && mname.equals("set")) { - setValue(null, jsonObject, String.valueOf(args[0]), args[1]); - return proxy; - } else if (largs == 1 || mname.startsWith("set")) { - setValue(null, jsonObject, attr, args[0]); - return proxy; - } - return null; - } - - /** - * @param proxy - */ - private void stripProxy(JsonBuilder proxy) { - Class type = proxy.getClass().getInterfaces()[0]; - - HashSet valid = JsonStripJre.getValidMethodsFrom(type.getMethods()); - Hashtable recursiveBuilders = JsonStripJre.getJsonBuildersFrom(type.getMethods()); - - for (String key: jsonObject.keys()) { - String name = MethodNameParser.methodName2AttrName(key); - if (!valid.contains(name)) { - jsonObject.remove(key); - continue; - } - Method recursiveBuilder = recursiveBuilders.get(name); - if (recursiveBuilder != null) { - callRecursiveStrip(proxy,recursiveBuilder); - } - } - } - - private void callRecursiveStrip(JsonBuilder proxy, Method recursiveBuilder) { - try { - ((IsProperties)invoke(proxy, recursiveBuilder, new Object[]{})).strip(); - } catch (Throwable e) { - e.printStackTrace(); - } - } - - private String getDataBindingClassName(Class type) { - for (Class c : type.getInterfaces()) { - if (c.equals(JsonBuilder.class)) { - return type.getName(); - } else { - return getDataBindingClassName(c); - } - } - return null; - } - - private String param(JsonObject o) { - String ret = ""; - for (String k : o.keys()) { - ret += ret.isEmpty() ? "" : "&"; - JsonValue v = o.get(k); - if (v instanceof JsonArray) { - for (int i = 0, l = ((JsonArray)v).length(); i < l ; i++) { - ret += i > 0 ? "&" : ""; - JsonValue e = ((JsonArray)v).get(i); - ret += k + "[]=" + e.toJson(); - } - } else { - if (v != null && !(v instanceof JsonNull)) { - ret += k + "=" + v.toJson(); - } - } - } - return ret; - } - } - @SuppressWarnings("unchecked") public T create(Class clz, JsonObject jso) { InvocationHandler handler = new JsonBuilderHandler(jso); diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/strip/JsonStripJre.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/strip/JsonStripJre.java deleted file mode 100644 index 19e961af..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/strip/JsonStripJre.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.google.gwt.query.vm.strip; - -import com.google.gwt.query.client.IsProperties; -import com.google.gwt.query.client.builders.Name; -import com.google.gwt.query.vm.util.MethodNameParser; - -import java.lang.reflect.Method; -import java.util.HashSet; -import java.util.Hashtable; - -public class JsonStripJre { - - public static HashSet getValidMethodsFrom(Method[] methods) { - HashSet valid = new HashSet(); - - if (!isValidArray(methods)) { - return valid; - } - - for (Method m : methods) { - String attr = MethodNameParser.methodName2AttrName(m.getName()); - Name annotation = m.getAnnotation(Name.class); - - if (annotation != null) { - attr = annotation.value(); - } - valid.add(attr); - } - return valid; - } - - - - public static Hashtable getJsonBuildersFrom(Method[] methods) { - Hashtable recursiveBuilders = new Hashtable(); - - if (!isValidArray(methods)) { - return recursiveBuilders; - } - - for (Method m : methods) { - if(isRecursiveJsonBuilder(m)) { - String attr = MethodNameParser.methodName2AttrName(m.getName()); - recursiveBuilders.put(attr, m); - } - } - - return recursiveBuilders; - } - - private static boolean isRecursiveJsonBuilder(Method m) { - Class[] classes = m.getParameterTypes(); - return classes.length == 0 && IsProperties.class.isAssignableFrom(m.getReturnType()); - } - - - private static boolean isValidArray(Object[] array) { - return array != null && array.length > 0; - } - -} diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/util/MethodNameParser.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/util/MethodNameParser.java deleted file mode 100644 index 99e9ff93..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/util/MethodNameParser.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.google.gwt.query.vm.util; - -public class MethodNameParser { - - public static String methodName2AttrName(String s) { - return deCapitalize(s.replaceFirst("^[gs]et", "")); - } - - private static String deCapitalize(String s) { - return s != null && s.length() > 0 ? s.substring(0, 1).toLowerCase() + s.substring(1) : s; - } -} -- cgit v1.2.3 From b571d28f9371a4c95837ddf383699d7211572857 Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Fri, 26 Dec 2014 16:49:26 +0100 Subject: Adding documentation and renaming some vars --- .../com/google/gwt/query/client/IsProperties.java | 2 + .../google/gwt/query/vm/JsonBuilderHandler.java | 45 ++++++++++------------ 2 files changed, 22 insertions(+), 25 deletions(-) (limited to 'gwtquery-core') diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/IsProperties.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/IsProperties.java index 3b88edf5..f630cf21 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/IsProperties.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/IsProperties.java @@ -35,6 +35,8 @@ public interface IsProperties { /** * Removes the extra JSON and leaves only the setters/getters described * in the JsonBuilder interface. + * If the object contains another IsProperties attributes the method strip() + * is called on them. */ T strip(); diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java index 5e7e1e54..8d9b9a4c 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java @@ -231,36 +231,31 @@ public class JsonBuilderHandler implements InvocationHandler { return s != null && s.length() > 0 ? s.substring(0, 1).toLowerCase() + s.substring(1) : s; } - /** - * @param proxy + /* + * This method removes all the json which is not mapped into a + * method inside the JsonBuilder Object. + * Also if the proxy contains another JsonBuilder in their methods + * the method strip() is called. */ - private void stripProxy(JsonBuilder proxy) { + private void stripProxy(JsonBuilder proxy) throws Throwable { Class type = proxy.getClass().getInterfaces()[0]; - HashSet valid = getValidMethodsFrom(type.getMethods()); - Hashtable recursiveBuilders = getJsonBuildersFrom(type.getMethods()); + HashSet validAttrs = getAttributeNames(type.getMethods()); + Hashtable ispropertyGetters = getJsonBuilders(type.getMethods()); for (String key : jsonObject.keys()) { String name = methodName2AttrName(key); - if (!valid.contains(name)) { + if (!validAttrs.contains(name)) { jsonObject.remove(key); continue; } - Method recursiveBuilder = recursiveBuilders.get(name); - if (recursiveBuilder != null) { - callRecursiveStrip(proxy, recursiveBuilder); + Method ispropertyGetter = ispropertyGetters.get(name); + if (ispropertyGetter != null) { + ((IsProperties) invoke(proxy, ispropertyGetter, new Object[] {})).strip(); } } } - private void callRecursiveStrip(JsonBuilder proxy, Method recursiveBuilder) { - try { - ((IsProperties) invoke(proxy, recursiveBuilder, new Object[] {})).strip(); - } catch (Throwable e) { - e.printStackTrace(); - } - } - private String getDataBindingClassName(Class type) { for (Class c : type.getInterfaces()) { if (c.equals(JsonBuilder.class)) { @@ -292,7 +287,7 @@ public class JsonBuilderHandler implements InvocationHandler { return ret; } - private HashSet getValidMethodsFrom(Method[] methods) { + private HashSet getAttributeNames(Method[] methods) { HashSet valid = new HashSet(); if (methods == null || methods.length == 0) { @@ -311,23 +306,23 @@ public class JsonBuilderHandler implements InvocationHandler { return valid; } - private Hashtable getJsonBuildersFrom(Method[] methods) { - Hashtable recursiveBuilders = new Hashtable(); + private Hashtable getJsonBuilders(Method[] methods) { + Hashtable ispropertyGetters = new Hashtable(); if (methods == null || methods.length == 0) { - return recursiveBuilders; + return ispropertyGetters; } for (Method m : methods) { Class[] classes = m.getParameterTypes(); - boolean isRecursiveJsonBuilder = + boolean isJsonBuilder = classes.length == 0 && IsProperties.class.isAssignableFrom(m.getReturnType()); - if (isRecursiveJsonBuilder) { + if (isJsonBuilder) { String attr = methodName2AttrName(m.getName()); - recursiveBuilders.put(attr, m); + ispropertyGetters.put(attr, m); } } - return recursiveBuilders; + return ispropertyGetters; } } \ No newline at end of file -- cgit v1.2.3 From 617443d1157cc3769db6d96bf7149278b51768b4 Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Fri, 26 Dec 2014 18:16:01 +0100 Subject: nodeType property error when using selectors like: $(widget) --- .../src/main/java/com/google/gwt/query/client/js/JsUtils.java | 3 +-- .../java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'gwtquery-core') 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 65f26cee..d1833d66 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 @@ -19,7 +19,6 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsArrayMixed; -import com.google.gwt.core.client.JsArrayString; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Node; @@ -351,7 +350,7 @@ public class JsUtils { * Check is a javascript object can be cast to an Element */ public static native boolean isElement(Object o) /*-{ - return o && o.nodeType && o.nodeName ? true : false; + return !!o && 'nodeType' in o && 'nodeName' in o; }-*/; /** diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java index b509fa00..287e6440 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java @@ -133,5 +133,14 @@ public class GQueryWidgetsTestGwt extends GWTTestCase { b2.click(); assertEquals("red", $(b1).css("color", false)); } + + public void testSelectorWidget() { + final Button b1 = new Button("click-me"); + RootPanel.get().add(b1); + GQuery g = $(b1); + assertEquals("inline-block", $(b1).css("display")); + g.hide(); + assertEquals("none", $(b1).css("display")); + } } -- cgit v1.2.3 From 447ddbc2d7b69a56540d8b1116913d91b04ec431 Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Fri, 26 Dec 2014 18:48:54 +0100 Subject: Using isVisible for widget selector test. Also removingFromParent Button. --- .../java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gwtquery-core') diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java index 287e6440..4d66d771 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java @@ -135,12 +135,13 @@ public class GQueryWidgetsTestGwt extends GWTTestCase { } public void testSelectorWidget() { - final Button b1 = new Button("click-me"); + final Button b1 = new Button("Button click"); RootPanel.get().add(b1); GQuery g = $(b1); - assertEquals("inline-block", $(b1).css("display")); + assertEquals(true, $(b1).isVisible()); g.hide(); - assertEquals("none", $(b1).css("display")); + assertEquals(false, $(b1).isVisible()); + b1.removeFromParent(); } } -- cgit v1.2.3 From 84909924a3af81010bc6c6df933b5c44f125c950 Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Fri, 26 Dec 2014 19:14:36 +0100 Subject: using assertTrue and asserFalse instead of assertEquals(true/false, ...) --- .../test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gwtquery-core') diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java index 4d66d771..66e1aab5 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java @@ -138,9 +138,9 @@ public class GQueryWidgetsTestGwt extends GWTTestCase { final Button b1 = new Button("Button click"); RootPanel.get().add(b1); GQuery g = $(b1); - assertEquals(true, $(b1).isVisible()); + assertTrue($(b1).isVisible()); g.hide(); - assertEquals(false, $(b1).isVisible()); + assertFalse($(b1).isVisible()); b1.removeFromParent(); } -- cgit v1.2.3 From 3ef29d689bd6e4377b258ced12c62928d73e674a Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Fri, 26 Dec 2014 21:32:24 +0100 Subject: Using GQuery var instance instead of evaluating selector multiple times. --- .../test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gwtquery-core') diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java index 66e1aab5..801992f9 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java @@ -138,9 +138,9 @@ public class GQueryWidgetsTestGwt extends GWTTestCase { final Button b1 = new Button("Button click"); RootPanel.get().add(b1); GQuery g = $(b1); - assertTrue($(b1).isVisible()); + assertTrue(g.isVisible()); g.hide(); - assertFalse($(b1).isVisible()); + assertFalse(g.isVisible()); b1.removeFromParent(); } -- cgit v1.2.3 From 0f3702eb8108999d364fc288d02023c1d6ec5b8d Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Thu, 1 Jan 2015 20:02:57 +0100 Subject: Do not format JSNI blocks. Allow methods with dollar --- gwtquery-core/src/main/code-style/gwt-checkstyle.xml | 1 + gwtquery-core/src/main/code-style/gwt-format.xml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'gwtquery-core') diff --git a/gwtquery-core/src/main/code-style/gwt-checkstyle.xml b/gwtquery-core/src/main/code-style/gwt-checkstyle.xml index 23439683..111e29c6 100644 --- a/gwtquery-core/src/main/code-style/gwt-checkstyle.xml +++ b/gwtquery-core/src/main/code-style/gwt-checkstyle.xml @@ -156,6 +156,7 @@ Description: + diff --git a/gwtquery-core/src/main/code-style/gwt-format.xml b/gwtquery-core/src/main/code-style/gwt-format.xml index b13daa74..1873dbdb 100644 --- a/gwtquery-core/src/main/code-style/gwt-format.xml +++ b/gwtquery-core/src/main/code-style/gwt-format.xml @@ -54,8 +54,8 @@ - - + + -- cgit v1.2.3 From 791e62c0ad78c03228882421a239d71b9f073401 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Thu, 1 Jan 2015 20:03:28 +0100 Subject: Organize imports, remove empty lines --- .../main/java/com/google/gwt/query/client/GQ.java | 8 ++--- .../com/google/gwt/query/client/LazyGQuery.java | 41 ++-------------------- .../com/google/gwt/query/client/Predicate.java | 1 - .../java/com/google/gwt/query/client/Promise.java | 1 - .../java/com/google/gwt/query/client/Selector.java | 1 + .../com/google/gwt/query/client/builders/Name.java | 1 + .../gwt/query/client/builders/XmlBuilder.java | 4 +-- .../gwt/query/client/builders/XmlBuilderBase.java | 4 +-- .../client/css/BackgroundAttachmentProperty.java | 1 - .../query/client/css/BackgroundImageProperty.java | 1 - .../gwt/query/client/css/BorderProperty.java | 1 - .../gwt/query/client/css/BorderStyleProperty.java | 1 - .../gwt/query/client/css/BorderWidthProperty.java | 1 - .../java/com/google/gwt/query/client/css/CSS.java | 18 ---------- .../gwt/query/client/css/CaptionSideProperty.java | 1 - .../google/gwt/query/client/css/ClearProperty.java | 1 - .../google/gwt/query/client/css/ClipProperty.java | 1 - .../google/gwt/query/client/css/CssProperty.java | 2 +- .../gwt/query/client/css/DirectionProperty.java | 1 - .../gwt/query/client/css/EdgePositionProperty.java | 1 - .../gwt/query/client/css/EmptyCellsProperty.java | 1 - .../gwt/query/client/css/HeightProperty.java | 1 - .../query/client/css/LetterSpacingProperty.java | 1 - .../gwt/query/client/css/LineHeightProperty.java | 1 - .../client/css/ListStylePositionProperty.java | 1 - .../gwt/query/client/css/ListStyleProperty.java | 1 - .../gwt/query/client/css/MarginProperty.java | 2 -- .../query/client/css/MultipleValueCssSetter.java | 1 - .../gwt/query/client/css/OutlineProperty.java | 1 - .../gwt/query/client/css/PaddingProperty.java | 2 -- .../gwt/query/client/css/PositionProperty.java | 1 - .../gwt/query/client/css/SimpleCssSetter.java | 1 - .../gwt/query/client/css/TextAlignProperty.java | 1 - .../query/client/css/TextDecorationProperty.java | 1 - .../gwt/query/client/css/TextIdentProperty.java | 1 - .../query/client/css/TextTransformProperty.java | 1 - .../gwt/query/client/css/UnicodeBidiProperty.java | 1 - .../com/google/gwt/query/client/css/UriValue.java | 1 - .../query/client/css/VerticalAlignProperty.java | 1 - .../gwt/query/client/css/VisibilityProperty.java | 1 - .../gwt/query/client/css/WhiteSpaceProperty.java | 1 - .../google/gwt/query/client/css/WidthProperty.java | 1 - .../gwt/query/client/css/WordSpacingProperty.java | 1 - .../gwt/query/client/impl/SelectorEngine.java | 7 ++-- .../client/impl/SelectorEngineCssToXPath.java | 4 +-- .../query/client/impl/SelectorEngineNativeIE8.java | 1 - .../query/client/impl/SelectorEngineNativeMin.java | 1 - .../client/impl/SelectorEngineNativeMinIE8.java | 2 -- .../query/client/impl/SelectorEngineSizzle.java | 1 - .../query/client/impl/SelectorEngineSizzleIE.java | 1 - .../google/gwt/query/client/js/JsObjectArray.java | 1 - .../com/google/gwt/query/client/js/JsUtils.java | 1 - .../gwt/query/client/plugins/LazyEffects.java | 11 +----- .../gwt/query/client/plugins/LazyEvents.java | 9 ----- .../gwt/query/client/plugins/LazyWidgets.java | 14 +------- .../gwt/query/client/plugins/MousePlugin.java | 3 -- .../gwt/query/client/plugins/QueuePlugin.java | 6 ++-- .../google/gwt/query/client/plugins/UiPlugin.java | 3 -- .../google/gwt/query/client/plugins/Widgets.java | 6 ++-- .../google/gwt/query/client/plugins/ajax/Ajax.java | 2 +- .../query/client/plugins/ajax/AjaxTransportJs.java | 1 - .../query/client/plugins/deferred/Callbacks.java | 4 +-- .../query/client/plugins/deferred/Deferred.java | 4 ++- .../client/plugins/deferred/PromiseReqBuilder.java | 2 +- .../gwt/query/client/plugins/effects/Fx.java | 2 -- .../plugins/effects/PropertiesAnimation.java | 1 - .../query/client/plugins/effects/Transitions.java | 12 +++---- .../plugins/effects/TransitionsAnimation.java | 1 - .../client/plugins/events/EventsListener.java | 7 ++-- .../gwt/query/client/plugins/events/GqEvent.java | 1 - .../plugins/widgets/ButtonWidgetFactory.java | 2 -- .../plugins/widgets/HtmlPanelWidgetFactory.java | 1 - .../client/plugins/widgets/LabelWidgetFactory.java | 1 - .../client/plugins/widgets/WidgetsHtmlPanel.java | 1 - .../query/client/plugins/widgets/WidgetsUtils.java | 4 +-- .../google/gwt/query/rebind/BrowserGenerator.java | 4 +-- .../gwt/query/rebind/JsniBundleGenerator.java | 20 +++++------ .../gwt/query/rebind/JsonBuilderGenerator.java | 18 +++++----- .../query/rebind/SelectorGeneratorCssToXPath.java | 18 +++++----- .../gwt/query/rebind/XmlBuilderGenerator.java | 4 +-- .../com/google/gwt/query/vm/AjaxTransportJre.java | 16 ++++----- .../java/com/google/gwt/query/vm/ResponseJre.java | 6 ++-- .../requestfactory/shared/gquery/PromiseRF.java | 13 ++++--- 83 files changed, 92 insertions(+), 240 deletions(-) (limited to 'gwtquery-core') diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQ.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQ.java index b3f7d1ab..9db9ea69 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQ.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQ.java @@ -15,11 +15,6 @@ */ package com.google.gwt.query.client; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.apache.http.MethodNotSupportedException; - import com.google.gwt.query.client.builders.JsonBuilder; import com.google.gwt.query.client.builders.JsonFactory; import com.google.gwt.query.client.plugins.ajax.Ajax.AjaxTransport; @@ -27,6 +22,9 @@ import com.google.gwt.query.client.plugins.ajax.AjaxTransportJs; import com.google.gwt.query.vm.AjaxTransportJre; import com.google.gwt.query.vm.JsonFactoryJre; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + /** * A set of useful methods for gQuery which can be run in browser or JVM. */ diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java index 18a25709..8addc6db 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java @@ -12,62 +12,25 @@ * the License. */ package com.google.gwt.query.client; -import static com.google.gwt.query.client.plugins.QueuePlugin.Queue; -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.core.client.JsArray; -import com.google.gwt.core.client.JsArrayMixed; -import com.google.gwt.core.client.JsArrayString; -import com.google.gwt.core.client.ScriptInjector; -import com.google.gwt.dom.client.BodyElement; -import com.google.gwt.dom.client.ButtonElement; -import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.InputElement; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.NodeList; -import com.google.gwt.dom.client.OptionElement; -import com.google.gwt.dom.client.SelectElement; -import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.HasCssName; -import com.google.gwt.dom.client.TextAreaElement; +import com.google.gwt.query.client.GQuery.Offset; import com.google.gwt.query.client.css.CSS; import com.google.gwt.query.client.css.HasCssValue; import com.google.gwt.query.client.css.TakesCssValue; import com.google.gwt.query.client.css.TakesCssValue.CssSetter; -import com.google.gwt.query.client.impl.AttributeImpl; -import com.google.gwt.query.client.impl.DocumentStyleImpl; import com.google.gwt.query.client.impl.SelectorEngine; -import com.google.gwt.query.client.js.JsCache; -import com.google.gwt.query.client.js.JsMap; import com.google.gwt.query.client.js.JsNamedArray; import com.google.gwt.query.client.js.JsNodeArray; -import com.google.gwt.query.client.js.JsObjectArray; -import com.google.gwt.query.client.js.JsUtils; import com.google.gwt.query.client.plugins.Effects; -import com.google.gwt.query.client.plugins.Events; -import com.google.gwt.query.client.plugins.Plugin; -import com.google.gwt.query.client.plugins.Widgets; -import com.google.gwt.query.client.plugins.ajax.Ajax; -import com.google.gwt.query.client.plugins.ajax.Ajax.Settings; -import com.google.gwt.query.client.plugins.deferred.Deferred; import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.Easing; -import com.google.gwt.query.client.plugins.events.EventsListener; -import com.google.gwt.query.client.plugins.widgets.WidgetsUtils; -import com.google.gwt.regexp.shared.RegExp; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.EventListener; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.IsWidget; import com.google.gwt.user.client.ui.Widget; -import java.util.ArrayList; -import java.util.Arrays; + import java.util.List; import java.util.Map; -import com.google.gwt.query.client.GQuery.*; -import com.google.gwt.query.client.LazyBase; public interface LazyGQuery extends LazyBase{ diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Predicate.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Predicate.java index aa17d2b9..796753ce 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Predicate.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Predicate.java @@ -38,5 +38,4 @@ public class Predicate { public boolean f(T e, int index) { return false; } - } 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 2734458e..193ac624 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 @@ -13,7 +13,6 @@ */ package com.google.gwt.query.client; -import com.google.gwt.query.client.Function; /** * Definition of jquery Promise interface used in gquery. diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Selector.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Selector.java index fbdcff73..38f51946 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Selector.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Selector.java @@ -16,6 +16,7 @@ package com.google.gwt.query.client; import static java.lang.annotation.ElementType.METHOD; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/Name.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/Name.java index 0c75590d..64f44c59 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/Name.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/Name.java @@ -16,6 +16,7 @@ package com.google.gwt.query.client.builders; import static java.lang.annotation.ElementType.METHOD; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/XmlBuilder.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/XmlBuilder.java index 930e7ef9..42ee3af3 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/XmlBuilder.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/XmlBuilder.java @@ -15,10 +15,10 @@ */ package com.google.gwt.query.client.builders; -import java.util.Date; - import com.google.gwt.dom.client.Element; +import java.util.Date; + /** * Tagging interface used to generate XmlBuilder classes. */ diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/XmlBuilderBase.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/XmlBuilderBase.java index 82bf32bd..c8a63495 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/XmlBuilderBase.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/XmlBuilderBase.java @@ -17,8 +17,6 @@ package com.google.gwt.query.client.builders; import static com.google.gwt.query.client.GQuery.$; -import java.util.Date; - import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsDate; import com.google.gwt.dom.client.Element; @@ -26,6 +24,8 @@ import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.Properties; import com.google.gwt.query.client.js.JsUtils; +import java.util.Date; + public abstract class XmlBuilderBase> implements XmlBuilder { //TODO empty document diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundAttachmentProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundAttachmentProperty.java index 83e48f3b..6460b350 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundAttachmentProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundAttachmentProperty.java @@ -60,5 +60,4 @@ public class BackgroundAttachmentProperty extends private BackgroundAttachmentProperty() { super(CSS_PROPERTY); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundImageProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundImageProperty.java index 126f1491..b0924e84 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundImageProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundImageProperty.java @@ -29,5 +29,4 @@ public class BackgroundImageProperty extends CssProperty { private BackgroundImageProperty() { super(CSS_PROPERTY); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderProperty.java index 97b79f36..c22973f4 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderProperty.java @@ -71,5 +71,4 @@ public class BorderProperty implements HasCssValue { RGBColor borderColor) { return new MultipleValueCssSetter(getCssName(), borderWidth, borderStyle, borderColor); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderStyleProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderStyleProperty.java index 714da3f8..385880aa 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderStyleProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderStyleProperty.java @@ -106,5 +106,4 @@ public class BorderStyleProperty extends private BorderStyleProperty(String value) { super(value); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderWidthProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderWidthProperty.java index be5b478a..51cb8110 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderWidthProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderWidthProperty.java @@ -46,7 +46,6 @@ public class BorderWidthProperty extends public String getCssName() { return name().toLowerCase(); } - } private static final String BORDER_BOTTOM_WIDTH_PROPERTY = "borderBottomWidth"; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CSS.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CSS.java index 1ecf7ebf..f55e648d 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CSS.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CSS.java @@ -15,37 +15,20 @@ */ package com.google.gwt.query.client.css; -import com.google.gwt.dom.client.Style.Cursor; -import com.google.gwt.dom.client.Style.Display; -import com.google.gwt.dom.client.Style.FontStyle; -import com.google.gwt.dom.client.Style.FontWeight; -import com.google.gwt.dom.client.Style.ListStyleType; -import com.google.gwt.dom.client.Style.Overflow; -import com.google.gwt.dom.client.Style.Position; -import com.google.gwt.dom.client.Style.TextDecoration; import com.google.gwt.dom.client.Style.VerticalAlign; -import com.google.gwt.dom.client.Style.Visibility; import com.google.gwt.query.client.css.BackgroundAttachmentProperty.BackgroundAttachment; import com.google.gwt.query.client.css.BackgroundPositionProperty.BackgroundPosition; import com.google.gwt.query.client.css.BackgroundRepeatProperty.BackgroundRepeat; import com.google.gwt.query.client.css.BorderCollapseProperty.BorderCollapse; import com.google.gwt.query.client.css.BorderSpacingProperty.BorderSpacing; -import com.google.gwt.query.client.css.BorderStyleProperty.BorderStyle; import com.google.gwt.query.client.css.BorderWidthProperty.BorderWidth; import com.google.gwt.query.client.css.CaptionSideProperty.CaptionSide; -import com.google.gwt.query.client.css.ClearProperty.Clear; -import com.google.gwt.query.client.css.ClipProperty.Shape; -import com.google.gwt.query.client.css.DirectionProperty.Direction; import com.google.gwt.query.client.css.EmptyCellsProperty.EmptyCells; -import com.google.gwt.query.client.css.FontSizeProperty.FontSize; import com.google.gwt.query.client.css.FontVariantProperty.FontVariant; import com.google.gwt.query.client.css.ListStylePositionProperty.ListStylePosition; import com.google.gwt.query.client.css.MarginProperty.ShorthandMarginProperty; import com.google.gwt.query.client.css.PaddingProperty.ShorthandPaddingProperty; -import com.google.gwt.query.client.css.TextAlignProperty.TextAlign; -import com.google.gwt.query.client.css.TextTransformProperty.TextTransform; import com.google.gwt.query.client.css.UnicodeBidiProperty.UnicodeBidi; -import com.google.gwt.query.client.css.WhiteSpaceProperty.WhiteSpace; /** * This class lists all CSS properties. @@ -1315,5 +1298,4 @@ public class CSS { ZIndexProperty.init(); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CaptionSideProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CaptionSideProperty.java index a1fdce0a..ecb6cc93 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CaptionSideProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CaptionSideProperty.java @@ -63,5 +63,4 @@ public class CaptionSideProperty extends private CaptionSideProperty() { super(CSS_PROPERTY); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ClearProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ClearProperty.java index 97cfa4f6..a69c3a78 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ClearProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ClearProperty.java @@ -52,7 +52,6 @@ public class ClearProperty extends CssProperty { public String getCssName() { return name().toLowerCase(); } - } private static final String CSS_PROPERTY = "clear"; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ClipProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ClipProperty.java index 83dfb09e..e985ea5c 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ClipProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ClipProperty.java @@ -48,7 +48,6 @@ public class ClipProperty extends CssProperty { public String getCssName() { return value; } - } private static final String CSS_PROPERTY = "clip"; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CssProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CssProperty.java index 59cfc0c3..342c67b6 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CssProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CssProperty.java @@ -20,7 +20,7 @@ import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.HasCssName; /** - * Base class for Css property + * Base class for Css property. * * @param Class of the value associated with the css property */ diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/DirectionProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/DirectionProperty.java index 601ace2a..dd6a5a8f 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/DirectionProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/DirectionProperty.java @@ -46,7 +46,6 @@ public class DirectionProperty extends public String getCssName() { return name().toLowerCase(); } - } private static final String CSS_PROPERTY = "direction"; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/EdgePositionProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/EdgePositionProperty.java index 54b3fda3..c2066bcb 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/EdgePositionProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/EdgePositionProperty.java @@ -30,5 +30,4 @@ public class EdgePositionProperty extends CssProperty { private EdgePositionProperty(String value) { super(value); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/EmptyCellsProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/EmptyCellsProperty.java index e31746a7..55c8926f 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/EmptyCellsProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/EmptyCellsProperty.java @@ -55,5 +55,4 @@ public class EmptyCellsProperty extends private EmptyCellsProperty() { super(CSS_PROPERTY); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/HeightProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/HeightProperty.java index 5ffcced5..3aa8e163 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/HeightProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/HeightProperty.java @@ -34,5 +34,4 @@ public class HeightProperty extends CssProperty { private HeightProperty(String cssName) { super(cssName); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/LetterSpacingProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/LetterSpacingProperty.java index a5e7286b..adf0a09c 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/LetterSpacingProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/LetterSpacingProperty.java @@ -30,5 +30,4 @@ public class LetterSpacingProperty extends CssProperty { private LetterSpacingProperty() { super(CSS_PROPERTY); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/LineHeightProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/LineHeightProperty.java index 112a1373..70b35cc6 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/LineHeightProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/LineHeightProperty.java @@ -57,5 +57,4 @@ public class LineHeightProperty extends CssProperty implements public CssSetter with(Double value) { return new SimpleCssSetter(CSS_PROPERTY, value != null ? "" + value : null); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ListStylePositionProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ListStylePositionProperty.java index 0fcb4c2e..cbac528e 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ListStylePositionProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ListStylePositionProperty.java @@ -45,7 +45,6 @@ public class ListStylePositionProperty extends public String getCssName() { return name().toLowerCase(); } - } private static final String CSS_PROPERTY = "listStylePosition"; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ListStyleProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ListStyleProperty.java index 5eed56a8..4410ff75 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ListStyleProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ListStyleProperty.java @@ -52,5 +52,4 @@ public class ListStyleProperty implements HasCssValue { return new MultipleValueCssSetter(CSS_PROPERTY, listStyleType, listStylePosition, listStyleImage); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/MarginProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/MarginProperty.java index 00a5b16e..a6cf8e41 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/MarginProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/MarginProperty.java @@ -70,7 +70,6 @@ public class MarginProperty extends CssProperty { margin3, margin4); } - } private static String MARGIN_BOTTOM_PROPERTY = "marginBottom"; @@ -90,5 +89,4 @@ public class MarginProperty extends CssProperty { private MarginProperty(String cssName) { super(cssName); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/MultipleValueCssSetter.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/MultipleValueCssSetter.java index a7dd7765..50305d01 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/MultipleValueCssSetter.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/MultipleValueCssSetter.java @@ -36,5 +36,4 @@ public class MultipleValueCssSetter extends SimpleCssSetter { private static String notNull(HasCssName value) { return value != null ? value.getCssName() + " " : ""; } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/OutlineProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/OutlineProperty.java index a723349a..848750fc 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/OutlineProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/OutlineProperty.java @@ -59,5 +59,4 @@ public class OutlineProperty implements Length outlineWidth) { return new MultipleValueCssSetter(CSS_PROPERTY, outlineColor, outlineStyle, outlineWidth); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/PaddingProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/PaddingProperty.java index 47474848..8dbca5d3 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/PaddingProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/PaddingProperty.java @@ -72,7 +72,6 @@ public class PaddingProperty extends CssProperty { padding3, padding4); } - } private static String PADDING_BOTTOM_PROPERTY = "paddingBottom"; @@ -92,5 +91,4 @@ public class PaddingProperty extends CssProperty { private PaddingProperty(String cssName) { super(cssName); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/PositionProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/PositionProperty.java index c89697c3..e01fc35b 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/PositionProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/PositionProperty.java @@ -32,5 +32,4 @@ public class PositionProperty extends CssProperty { private PositionProperty() { super(CSS_PROPERTY); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/SimpleCssSetter.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/SimpleCssSetter.java index 03297f7c..468a1edf 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/SimpleCssSetter.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/SimpleCssSetter.java @@ -43,5 +43,4 @@ public class SimpleCssSetter implements CssSetter { e.getStyle().setProperty(property, value != null ? value : ""); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextAlignProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextAlignProperty.java index bd245ae9..64101e8f 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextAlignProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextAlignProperty.java @@ -66,5 +66,4 @@ public class TextAlignProperty extends private TextAlignProperty() { super(CSS_PROPERTY); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextDecorationProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextDecorationProperty.java index e89a9ec8..c6b37f60 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextDecorationProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextDecorationProperty.java @@ -41,5 +41,4 @@ public class TextDecorationProperty extends CssProperty { private TextDecorationProperty() { super(CSS_PROPERTY); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextIdentProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextIdentProperty.java index b7c1deb7..958932af 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextIdentProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextIdentProperty.java @@ -33,5 +33,4 @@ public class TextIdentProperty extends CssProperty { private TextIdentProperty() { super(CSS_PROPERTY); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextTransformProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextTransformProperty.java index 5d80ca34..c54f9266 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextTransformProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextTransformProperty.java @@ -55,5 +55,4 @@ public class TextTransformProperty extends private TextTransformProperty() { super(CSS_PROPERTY); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/UnicodeBidiProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/UnicodeBidiProperty.java index 9d017cc8..df0a3d9f 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/UnicodeBidiProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/UnicodeBidiProperty.java @@ -63,7 +63,6 @@ public class UnicodeBidiProperty extends public String getCssName() { return name().toLowerCase().replace('_', '-'); } - } private static final String CSS_PROPERTY = "unicodeBidi"; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/UriValue.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/UriValue.java index b5ae719e..fb03f115 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/UriValue.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/UriValue.java @@ -38,5 +38,4 @@ public class UriValue implements HasCssName { public String getCssName() { return value; } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/VerticalAlignProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/VerticalAlignProperty.java index 85a60f19..f7aac5d4 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/VerticalAlignProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/VerticalAlignProperty.java @@ -37,5 +37,4 @@ public class VerticalAlignProperty extends CssProperty public CssSetter with(Length value) { return new SimpleCssSetter(this, value); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/VisibilityProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/VisibilityProperty.java index 8cb4c59e..c54e1c76 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/VisibilityProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/VisibilityProperty.java @@ -33,5 +33,4 @@ public class VisibilityProperty extends CssProperty { private VisibilityProperty() { super(CSS_PROPERTY); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/WhiteSpaceProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/WhiteSpaceProperty.java index d944f0b9..6821b085 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/WhiteSpaceProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/WhiteSpaceProperty.java @@ -73,5 +73,4 @@ public class WhiteSpaceProperty extends private WhiteSpaceProperty() { super(CSS_PROPERTY); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/WidthProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/WidthProperty.java index 865eae3c..2cfff008 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/WidthProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/WidthProperty.java @@ -33,5 +33,4 @@ public class WidthProperty extends CssProperty { private WidthProperty(String cssName) { super(cssName); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/WordSpacingProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/WordSpacingProperty.java index c5552cd3..e62a6aad 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/WordSpacingProperty.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/WordSpacingProperty.java @@ -29,5 +29,4 @@ public class WordSpacingProperty extends CssProperty { private WordSpacingProperty() { super(CSS_PROPERTY); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java index 967961e8..858ee141 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java @@ -15,9 +15,8 @@ */ package com.google.gwt.query.client.impl; -import static com.google.gwt.query.client.GQuery.*; - -import java.util.HashSet; +import static com.google.gwt.query.client.GQuery.document; +import static com.google.gwt.query.client.GQuery.window; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Document; @@ -32,6 +31,8 @@ import com.google.gwt.query.client.js.JsUtils; import com.google.gwt.regexp.shared.MatchResult; import com.google.gwt.regexp.shared.RegExp; +import java.util.HashSet; + /** * Core Selector engine functions, and native JS utility functions. */ diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java index e5fa3fa4..2492214d 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java @@ -17,8 +17,6 @@ package com.google.gwt.query.client.impl; import static com.google.gwt.query.client.GQuery.console; -import java.util.ArrayList; - import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.dom.client.Element; @@ -30,6 +28,8 @@ import com.google.gwt.query.client.js.JsUtils; import com.google.gwt.regexp.shared.MatchResult; import com.google.gwt.regexp.shared.RegExp; +import java.util.ArrayList; + /** * Runtime selector engine implementation which translates selectors to XPath * and delegates to document.evaluate(). diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeIE8.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeIE8.java index 42c8dcfe..5d16d57c 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeIE8.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeIE8.java @@ -42,5 +42,4 @@ public class SelectorEngineNativeIE8 extends SelectorEngineSizzleIE { } } } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMin.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMin.java index efc930eb..100d9e85 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMin.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMin.java @@ -40,5 +40,4 @@ public class SelectorEngineNativeMin extends SelectorEngineImpl { return null; } } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMinIE8.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMinIE8.java index 604ce517..c0bfbdad 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMinIE8.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMinIE8.java @@ -17,7 +17,6 @@ package com.google.gwt.query.client.impl; import static com.google.gwt.query.client.GQuery.console; -import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.NodeList; @@ -41,5 +40,4 @@ public class SelectorEngineNativeMinIE8 extends SelectorEngineImpl { return null; } } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineSizzle.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineSizzle.java index 9a1591a9..718883bc 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineSizzle.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineSizzle.java @@ -1037,7 +1037,6 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { match = true; break; } - } else if ( GQS.filter( cur, [elem] ).length > 0 ) { match = elem; break; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineSizzleIE.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineSizzleIE.java index 741c785a..b4130f97 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineSizzleIE.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineSizzleIE.java @@ -879,7 +879,6 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { match = true; break; } - } else if ( IES.filter( cur, [elem] ).length > 0 ) { match = elem; break; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsObjectArray.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsObjectArray.java index c5a6062c..022d42a1 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsObjectArray.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsObjectArray.java @@ -85,5 +85,4 @@ public final class JsObjectArray extends JavaScriptObject { public Object[] elements() { return c().elements(); } - } 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 82e2ae79..f59a2b75 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 @@ -19,7 +19,6 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsArrayMixed; -import com.google.gwt.core.client.JsArrayString; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Node; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEffects.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEffects.java index 1b7d90bf..5178862d 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEffects.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEffects.java @@ -14,19 +14,10 @@ * the License. */ package com.google.gwt.query.client.plugins; -import com.google.gwt.animation.client.Animation; -import com.google.gwt.dom.client.Element; import com.google.gwt.query.client.Function; -import com.google.gwt.query.client.GQuery; +import com.google.gwt.query.client.LazyBase; import com.google.gwt.query.client.Properties; -import com.google.gwt.query.client.plugins.effects.ClipAnimation; -import com.google.gwt.query.client.plugins.effects.ClipAnimation.Direction; -import com.google.gwt.query.client.plugins.effects.Fx; import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.Easing; -import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.EasingCurve; -import com.google.gwt.query.client.plugins.effects.TransitionsAnimation.TransitionsClipAnimation; -import com.google.gwt.query.client.GQuery.*; -import com.google.gwt.query.client.LazyBase; public interface LazyEffects extends LazyBase{ diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java index 081e1702..7ba49eed 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java @@ -12,18 +12,9 @@ * the License. */ package com.google.gwt.query.client.plugins; -import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.FormElement; import com.google.gwt.dom.client.NativeEvent; -import com.google.gwt.dom.client.Node; import com.google.gwt.query.client.Function; import com.google.gwt.query.client.GQuery; -import com.google.gwt.query.client.js.JsUtils; -import com.google.gwt.query.client.plugins.events.EventsListener; -import com.google.gwt.query.client.plugins.events.EventsListener.SpecialEvent; -import com.google.gwt.query.client.plugins.events.GqEvent; -import com.google.gwt.user.client.Event; -import com.google.gwt.query.client.GQuery.*; import com.google.gwt.query.client.LazyBase; public interface LazyEvents extends LazyBase{ diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyWidgets.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyWidgets.java index 8c40c293..fac96f09 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyWidgets.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyWidgets.java @@ -14,27 +14,15 @@ * the License. */ package com.google.gwt.query.client.plugins; -import java.util.ArrayList; -import java.util.List; -import com.google.gwt.dom.client.Element; -import com.google.gwt.query.client.GQuery; -import com.google.gwt.query.client.plugins.widgets.ButtonWidgetFactory; -import com.google.gwt.query.client.plugins.widgets.HtmlPanelWidgetFactory; -import com.google.gwt.query.client.plugins.widgets.LabelWidgetFactory; -import com.google.gwt.query.client.plugins.widgets.PasswordTextBoxWidgetFactory; -import com.google.gwt.query.client.plugins.widgets.TextAreaWidgetFactory; -import com.google.gwt.query.client.plugins.widgets.TextBoxWidgetFactory; +import com.google.gwt.query.client.LazyBase; import com.google.gwt.query.client.plugins.widgets.WidgetFactory; import com.google.gwt.query.client.plugins.widgets.WidgetInitializer; -import com.google.gwt.query.client.plugins.widgets.WidgetsUtils; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.PasswordTextBox; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.Widget; -import com.google.gwt.query.client.GQuery.*; -import com.google.gwt.query.client.LazyBase; public interface LazyWidgets extends LazyBase{ diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/MousePlugin.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/MousePlugin.java index 9dbbc671..c7b8f67d 100755 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/MousePlugin.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/MousePlugin.java @@ -96,7 +96,6 @@ public abstract class MousePlugin extends UiPlugin { } }); } - } /** @@ -255,7 +254,6 @@ public abstract class MousePlugin extends UiPlugin { }); } - } private boolean delayConditionMet() { @@ -333,5 +331,4 @@ public abstract class MousePlugin extends UiPlugin { return e.getClientY(); } } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java index 89822ef0..fe384dd3 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java @@ -15,9 +15,6 @@ */ package com.google.gwt.query.client.plugins; -import java.util.LinkedList; -import java.util.Queue; - import com.google.gwt.dom.client.Element; import com.google.gwt.query.client.Function; import com.google.gwt.query.client.GQuery; @@ -25,6 +22,9 @@ import com.google.gwt.query.client.Promise; import com.google.gwt.query.client.plugins.deferred.Callbacks; import com.google.gwt.user.client.Timer; +import java.util.LinkedList; +import java.util.Queue; + /** * Class used in plugins which need a queue system. */ diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/UiPlugin.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/UiPlugin.java index eb589bbd..d2f01187 100755 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/UiPlugin.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/UiPlugin.java @@ -111,7 +111,6 @@ public class UiPlugin extends GQuery { + e.css("overflow-y", true); return overflow.contains("auto") || overflow.contains("scroll"); } - } @SuppressWarnings("unused") @@ -123,7 +122,6 @@ public class UiPlugin extends GQuery { return ("absolute".equals(position) || "relative".equals(position) || "static" .equals(position)); } - } public static Class GQueryUi = UiPlugin.class; @@ -176,5 +174,4 @@ public class UiPlugin extends GQuery { protected void trigger(GwtEvent e, Function callback, Element element) { trigger(e, callback, element, eventBus); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java index 2eaf38c2..352e0e04 100755 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java @@ -15,9 +15,6 @@ */ package com.google.gwt.query.client.plugins; -import java.util.ArrayList; -import java.util.List; - import com.google.gwt.dom.client.Element; import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.plugins.widgets.ButtonWidgetFactory; @@ -36,6 +33,9 @@ import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.Widget; +import java.util.ArrayList; +import java.util.List; + /** * Widgets plugin for Gwt Query. Be careful, this plugin is still experimental. * The api can change in next releases. diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java index 4fc1cba7..394ec58f 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java @@ -21,10 +21,10 @@ import com.google.gwt.core.client.ScriptInjector; import com.google.gwt.dom.client.Element; import com.google.gwt.http.client.Request; import com.google.gwt.http.client.Response; -import com.google.gwt.query.client.IsProperties; import com.google.gwt.query.client.Function; import com.google.gwt.query.client.GQ; import com.google.gwt.query.client.GQuery; +import com.google.gwt.query.client.IsProperties; import com.google.gwt.query.client.Promise; import com.google.gwt.query.client.builders.JsonBuilder; import com.google.gwt.query.client.js.JsUtils; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/AjaxTransportJs.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/AjaxTransportJs.java index 8ab32ac6..07c204ea 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/AjaxTransportJs.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/AjaxTransportJs.java @@ -62,5 +62,4 @@ public class AjaxTransportJs implements AjaxTransport { public Promise getXhr(Settings settings) { return new PromiseReqBuilder(settings); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Callbacks.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Callbacks.java index 24654b53..ce0112e1 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Callbacks.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Callbacks.java @@ -13,12 +13,12 @@ */ package com.google.gwt.query.client.plugins.deferred; +import com.google.gwt.query.client.Function; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import com.google.gwt.query.client.Function; - /** * Implementation of jQuery.Callbacks for gwtquery. */ diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Deferred.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Deferred.java index 91c899a5..5cc99f03 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Deferred.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Deferred.java @@ -15,7 +15,9 @@ */ package com.google.gwt.query.client.plugins.deferred; -import static com.google.gwt.query.client.Promise.*; +import static com.google.gwt.query.client.Promise.PENDING; +import static com.google.gwt.query.client.Promise.REJECTED; +import static com.google.gwt.query.client.Promise.RESOLVED; import com.google.gwt.query.client.Function; import com.google.gwt.query.client.GQuery; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseReqBuilder.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseReqBuilder.java index 9f72b1b5..14ff309b 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseReqBuilder.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseReqBuilder.java @@ -36,8 +36,8 @@ import com.google.gwt.http.client.RequestCallback; import com.google.gwt.http.client.RequestException; import com.google.gwt.http.client.RequestPermissionException; import com.google.gwt.http.client.Response; -import com.google.gwt.query.client.IsProperties; import com.google.gwt.query.client.Function; +import com.google.gwt.query.client.IsProperties; import com.google.gwt.query.client.js.JsCache; import com.google.gwt.query.client.js.JsUtils; import com.google.gwt.query.client.plugins.ajax.Ajax.Settings; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Fx.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Fx.java index ddb865ab..3ece61d6 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Fx.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Fx.java @@ -246,7 +246,6 @@ public class Fx { } return result; } - } public String cssprop; @@ -288,5 +287,4 @@ public class Fx { + " value=" + value + " start=" + start + " end=" + end + " unit=" + unit).replaceAll("\\.0([^\\d])", "$1"); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java index 0c9d109c..2c4c6f76 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java @@ -365,5 +365,4 @@ public class PropertiesAnimation extends GQAnimation { protected double interpolate(double progress) { return easing.interpolate(progress); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transitions.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transitions.java index 693990d5..d5f15bbe 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transitions.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transitions.java @@ -28,12 +28,6 @@ */ package com.google.gwt.query.client.plugins.effects; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map.Entry; - import com.google.gwt.core.client.Duration; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Style; @@ -49,6 +43,12 @@ import com.google.gwt.regexp.shared.RegExp; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Timer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map.Entry; + /** * Transitions and transformation plugin for gQuery. * diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/TransitionsAnimation.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/TransitionsAnimation.java index a671d92e..9cc24342 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/TransitionsAnimation.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/TransitionsAnimation.java @@ -183,7 +183,6 @@ public class TransitionsAnimation extends PropertiesAnimation { trsStart = "" + start; g.css(key, start + unit); } - } else { trsStart = ""; trsEnd = val; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java index fbc25013..0b6478a5 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java @@ -13,6 +13,8 @@ */ package com.google.gwt.query.client.plugins.events; +import static com.google.gwt.query.client.GQuery.$; + import com.google.gwt.core.client.Duration; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.EventTarget; @@ -31,8 +33,6 @@ import com.google.gwt.user.client.EventListener; import java.util.ArrayList; import java.util.List; -import static com.google.gwt.query.client.GQuery.$; - /** * This class implements an event queue instance for one Element. The queue instance is configured * as the default event listener in GWT. @@ -324,7 +324,6 @@ public class EventsListener implements EventListener { if (newFunctions.length() > 0) { bindFunctionBySelector.put(cssSelector, newFunctions); } - } } @@ -370,7 +369,6 @@ public class EventsListener implements EventListener { return Element.as(eventTarget); } - } public static final String EVENT_DATA = "___event_datas"; @@ -553,7 +551,6 @@ public class EventsListener implements EventListener { die(b, nameSpace, eventName, originalEventName, cssSelector); } - } public void die(int eventbits, String nameSpace, String eventName, String originalEventName, diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/GqEvent.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/GqEvent.java index 5c8f071a..ed4da4db 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/GqEvent.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/GqEvent.java @@ -115,5 +115,4 @@ public class GqEvent extends Event { return getClientY() + GQuery.document.getScrollTop(); } } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ButtonWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ButtonWidgetFactory.java index c1d5c32c..9abb5a96 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ButtonWidgetFactory.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ButtonWidgetFactory.java @@ -17,8 +17,6 @@ package com.google.gwt.query.client.plugins.widgets; import com.google.gwt.dom.client.ButtonElement; import com.google.gwt.dom.client.Element; -import com.google.gwt.query.client.plugins.widgets.WidgetFactory; -import com.google.gwt.query.client.plugins.widgets.WidgetsUtils; import com.google.gwt.user.client.ui.Button; /** diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/HtmlPanelWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/HtmlPanelWidgetFactory.java index 4e3ad447..527b2de3 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/HtmlPanelWidgetFactory.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/HtmlPanelWidgetFactory.java @@ -23,5 +23,4 @@ public class HtmlPanelWidgetFactory implements WidgetFactory { public HTMLPanel create(Element e) { return new WidgetsHtmlPanel(e); } - } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/LabelWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/LabelWidgetFactory.java index 51a05174..b7c4bad9 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/LabelWidgetFactory.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/LabelWidgetFactory.java @@ -26,5 +26,4 @@ public class LabelWidgetFactory implements WidgetFactory