aboutsummaryrefslogtreecommitdiffstats
path: root/gwtquery-core/src/main/java
diff options
context:
space:
mode:
authorManolo Carrasco <manolo@apache.org>2015-01-02 14:26:04 +0100
committerManolo Carrasco <manolo@apache.org>2015-01-02 14:47:02 +0100
commit083aeae611e94e9121e715b2d5e4d2584abe4f6a (patch)
treec976806b0caa936d501429ad78ef18e0efa9766e /gwtquery-core/src/main/java
parent37879db51962706258f8955ce4d70a5be7f5fa1b (diff)
parentbbb781795cb27391483139dda2166717b751b778 (diff)
downloadgwtquery-083aeae611e94e9121e715b2d5e4d2584abe4f6a.tar.gz
gwtquery-083aeae611e94e9121e715b2d5e4d2584abe4f6a.zip
Merge branch 'mcm_styling' into mcm_special_events
Conflicts: gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/GqEvent.java
Diffstat (limited to 'gwtquery-core/src/main/java')
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/Browser.java12
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java116
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/GQ.java14
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java209
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/IsProperties.java12
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/Lazy.java3
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/LazyBase.java3
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java112
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/Predicate.java5
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/Promise.java8
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java39
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/Selector.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/Selectors.java6
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilder.java5
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java44
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonFactory.java5
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/builders/Name.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/builders/XmlBuilder.java16
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/builders/XmlBuilderBase.java36
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundAttachmentProperty.java5
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundImageProperty.java3
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundPositionProperty.java16
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundRepeatProperty.java2
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderCollapseProperty.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderSpacingProperty.java3
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderStyleProperty.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderWidthProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/CSS.java33
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/CaptionSideProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/ClearProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/ClipProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/CssProperty.java5
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/CursorProperty.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/DirectionProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/EdgePositionProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/EmptyCellsProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/HasCssValue.java2
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/HeightProperty.java3
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/LetterSpacingProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/LineHeightProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/ListStylePositionProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/ListStyleProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/MarginProperty.java15
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/MultipleValueCssSetter.java8
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/OutlineProperty.java3
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/PaddingProperty.java15
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/PositionProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/SimpleCssSetter.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesCssValue.java10
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesInteger.java2
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesNumber.java2
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextAlignProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextDecorationProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextIdentProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/TextTransformProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/UnicodeBidiProperty.java5
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/UriValue.java5
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/VerticalAlignProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/VisibilityProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/WhiteSpaceProperty.java6
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/WidthProperty.java3
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/WordSpacingProperty.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/css/ZIndexProperty.java7
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java22
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeTridentImpl.java16
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/ConsoleBrowser.java74
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java26
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java6
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/HasSelector.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java64
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java170
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineImpl.java1
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNative.java9
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeIE8.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMin.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeMinIE8.java5
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineSizzle.java7
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineSizzleIE.java3
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineJS.java86
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineSizzleGwt.java2
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineXPath.java18
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java51
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsMap.java13
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsNamedArray.java18
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsNodeArray.java10
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsObjectArray.java13
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsRegexp.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java95
-rwxr-xr-xgwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java31
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java18
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEffects.java41
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java15
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyWidgets.java24
-rwxr-xr-xgwtquery-core/src/main/java/com/google/gwt/query/client/plugins/MouseOptions.java6
-rwxr-xr-xgwtquery-core/src/main/java/com/google/gwt/query/client/plugins/MousePlugin.java32
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java34
-rwxr-xr-xgwtquery-core/src/main/java/com/google/gwt/query/client/plugins/UiPlugin.java21
-rwxr-xr-xgwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java10
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java159
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/AjaxTransportJs.java25
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Callbacks.java45
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Deferred.java53
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/FunctionDeferred.java15
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseRPC.java2
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseReqBuilder.java18
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseReqBuilderJSONP.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Bezier.java20
-rwxr-xr-xgwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/ClipAnimation.java6
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Fx.java115
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java181
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transitions.java22
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/TransitionsAnimation.java22
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java24
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/GqEvent.java20
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ButtonWidgetFactory.java8
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/HtmlPanelWidgetFactory.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/LabelWidgetFactory.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextAreaWidgetFactory.java2
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextBoxBaseWidgetFactory.java7
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetFactory.java15
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetInitializer.java19
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsHtmlPanel.java6
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java366
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/linker/IFrameWithDocTypeLinker.java14
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/rebind/BrowserGenerator.java9
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsniBundleGenerator.java85
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsonBuilderGenerator.java62
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/rebind/LazyGenerator.java9
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorBase.java6
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorCssToXPath.java23
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorJSOptimal.java214
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorNative.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorXPath.java24
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/rebind/XmlBuilderGenerator.java19
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/vm/AjaxTransportJre.java43
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/vm/CookieManager.java25
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java346
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java254
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/vm/ResponseJre.java19
-rw-r--r--gwtquery-core/src/main/java/com/google/web/bindery/requestfactory/shared/gquery/PromiseRF.java17
141 files changed, 2204 insertions, 1924 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Browser.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Browser.java
index dfe06f22..e8136e14 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Browser.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Browser.java
@@ -15,8 +15,6 @@
*/
package com.google.gwt.query.client;
-import com.google.gwt.query.rebind.BrowserGenerator;
-
/**
* This class is the equivalent to the jQuery.browser object in gQuery.
*
@@ -65,7 +63,7 @@ public abstract class Browser {
*/
public final boolean opera = isOpera();
/**
- * Maintained for jQuery compatibility
+ * Maintained for jQuery compatibility.
* @return true if webkit
* @deprecated use webkit() instead
*/
@@ -77,12 +75,20 @@ public abstract class Browser {
public final boolean webkit = isWebkit();
protected abstract boolean isIe6();
+
protected abstract boolean isIe8();
+
protected abstract boolean isIe9();
+
protected abstract boolean isIe10();
+
protected abstract boolean isIe11();
+
protected abstract boolean isMozilla();
+
protected abstract boolean isMsie();
+
protected abstract boolean isOpera();
+
protected abstract boolean isWebkit();
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java
index 7416870d..063aaf38 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java
@@ -54,30 +54,31 @@ public abstract class Function {
private String dumpArguments(Object[] arguments, String sep) {
StringBuilder b = new StringBuilder();
- for (int i = 0, l = arguments.length; i < l; i++ ) {
+ for (int i = 0, l = arguments.length; i < l; i++) {
b.append("[").append(i).append("]");
Object o = arguments[i];
if (o == null) {
b.append(" null");
} else if (o.getClass().isArray()) {
- b.append(dumpArguments((Object[])o, sep + " "));
+ b.append(dumpArguments((Object[]) o, sep + " "));
} else if (o instanceof JavaScriptObject) {
- JavaScriptObject jso = (JavaScriptObject)o;
+ JavaScriptObject jso = (JavaScriptObject) o;
if (JsUtils.isElement(jso)) {
b.append("(Element) ").append(jso.toString());
} else {
- b.append("(JSO) ").append(jso.<Properties>cast().toJsonString());
+ b.append("(JSO) ").append(jso.<Properties> cast().toJsonString());
}
} else {
b.append("(").append(o.getClass().getName()).append(") ").append(o);
}
- if (i < l-1) b.append(sep);
+ if (i < l - 1)
+ b.append(sep);
}
return b.toString();
}
public <T extends com.google.gwt.dom.client.Element> T getElement() {
- return element.<T>cast();
+ return element.<T> cast();
}
public <T extends com.google.gwt.dom.client.Element> Function setElement(T e) {
@@ -87,7 +88,8 @@ public abstract class Function {
public Function setEvent(Event e) {
event = e;
- element = e != null ? e.getCurrentEventTarget().<com.google.gwt.dom.client.Element>cast() : null;
+ element =
+ e != null ? e.getCurrentEventTarget().<com.google.gwt.dom.client.Element> cast() : null;
return this;
}
@@ -113,15 +115,16 @@ public abstract class Function {
}
/**
- * Set the list of arguments to be passed to the function
+ * Set the list of arguments to be passed to the function.
*/
- public Function setArguments(Object...arguments) {
+ public Function setArguments(Object... arguments) {
this.arguments = arguments;
return this;
}
/**
- * Return the first element of the arguments list
+ * Return the first element of the arguments list.
+ *
* @deprecated use getArgument(idx) instead.
*/
@Deprecated
@@ -130,7 +133,7 @@ public abstract class Function {
}
/**
- * @deprecated use getArgument instead
+ * @deprecated use getArgument instead.
*/
@Deprecated
public Object getDataObject(int idx) {
@@ -144,7 +147,7 @@ public abstract class Function {
*/
@SuppressWarnings("unchecked")
public <T extends JavaScriptObject> T getArgumentJSO(int argIdx, int pos) {
- return (T)getArgument(argIdx, pos, JavaScriptObject.class);
+ return (T) getArgument(argIdx, pos, JavaScriptObject.class);
}
/**
@@ -165,9 +168,9 @@ public abstract class Function {
* Always returns an array.
*/
public Object[] getArgumentArray(int idx) {
- Object o = idx < 0 ? arguments: getArgument(idx);
+ Object o = idx < 0 ? arguments : getArgument(idx);
if (o != null) {
- return o.getClass().isArray() ? (Object[])o : new Object[]{o};
+ return o.getClass().isArray() ? (Object[]) o : new Object[] {o};
} else if (idx == 0) {
return arguments;
}
@@ -193,7 +196,7 @@ public abstract class Function {
}
/**
- * Convenience alias for the getArguments(argIdx, pos) method;
+ * Convenience alias for the getArguments(argIdx, pos) method.
*/
public <T> T arguments(int argIdx, int pos) {
return getArgument(argIdx, pos);
@@ -237,20 +240,20 @@ public abstract class Function {
Object[] objs = getArgumentArray(argIdx);
Object o = objs.length > pos ? objs[pos] : null;
if (o != null && (
- // When type is null we don't safety check
- type == null ||
- // The object is an instance of the type requested
- o.getClass() == type ||
- // Overlay types
- type == JavaScriptObject.class && o instanceof JavaScriptObject
- )) {
- return (T)o;
+ // When type is null we don't safety check
+ type == null ||
+ // The object is an instance of the type requested
+ o.getClass() == type ||
+ // Overlay types
+ type == JavaScriptObject.class && o instanceof JavaScriptObject
+ )) {
+ return (T) o;
}
return null;
}
/**
- * @deprecated use: getArgument()
+ * @deprecated use: getArgument() instead.
*/
@Deprecated
public Properties getDataProperties() {
@@ -258,7 +261,7 @@ public abstract class Function {
}
/**
- * @deprecated use: getArgument(idx)
+ * @deprecated use: getArgument(idx) instead.
*/
@Deprecated
public Properties getDataProperties(int idx) {
@@ -266,7 +269,7 @@ public abstract class Function {
}
/**
- * @deprecated use: setArguments()
+ * @deprecated use: setArguments() instead.
*/
@Deprecated
public void setData(boolean b) {
@@ -274,7 +277,7 @@ public abstract class Function {
}
/**
- * @deprecated use: setArguments()
+ * @deprecated use: setArguments() instead.
*/
@Deprecated
public void setData(double b) {
@@ -282,10 +285,10 @@ public abstract class Function {
}
/**
- * @deprecated use use setArguments instead
+ * @deprecated use use setArguments instead.
*/
@Deprecated
- public void setData(Object...arguments) {
+ public void setData(Object... arguments) {
setArguments(arguments);
}
@@ -298,7 +301,9 @@ public abstract class Function {
}
/**
- * Return the index in a loop execution. Used in GQuery.each()
+ * Return the index in a loop execution.
+ *
+ * Used in GQuery.each()
*/
public int getIndex() {
return index;
@@ -312,8 +317,8 @@ public abstract class Function {
*/
public void cancel(com.google.gwt.dom.client.Element e) {
setElement(e);
- // This has to be the order of calls
- cancel(e.<com.google.gwt.user.client.Element>cast());
+ // This has to be the order of calls
+ cancel(e.<com.google.gwt.user.client.Element> cast());
}
/**
@@ -346,7 +351,7 @@ public abstract class Function {
setElement(e);
setIndex(i);
// This has to be the order of calls
- return f(e.<com.google.gwt.user.client.Element>cast(), i);
+ return f(e.<com.google.gwt.user.client.Element> cast(), i);
}
/**
@@ -361,10 +366,10 @@ public abstract class Function {
setElement(e);
setIndex(i);
Widget w = GQuery.getAssociatedWidget(e);
- if (w != null){
+ if (w != null) {
f(w, i);
} else {
- f(e.<com.google.gwt.dom.client.Element>cast());
+ f(e.<com.google.gwt.dom.client.Element> cast());
}
return null;
}
@@ -385,7 +390,7 @@ public abstract class Function {
}
/**
- * Override this method for bound callbacks
+ * Override this method for bound callbacks.
*/
public Object f(Object... args) {
setArguments(args);
@@ -394,24 +399,24 @@ public abstract class Function {
}
/**
- * Override this method for bound callbacks
+ * Override this method for bound callbacks.
*/
public void f(int i, Object arg) {
- f(i, new Object[]{arg});
+ f(i, new Object[] {arg});
}
/**
- * Override this method for bound callbacks
+ * Override this method for bound callbacks.
*/
public void f(int i, Object... args) {
setIndex(i);
setArguments(args);
if (args.length == 1 && args[0] instanceof JavaScriptObject) {
- if (JsUtils.isElement((JavaScriptObject)args[0])) {
- setElement((com.google.gwt.dom.client.Element)args[0]);
+ if (JsUtils.isElement((JavaScriptObject) args[0])) {
+ setElement((com.google.gwt.dom.client.Element) args[0]);
f(getElement(), i);
- } else if (JsUtils.isEvent((JavaScriptObject)args[0])) {
- setEvent((Event)args[0]);
+ } else if (JsUtils.isEvent((JavaScriptObject) args[0])) {
+ setEvent((Event) args[0]);
f(getEvent());
} else {
f();
@@ -448,8 +453,8 @@ public abstract class Function {
*/
public void f(com.google.gwt.dom.client.Element e) {
setElement(e);
- // This has to be the order of calls
- f(e.<com.google.gwt.user.client.Element>cast());
+ // This has to be the order of calls
+ f(e.<com.google.gwt.user.client.Element> cast());
}
/**
@@ -459,11 +464,12 @@ public abstract class Function {
* @param elem takes a com.google.gwt.user.client.Element
*/
private boolean loop = false;
+
@Deprecated
public void f(com.google.gwt.user.client.Element e) {
setElement(e);
Widget w = e != null ? GQuery.getAssociatedWidget(e) : null;
- if (w != null){
+ if (w != null) {
loop = true;
f(w);
} else {
@@ -479,13 +485,13 @@ public abstract class Function {
* 'public void f()' or 'public void f(Element e)' to handle these elements and
* avoid a runtime exception.
*/
- public void f(Widget w){
+ public void f(Widget w) {
setElement(w.getElement());
if (loop) {
loop = false;
f();
} else {
- f(w.getElement().<com.google.gwt.dom.client.Element>cast());
+ f(w.getElement().<com.google.gwt.dom.client.Element> cast());
}
}
@@ -501,16 +507,16 @@ public abstract class Function {
/**
* Methods fe(...) should be used from asynchronous contexts so as we can
* catch the exception and send it to the GWT UncaughtExceptionHandler
- * They are intentionally final to avoid override them
+ * They are intentionally final to avoid override them.
*/
public final void fe(Object arg) {
- fe(new Object[]{arg});
+ fe(new Object[] {arg});
}
/**
* Methods fe(...) should be used from asynchronous contexts so as we can
* catch the exception and send it to the GWT UncaughtExceptionHandler
- * They are intentionally final to avoid override them
+ * They are intentionally final to avoid override them.
*/
public final Object fe(Object... args) {
if (GWT.getUncaughtExceptionHandler() != null) {
@@ -527,7 +533,7 @@ public abstract class Function {
/**
* Methods fe(...) should be used from asynchronous contexts so as we can
* catch the exception and send it to the GWT UncaughtExceptionHandler
- * They are intentionally final to avoid override them
+ * They are intentionally final to avoid override them.
*/
public final boolean fe(Event ev, Object... args) {
if (GWT.getUncaughtExceptionHandler() != null) {
@@ -544,17 +550,17 @@ public abstract class Function {
/**
* Methods fe(...) should be used from asynchronous contexts so as we can
* catch the exception and send it to the GWT UncaughtExceptionHandler
- * They are intentionally final to avoid override them
+ * They are intentionally final to avoid override them.
*/
public final void fe(com.google.gwt.dom.client.Element elem) {
if (GWT.getUncaughtExceptionHandler() != null) {
try {
- f(elem.<com.google.gwt.dom.client.Element>cast());
+ f(elem.<com.google.gwt.dom.client.Element> cast());
} catch (Exception e) {
GWT.getUncaughtExceptionHandler().onUncaughtException(e);
}
return;
}
- f(elem.<com.google.gwt.dom.client.Element>cast());
+ f(elem.<com.google.gwt.dom.client.Element> cast());
}
}
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..b32fbeb2 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.
*/
@@ -43,7 +41,7 @@ public abstract class GQ {
}
/**
- * Create an instance of a JsonBuilder object whose type is <T>
+ * Create an instance of a JsonBuilder object whose type is <T>.
*/
public static <T extends JsonBuilder> T create(Class<T> clz) {
return getFactory().create(clz);
@@ -91,7 +89,7 @@ public abstract class GQ {
/**
* Return the appropriate transport implementation depending on the runtime
- * environment: browser or JVM
+ * environment: browser or JVM.
*/
public static AjaxTransport getAjaxTransport() {
initFactory();
@@ -131,7 +129,7 @@ public abstract class GQ {
// We are running DevMode, so create Js versions of the factories
method = gwt.getMethod("create", Class.class);
ret = method.invoke(null,
- new Object[] {JsonFactory.class});
+ new Object[] {JsonFactory.class});
jsonFactory = (JsonFactory) ret;
ajaxTransport = new AjaxTransportJs();
return;
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 00cb1bd4..72beed5b 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;
@@ -32,9 +34,7 @@ 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.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;
@@ -54,6 +54,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;
@@ -69,7 +70,6 @@ import com.google.gwt.user.client.ui.Widget;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
/**
* GwtQuery is a GWT clone of the popular jQuery library.
@@ -102,7 +102,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
}
/**
- * Class used internally to create DOM element from html snippet
+ * Class used internally to create DOM element from html snippet.
*/
private static class TagWrapper {
public static final TagWrapper DEFAULT = new TagWrapper(0, "", "");
@@ -130,12 +130,12 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
/**
* A Browser object with a set of browser-specific flags.
*/
- public static final Browser browser = GWT.isClient() ? GWT.<Browser>create(Browser.class) : null;
+ public static final Browser browser = GWT.isClient() ? GWT.<Browser> create(Browser.class) : null;
/**
* An object with the same methods than window.console.
*/
- public static final Console console = GWT.isClient() ? GWT.<Console>create(Console.class) : null;
+ public static final Console console = GWT.isClient() ? GWT.<Console> create(Console.class) : null;
/**
* Object to store element data (public so as we can access to it from tests).
@@ -148,7 +148,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
public static final Document document = GWT.isClient() ? Document.get() : null;
/**
- * Static reference Effects plugin
+ * Static reference Effects plugin.
*/
public static Class<Effects> Effects = com.google.gwt.query.client.plugins.Effects.Effects;
@@ -158,7 +158,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
protected static SelectorEngine engine;
/**
- * Static reference Events plugin
+ * Static reference Events plugin.
*/
public static Class<Events> Events = com.google.gwt.query.client.plugins.Events.Events;
@@ -175,7 +175,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
// Sizzle POS regex : usefull in some methods
// TODO: Share this static with SelectorEngineSizzle
- private static RegExp posRegex = RegExp.compile("^:(nth|eq|gt|lt|first|last|even|odd)(?:\\((\\d*)\\))?(?=[^\\-]|$)$");
+ private static RegExp posRegex = RegExp
+ .compile("^:(nth|eq|gt|lt|first|last|even|odd)(?:\\((\\d*)\\))?(?=[^\\-]|$)$");
/**
* Implementation class used for style manipulations.
@@ -185,14 +186,15 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
private static RegExp tagNameRegex = RegExp.compile("<([\\w:-]+)");
/**
- * Static reference to the Widgets plugin
+ * Static reference to the Widgets plugin.
*/
public static Class<Widgets> Widgets = com.google.gwt.query.client.plugins.Widgets.Widgets;
/**
* The window object.
*/
- public static final Element window = GWT.isClient() ? ScriptInjector.TOP_WINDOW.<Element>cast() : null;
+ public static final Element window = GWT.isClient() ? ScriptInjector.TOP_WINDOW.<Element> cast()
+ : null;
private static Element windowData = null;
@@ -252,15 +254,15 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
}
return JsUtils.isWindow(jso) ? $(jso.<Element> cast()) :
- JsUtils.isElement(jso) ? $(jso.<Element> cast()) :
- JsUtils.isEvent(jso) ? $(jso.<Event> cast()) :
- JsUtils.isNodeList(jso) ? $(jso.<NodeList<Element>> cast()) :
- $(jso.<Element> cast());
+ JsUtils.isElement(jso) ? $(jso.<Element> cast()) :
+ JsUtils.isEvent(jso) ? $(jso.<Event> cast()) :
+ JsUtils.isNodeList(jso) ? $(jso.<NodeList<Element>> cast()) :
+ $(jso.<Element> cast());
}
/**
* Wrap a GQuery around any object, supported objects are:
- * String, GQuery, Function, Widget, JavaScriptObject
+ * String, GQuery, Function, Widget, JavaScriptObject.
*
* In the case of string, we accept a CSS selector which is then used to match a set of
* elements, or a raw HTML to create a GQuery element containing those elements. Xpath
@@ -274,31 +276,32 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
public static GQuery $(Object o) {
if (o != null) {
if (o instanceof String) {
- return $((String)o);
+ return $((String) o);
}
if (o instanceof GQuery) {
- return (GQuery)o;
+ return (GQuery) o;
}
if (o instanceof Function) {
- return $((Function)o);
+ return $((Function) o);
}
if (JsUtils.isElement(o)) {
- return $(JsUtils.<Element>cast(o));
+ return $(JsUtils.<Element> cast(o));
}
if (o instanceof JavaScriptObject) {
- return $((JavaScriptObject)o);
+ return $((JavaScriptObject) o);
}
if (o instanceof IsWidget) {
return $(Arrays.asList(o));
}
- console.log("Error: GQuery.$(Object o) could not wrap the type : ", o.getClass().getName(), o);
+ console
+ .log("Error: GQuery.$(Object o) could not wrap the type : ", o.getClass().getName(), o);
}
return $();
}
/**
* Create a new GQuery given a list of {@link com.google.gwt.dom.client.Node} or
- * {@link com.google.gwt.user.client.ui.IsWidget}
+ * {@link com.google.gwt.user.client.ui.IsWidget}.
*/
public static GQuery $(List<?> nodesOrWidgets) {
JsNodeArray elms = JsNodeArray.create();
@@ -307,7 +310,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
if (o instanceof Node) {
elms.addNode((Node) o);
} else if (o instanceof IsWidget) {
- elms.addNode(((IsWidget)o).asWidget().getElement());
+ elms.addNode(((IsWidget) o).asWidget().getElement());
}
}
}
@@ -494,8 +497,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
return
// return all nodes added to the wrapper
$(n.getChildNodes())
- // detach nodes from their temporary parent
- .remove(null, false);
+ // detach nodes from their temporary parent
+ .remove(null, false);
}
/**
@@ -546,7 +549,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
}
/**
- * Execute a function around each object
+ * Execute a function around each object.
*/
public static void each(JsArrayMixed objects, Function f) {
for (int i = 0, l = objects.length(); i < l; i++) {
@@ -555,7 +558,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
}
/**
- * Execute a function around each object
+ * Execute a function around each object.
*/
public static <T> void each(List<T> objects, Function f) {
for (int i = 0, l = objects.size(); i < l; i++) {
@@ -564,7 +567,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
}
/**
- * Execute a function around each object
+ * Execute a function around each object.
*/
public static <T> void each(T[] objects, Function f) {
for (int i = 0, l = objects.length; i < l; i++) {
@@ -693,9 +696,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
wrapperMap.put("td", trWrapper);
wrapperMap.put("th", trWrapper);
wrapperMap.put("col", new TagWrapper(2, "<table><tbody></tbody><colgroup>",
- "</colgroup></table>"));
+ "</colgroup></table>"));
wrapperMap.put("area", new TagWrapper(1, "<map>", "</map>"));
-
}
private static GQuery innerHtml(String html, Document doc) {
@@ -765,7 +767,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
/**
* A constructor function that returns a chainable utility object with methods to register
* multiple callbacks into callback queues, invoke callback queues, and relay the success
- * or failure state of any synchronous or asynchronous function
+ * or failure state of any synchronous or asynchronous function.
*/
public static Promise.Deferred Deferred() {
return new Deferred();
@@ -791,12 +793,12 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
protected String currentSelector;
/**
- * Immutable array of matched elements, modify this using setArray
+ * Immutable array of matched elements, modify this using setArray.
*/
private Element[] elements = new Element[0];
/**
- * The nodeList of matched elements, modify this using setArray
+ * The nodeList of matched elements, modify this using setArray.
*/
// TODO: remove this and use elements, change return type of get()
private NodeList<Element> nodeList = JavaScriptObject.createArray().cast();
@@ -951,7 +953,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px
+ * // move the element from its original position to left:500px
* $("#foo").animate("left:'500'");
*
* // Change the width html attribute of a table, note the symbol '$' to
@@ -968,7 +970,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 500ms and
+ * // move the element from its original position to 500px to the left for 500ms and
* // change the background color of the element at the end of the animation
*
* $("#foo").animate("left:'+=500'", new Function(){
@@ -1011,7 +1013,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms using a swing easing
+ * // move the element from its original position to left:500px for 500ms using a swing easing
* $("#foo").animate("left:'500'", 500, Easing.SWING);
*
* // Change the width html attribute of a table, note the symbol '$' to
@@ -1029,8 +1031,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left and 5OOpx down for 400ms.
- * //use a swing easing function for the transition
+ * // move the element from its original position to 500px to the left and 5OOpx down for 400ms.
+ * // use a swing easing function for the transition
* $("#foo").animate(Properties.create("{top:'+=500px',left:'+=500px'}"), 400, Easing.SWING);
* </pre>
*
@@ -1067,7 +1069,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms
+ * // move the element from its original position to left:500px for 500ms
* $("#foo").animate("left:'500'", 500);
*
* // Change the width html attribute of a table, note the symbol '$' to
@@ -1085,7 +1087,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 1000ms and
+ * // move the element from its original position to 500px to the left for 1000ms and
* // change the background color of the element at the end of the animation
* $("#foo").animate("left:'+=500'", 1000, new Function(){
* public void f(Element e){
@@ -1102,9 +1104,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)', 1000");
* </pre>
*
- * @param prop the property to animate : "cssName:'value'"
- * @param funcs an array of {@link Function} called once the animation is complete
- * @param duration the duration in milliseconds of the animation
+ * @param stringOrProperties the set of properties to animate : "cssName:'value'"
+ * @param funcs an array of {@link Function} called once the animation is complete.
*/
public GQuery animate(Object stringOrProperties, int duration, Function... funcs) {
return as(Effects).animate(stringOrProperties, duration, funcs);
@@ -1179,11 +1180,11 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
public <T extends GQuery> T as(Class<T> plugin) {
// GQuery is not a plugin for itself
if (plugin == GQUERY) {
- return (T)this;
+ return (T) this;
} else if (plugins != null) {
Plugin<?> p = plugins.get(plugin);
if (p != null) {
- return (T)p.init(this);
+ return (T) p.init(this);
}
}
throw new RuntimeException("No plugin registered for class " + plugin.getName());
@@ -1465,7 +1466,6 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
}
return $(unique(result));
-
}
/**
@@ -1708,7 +1708,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
*/
@SuppressWarnings("unchecked")
public <T> T data(String name) {
- return isEmpty() ? null : (T)data(get(0), name, null);
+ return isEmpty() ? null : (T) data(get(0), name, null);
}
/**
@@ -2016,7 +2016,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
/**
* Remove all event handlers previously attached using {@link #live(String, Function)}. In order
* for this method to function correctly, the selector used with it must match exactly the
- * selector initially used with {@link #live(String, Function)}
+ * selector initially used with {@link #live(String, Function)}.
+ *
* @deprecated use {@link #off(String, String)} instead
*/
public GQuery die() {
@@ -2026,7 +2027,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
/**
* Remove an event handlers previously attached using {@link #live(int, Function)} In order for
* this method to function correctly, the selector used with it must match exactly the selector
- * initially used with {@link #live(int, Function)}
+ * initially used with {@link #live(int, Function)}.
* @deprecated use {@link #off(String)}
*/
public GQuery die(int eventbits) {
@@ -2036,7 +2037,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
/**
* Remove an event handlers previously attached using {@link #live(String, Function)} In order for
* this method to function correctly, the selector used with it must match exactly the selector
- * initially used with {@link #live(String, Function)}
+ * initially used with {@link #live(String, Function)}.
*/
public GQuery die(String eventName) {
return as(Events).die(eventName);
@@ -2642,7 +2643,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
}
/**
- * Return true if the first element is visible.isVisible
+ * Return true if the first element is visible.isVisible.
*/
public boolean isVisible() {
return isEmpty() ? false : getStyleImpl().isVisible(get(0));
@@ -3074,7 +3075,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
/**
* Get all following siblings of each element up to but not including the element matched by the
- * GQuery object, filtered by a selector
+ * GQuery object, filtered by a selector.
*
* @return
*/
@@ -3144,23 +3145,23 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* Set the current coordinates of every element in the set of matched elements, relative to the document.
*/
public GQuery offset(int top, int left) {
- for (Element element : elements()){
- GQuery $element = $(element);
+ for (Element element : elements()) {
+ GQuery g = $(element);
- String position = $element.css("position", true);
+ String position = g.css("position", true);
if ("static".equals(position)) {
css("position", "relative");
}
- Offset curOffset = $element.offset();
- String curCSSTop = $element.css("top", true);
- String curCSSLeft = $element.css("left", true);
+ Offset curOffset = g.offset();
+ String curCSSTop = g.css("top", true);
+ String curCSSLeft = g.css("left", true);
long curTop = 0;
long curLeft = 0;
- if (("absolute".equals(position) || "fixed".equals(position)) && ("auto".equals(curCSSTop) || "auto".equals
- (curCSSLeft))) {
- Offset curPosition = $element.position();
+ if (("absolute".equals(position) || "fixed".equals(position))
+ && ("auto".equals(curCSSTop) || "auto".equals(curCSSLeft))) {
+ Offset curPosition = g.position();
curTop = curPosition.top;
curLeft = curPosition.left;
} else {
@@ -3180,7 +3181,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
long newTop = top - curOffset.top + curTop;
long newLeft = left - curOffset.left + curLeft;
- $element.css("top", "" + newTop).css("left", "" + newLeft);
+ g.css("top", "" + newTop).css("left", "" + newLeft);
}
return this;
@@ -3248,21 +3249,21 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
}
/**
- * Remove an event handler
+ * Remove an event handler.
*/
public GQuery off(String eventName) {
return unbind(eventName, null);
}
/**
- * Remove an event handler
+ * Remove an event handler.
*/
public GQuery off(String eventName, Function f) {
return unbind(eventName, f);
}
/**
- * Remove an event handler
+ * Remove an event handler.
*/
public GQuery off(String eventName, String selector) {
if (selector == null || selector.isEmpty()) {
@@ -3301,7 +3302,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
return 0;
}
// height including padding and border
- int outerHeight = (int)cur("offsetHeight", true);
+ int outerHeight = (int) cur("offsetHeight", true);
if (includeMargin) {
outerHeight += cur("marginTop", true) + cur("marginBottom", true);
}
@@ -3325,7 +3326,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
return 0;
}
// width including padding and border
- int outerWidth = (int)cur("offsetWidth", true);
+ int outerWidth = (int) cur("offsetWidth", true);
if (includeMargin) {
outerWidth += cur("marginRight", true) + cur("marginLeft", true);
}
@@ -3376,7 +3377,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* including the element matched by the selector.
*/
public GQuery parentsUntil(final String selector) {
- return parentsUntil(new Predicate(){
+ return parentsUntil(new Predicate() {
@Override
public <T> boolean f(T e, int index) {
return selector != null && $(e).is(selector);
@@ -3656,7 +3657,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
*/
public <T> T prop(String key) {
assert key != null : "Key is null";
- return isEmpty() ? null : JsUtils.<T>prop(get(0), key);
+ return isEmpty() ? null : JsUtils.<T> prop(get(0), key);
}
/**
@@ -3671,7 +3672,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
*/
public <T> T prop(String key, Class<? extends T> clz) {
assert key != null : "Key is null";
- return isEmpty() ? null : JsUtils.<T>prop(get(0), key, clz);
+ return isEmpty() ? null : JsUtils.<T> prop(get(0), key, clz);
}
/**
@@ -3802,6 +3803,30 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
}
/**
+ * 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.
*/
public GQuery remove() {
@@ -3905,7 +3930,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
*/
public GQuery removeProp(String name) {
for (Element e : elements) {
- e.<JsCache>cast().delete(name);
+ e.<JsCache> cast().delete(name);
}
return this;
}
@@ -3935,9 +3960,9 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
List<Element> newElements = new ArrayList<Element>();
for (int i = 0, l = target.size(); i < l; i++) {
- GQuery _this = (i > 0 && mustBeCloned) ? this.clone() : this;
- $(target.get(i)).replaceWith(_this);
- newElements.addAll(Arrays.asList(_this.elements));
+ GQuery that = (i > 0 && mustBeCloned) ? this.clone() : this;
+ $(target.get(i)).replaceWith(that);
+ newElements.addAll(Arrays.asList(that.elements));
}
return $(newElements);
}
@@ -3982,7 +4007,6 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
$(el).remove();
}
return this;
-
}
/**
@@ -4062,8 +4086,9 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* Scrolls the first matched element into view.
*/
public GQuery scrollIntoView() {
- if (!isEmpty())
+ if (!isEmpty()) {
scrollIntoViewImpl(get(0));
+ }
return this;
}
@@ -4203,7 +4228,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
}
/**
- * Make all matched elements visible
+ * Make all matched elements visible.
*/
public GQuery show() {
for (Element e : elements) {
@@ -4491,9 +4516,9 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
elStr = JsUtils.isXML(e) ? JsUtils.XML2String(e) : e.getString();
} catch (Exception e2) {
elStr =
- "< " + (e == null ? "null" : e.getNodeName())
- + "(gquery, error getting the element string representation: " + e2.getMessage()
- + ")/>";
+ "< " + (e == null ? "null" : e.getNodeName())
+ + "(gquery, error getting the element string representation: " + e2.getMessage()
+ + ")/>";
}
r += (pretty && r.length() > 0 ? "\n " : "") + elStr;
}
@@ -4559,7 +4584,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
/**
* Remove all event delegation that have been bound using
- * {@link #delegate(String, int, Function...)} {@link #live(int, Function...)} methods
+ * {@link #delegate(String, int, Function...)} {@link #live(int, Function...)} methods.
+ *
* @deprecated use {@link #off()}
*/
public GQuery undelegate() {
@@ -4568,7 +4594,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
/**
* Undelegate is a way of removing event handlers that have been bound using
- * {@link #delegate(String, int, Function...)} method
+ * {@link #delegate(String, int, Function...)} method.
+ *
* @deprecated use {@link #off(String)}
*/
public GQuery undelegate(String selector) {
@@ -4581,7 +4608,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
/**
* Undelegate is a way of removing event handlers that have been bound using
- * {@link #delegate(String, int, Function...)} method
+ * {@link #delegate(String, int, Function...)} method.
+ *
* @deprecated use {@link #off(String)}
*/
public GQuery undelegate(String selector, int eventBit) {
@@ -4594,7 +4622,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
/**
* Undelegate is a way of removing event handlers that have been bound using
- * {@link #delegate(String, int, Function...)} method
+ * {@link #delegate(String, int, Function...)} method.
+ *
* @deprecated use {@link #off(String, String)}
*/
public GQuery undelegate(String selector, String eventName) {
@@ -4615,7 +4644,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
/**
* This method removes the element's parent. The matched elements replaces their parents within
- * the DOM structure. It is the inverse of {@link GQuery#wrap(GQuery)} method
+ * the DOM structure. It is the inverse of {@link GQuery#wrap(GQuery)} method.
*
* @return
*/
@@ -4623,8 +4652,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
for (Element parent : parent().elements) {
if (!"body".equalsIgnoreCase(parent.getTagName())) {
- GQuery $parent = $(parent);
- $parent.replaceWith($parent.children());
+ GQuery g = $(parent);
+ g.replaceWith(g.children());
}
}
return this;
@@ -4633,7 +4662,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
/**
* Gets the content of the value attribute of the first matched element, returns only the first
* value even if it is a multivalued element. To get an array of all values in multivalues
- * elements use vals()
+ * elements use vals().
*
* When the first element is a radio-button and is not checked, then it looks for the first
* checked radio-button that has the same name in the list of matched elements.
@@ -4804,7 +4833,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
}
/**
- * return the list of attached widgets matching the query
+ * return the list of attached widgets matching the query.
*/
public List<Widget> widgets() {
List<Widget> widgets = new ArrayList<Widget>();
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 ac11b119..9a61efe0 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
@@ -30,6 +30,14 @@ public interface IsProperties {
* parses a json string and loads the resulting properties object.
*/
<T extends IsProperties> T parse(String json);
+
+ /**
+ * 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 extends IsProperties> T strip();
/**
* Returns the underlying object, normally a Properties jso in client
@@ -72,7 +80,7 @@ public interface IsProperties {
String toQueryString();
/**
- * return the name for this type
+ * return the name for this type.
*/
String getJsonName();
@@ -80,5 +88,5 @@ public interface IsProperties {
* converts a JsonBuilder instance into another JsonBuilder type but
* preserving the underlying data object.
*/
- <T extends JsonBuilder> T as (Class<T> clz);
+ <T extends JsonBuilder> T as(Class<T> clz);
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Lazy.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Lazy.java
index 452688b1..e5395bf4 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Lazy.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Lazy.java
@@ -21,6 +21,9 @@ package com.google.gwt.query.client;
* method calls to the class which implements the Lazy interface. Methods in the
* generated class do not execute but instead queue up a deferred execution of
* the method.
+ *
+ * @param <S>
+ * @param <T>
*/
public interface Lazy<S, T extends LazyBase> {
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyBase.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyBase.java
index c5294aaa..b3dfb55f 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyBase.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyBase.java
@@ -18,8 +18,9 @@ package com.google.gwt.query.client;
/**
* All lazy interfaces must extend this baseclass. This ensures the done()
* method exists and returns an executable function.
+ *
+ * @param <S>
*/
public interface LazyBase<S> {
-
Function done();
}
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..df766f9a 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,64 +12,28 @@
* 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.css.CSS;
+import com.google.gwt.query.client.GQuery.Offset;
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<T> extends LazyBase<T>{
+/**
+ * LazyGQuery.
+ * @param <T>
+ */
+public interface LazyGQuery<T> extends LazyBase<T> {
/**
* Add elements to the set of matched elements if they are not included yet.
@@ -130,7 +94,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px
+ * // move the element from its original position to left:500px
* $("#foo").animate("left:'500'");
*
* // Change the width html attribute of a table, note the symbol '$' to
@@ -147,7 +111,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 500ms and
+ * // move the element from its original position to 500px to the left for 500ms and
* // change the background color of the element at the end of the animation
*
* $("#foo").animate("left:'+=500'", new Function(){
@@ -188,7 +152,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms using a swing easing
+ * // move the element from its original position to left:500px for 500ms using a swing easing
* $("#foo").animate("left:'500'", 500, Easing.SWING);
*
* // Change the width html attribute of a table, note the symbol '$' to
@@ -206,8 +170,8 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left and 5OOpx down for 400ms.
- * //use a swing easing function for the transition
+ * // move the element from its original position to 500px to the left and 5OOpx down for 400ms.
+ * // use a swing easing function for the transition
* $("#foo").animate(Properties.create("{top:'+=500px',left:'+=500px'}"), 400, Easing.SWING);
* </pre>
*
@@ -242,7 +206,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms
+ * // move the element from its original position to left:500px for 500ms
* $("#foo").animate("left:'500'", 500);
*
* // Change the width html attribute of a table, note the symbol '$' to
@@ -260,7 +224,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 1000ms and
+ * // move the element from its original position to 500px to the left for 1000ms and
* // change the background color of the element at the end of the animation
* $("#foo").animate("left:'+=500'", 1000, new Function(){
* public void f(Element e){
@@ -277,9 +241,8 @@ public interface LazyGQuery<T> extends LazyBase<T>{
* $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)', 1000");
* </pre>
*
- * @param prop the property to animate : "cssName:'value'"
- * @param funcs an array of {@link Function} called once the animation is complete
- * @param duration the duration in milliseconds of the animation
+ * @param stringOrProperties the set of properties to animate : "cssName:'value'"
+ * @param funcs an array of {@link Function} called once the animation is complete.
*/
LazyGQuery<T> animate(Object stringOrProperties, int duration, Function... funcs);
@@ -894,7 +857,8 @@ public interface LazyGQuery<T> extends LazyBase<T>{
/**
* Remove all event handlers previously attached using {@link #live(String, Function)}. In order
* for this method to function correctly, the selector used with it must match exactly the
- * selector initially used with {@link #live(String, Function)}
+ * selector initially used with {@link #live(String, Function)}.
+ *
* @deprecated use {@link #off(String, String)} instead
*/
LazyGQuery<T> die();
@@ -902,7 +866,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
/**
* Remove an event handlers previously attached using {@link #live(int, Function)} In order for
* this method to function correctly, the selector used with it must match exactly the selector
- * initially used with {@link #live(int, Function)}
+ * initially used with {@link #live(int, Function)}.
* @deprecated use {@link #off(String)}
*/
LazyGQuery<T> die(int eventbits);
@@ -910,7 +874,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
/**
* Remove an event handlers previously attached using {@link #live(String, Function)} In order for
* this method to function correctly, the selector used with it must match exactly the selector
- * initially used with {@link #live(String, Function)}
+ * initially used with {@link #live(String, Function)}.
*/
LazyGQuery<T> die(String eventName);
@@ -1242,7 +1206,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
boolean isEmpty();
/**
- * Return true if the first element is visible.isVisible
+ * Return true if the first element is visible.isVisible.
*/
boolean isVisible();
@@ -1570,7 +1534,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
/**
* Get all following siblings of each element up to but not including the element matched by the
- * GQuery object, filtered by a selector
+ * GQuery object, filtered by a selector.
*
* @return
*/
@@ -1642,17 +1606,17 @@ public interface LazyGQuery<T> extends LazyBase<T>{
LazyGQuery<T> off();
/**
- * Remove an event handler
+ * Remove an event handler.
*/
LazyGQuery<T> off(String eventName);
/**
- * Remove an event handler
+ * Remove an event handler.
*/
LazyGQuery<T> off(String eventName, Function f);
/**
- * Remove an event handler
+ * Remove an event handler.
*/
LazyGQuery<T> off(String eventName, String selector);
@@ -1723,9 +1687,9 @@ public interface LazyGQuery<T> extends LazyBase<T>{
/**
* Get the ancestors of each element in the current set of matched elements, up to but not
- * including the element matched by the selector.
+ * including the node.
*/
- LazyGQuery<T> parentsUntil(Node selector);
+ LazyGQuery<T> parentsUntil(Node node);
/**
* Gets the top and left position of an element relative to its offset parent. The returned object
@@ -2152,7 +2116,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
LazyGQuery<T> setSelector(String selector);
/**
- * Make all matched elements visible
+ * Make all matched elements visible.
*/
LazyGQuery<T> show();
@@ -2350,28 +2314,32 @@ public interface LazyGQuery<T> extends LazyBase<T>{
/**
* Remove all event delegation that have been bound using
- * {@link #delegate(String, int, Function...)} {@link #live(int, Function...)} methods
+ * {@link #delegate(String, int, Function...)} {@link #live(int, Function...)} methods.
+ *
* @deprecated use {@link #off()}
*/
LazyGQuery<T> undelegate();
/**
* Undelegate is a way of removing event handlers that have been bound using
- * {@link #delegate(String, int, Function...)} method
+ * {@link #delegate(String, int, Function...)} method.
+ *
* @deprecated use {@link #off(String)}
*/
LazyGQuery<T> undelegate(String selector);
/**
* Undelegate is a way of removing event handlers that have been bound using
- * {@link #delegate(String, int, Function...)} method
+ * {@link #delegate(String, int, Function...)} method.
+ *
* @deprecated use {@link #off(String)}
*/
LazyGQuery<T> undelegate(String selector, int eventBit);
/**
* Undelegate is a way of removing event handlers that have been bound using
- * {@link #delegate(String, int, Function...)} method
+ * {@link #delegate(String, int, Function...)} method.
+ *
* @deprecated use {@link #off(String, String)}
*/
LazyGQuery<T> undelegate(String selector, String eventName);
@@ -2384,7 +2352,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
/**
* This method removes the element's parent. The matched elements replaces their parents within
- * the DOM structure. It is the inverse of {@link GQuery#wrap(GQuery)} method
+ * the DOM structure. It is the inverse of {@link GQuery#wrap(GQuery)} method.
*
* @return
*/
@@ -2393,7 +2361,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
/**
* Gets the content of the value attribute of the first matched element, returns only the first
* value even if it is a multivalued element. To get an array of all values in multivalues
- * elements use vals()
+ * elements use vals().
*
* When the first element is a radio-button and is not checked, then it looks for the first
* checked radio-button that has the same name in the list of matched elements.
@@ -2464,7 +2432,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
<W extends Widget> W widget(int n);
/**
- * return the list of attached widgets matching the query
+ * return the list of attached widgets matching the query.
*/
List<Widget> widgets();
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..55b28e14 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
@@ -31,12 +31,11 @@ public class Predicate {
* @param index
* the element position in the gquery elements array.
*/
- public boolean f(Element e, int index) {
- return f((Object)e, index);
+ public boolean f(Element e, int index) {
+ return f((Object) e, index);
}
public <T> 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..3b0650e4 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,8 +13,6 @@
*/
package com.google.gwt.query.client;
-import com.google.gwt.query.client.Function;
-
/**
* Definition of jquery Promise interface used in gquery.
*/
@@ -45,9 +43,9 @@ public interface Promise {
Deferred resolve(Object... o);
}
- public static final String PENDING = "pending";
- public static final String REJECTED = "rejected";
- public static final String RESOLVED = "resolved";
+ String PENDING = "pending";
+ String REJECTED = "rejected";
+ String RESOLVED = "resolved";
/**
* Add handlers to be called when the Deferred object is either resolved or rejected.
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 0997404e..c75dd238 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
@@ -38,7 +38,8 @@ public class Properties extends JavaScriptObject implements IsProperties {
return JsUtils.parseJSON(p);
} catch (Exception e) {
if (!GWT.isProdMode()) {
- System.err.println("Error creating Properties: \n> " + properties + "\n< " + p + "\n" + e.getMessage());
+ System.err.println("Error creating Properties: \n> " + properties + "\n< " + p + "\n"
+ + e.getMessage());
}
}
}
@@ -57,10 +58,10 @@ public class Properties extends JavaScriptObject implements IsProperties {
public static String wrapPropertiesString(String s) {
String ret = s //
.replaceAll("\\s*/\\*[\\s\\S]*?\\*/\\s*", "") // Remove comments
- .replaceAll("([:\\)\\(,;}{'\"])\\s+" , "$1") // Remove spaces
- .replaceAll("\\s+([:\\)\\(,;}{'\"])" , "$1") // Remove spaces
+ .replaceAll("([:\\)\\(,;}{'\"])\\s+", "$1") // Remove spaces
+ .replaceAll("\\s+([:\\)\\(,;}{'\"])", "$1") // Remove spaces
.replaceFirst("^[\\(]+(.*)[\\)]+$", "$1") // Remove ()
- .replaceAll("\\([\"']([^\\)]+)[\"']\\)" , "($1)") // Remove quotes
+ .replaceAll("\\([\"']([^\\)]+)[\"']\\)", "($1)") // Remove quotes
.replaceAll("[;,]+([\\w-\\$]+:|$)", ";$1") // Change comma by semicolon
.replaceAll("([^,;])([\\]}])", "$1;$2") // Put control semicolon used below
.replaceAll(":\\s*[\"']?([^;\\{\\}\\[\\]\"']*)[\"']?\\s*([;,]+|$)", ":\"$1\";") // put quotes to all values (even empty)
@@ -71,8 +72,7 @@ public class Properties extends JavaScriptObject implements IsProperties {
.replaceAll(";([^:]+):", ",$1:") // change semicolon
.replaceAll(";([^:]+):", ",$1:") // change semicolon second pass
.replaceAll(":\"(-?\\d[\\d\\.]*|null|false|true)\"[;,]", ":$1,") // numbers do not need quote
- .replaceAll("[;,]+([\\]\\}]|$)", "$1") // remove endings
- ;
+ .replaceAll("[;,]+([\\]\\}]|$)", "$1"); // remove endings
ret = ret.matches("(^[\\[\\{].*[\\]\\}]$)") ? ret : "{" + ret + "}";
return ret;
}
@@ -86,7 +86,7 @@ public class Properties extends JavaScriptObject implements IsProperties {
}
private JsCache c() {
- return this.<JsCache>cast();
+ return this.<JsCache> cast();
}
public final native Properties cloneProps() /*-{
@@ -104,7 +104,7 @@ public class Properties extends JavaScriptObject implements IsProperties {
@SuppressWarnings("unchecked")
public final <T> T get(Object name) {
// Casting because of issue_135
- return (T)c().get(String.valueOf(name));
+ return (T) c().get(String.valueOf(name));
}
public final boolean getBoolean(Object name) {
@@ -119,13 +119,13 @@ public class Properties extends JavaScriptObject implements IsProperties {
final Object o = c().get(String.valueOf(name));
if (o != null) {
if (o instanceof Function) {
- return (Function)o;
+ return (Function) o;
} else if (o instanceof JavaScriptObject) {
- Object f = ((JavaScriptObject)o).<Properties>cast().getObject("__f");
+ Object f = ((JavaScriptObject) o).<Properties> cast().getObject("__f");
if (f != null && f instanceof Function) {
return (Function) f;
}
- return new JsUtils.JsFunction((JavaScriptObject)o);
+ return new JsUtils.JsFunction((JavaScriptObject) o);
}
}
return null;
@@ -150,7 +150,7 @@ public class Properties extends JavaScriptObject implements IsProperties {
@SuppressWarnings("unchecked")
public final <T extends JavaScriptObject> T getJavaScriptObject(Object name) {
// Casting because of issue_135
- return (T)c().getJavaScriptObject(String.valueOf(name));
+ return (T) c().getJavaScriptObject(String.valueOf(name));
}
public final JsArrayMixed getArray(Object 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 <T> void setFunction(T name, Function f) /*-{
if (!f) return;
@@ -207,17 +207,22 @@ public class Properties extends JavaScriptObject implements IsProperties {
return JsUtils.param(JsCache.checkNull(this));
}
- public final boolean isEmpty(){
+ public final boolean isEmpty() {
return c().length() == 0;
}
public final <J extends IsProperties> J load(Object prp) {
c().clear();
if (prp instanceof JsCache) {
- c().copy((JsCache)prp);
+ c().copy((JsCache) prp);
}
return getDataImpl();
}
+
+ @SuppressWarnings("unchecked")
+ public final <J extends IsProperties> J strip() {
+ return (J) this;
+ }
public final <J extends IsProperties> J parse(String json) {
return load(JsUtils.parseJSON(json));
@@ -241,7 +246,7 @@ public class Properties extends JavaScriptObject implements IsProperties {
@SuppressWarnings("unchecked")
public final <J> J getDataImpl() {
- return (J)this;
+ return (J) this;
}
public final String getJsonName() {
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/Selectors.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Selectors.java
index 6c44caed..f20619ce 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Selectors.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Selectors.java
@@ -54,12 +54,12 @@ public interface Selectors {
* Set the context for all the selectors.
* By default they are evaluated in all the document.
*/
- public void setRoot(Node node);
+ void setRoot(Node node);
/**
* Get the configured root context.
*/
- public Node getRoot();
+ Node getRoot();
/**
* Used for benchmarking purposes, it returns true if the selector engine
@@ -68,5 +68,5 @@ public interface Selectors {
*
* It is useful to check if IE8 native selectors are being used.
*/
- public boolean isDegradated();
+ boolean isDegradated();
}
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 60b209c0..41d6cd7e 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
@@ -31,8 +31,9 @@ public interface JsonBuilder extends IsProperties {
/**
* Returns the wrapped object, normally a Properties jso in client
- * but can be used to return the underlying Json implementation in JVM
- * @deprecated use asObject() instead
+ * but can be used to return the underlying Json implementation in JVM.
+ *
+ * @deprecated use asObject() instead.
*/
<J> J getProperties();
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 4c25117a..f0c46931 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,22 @@ 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 java.util.Arrays;
+import java.util.List;
+
+/**
+ * Common class for all JsonBuilder implementations.
+ *
+ * @param <J>
+ */
public abstract class JsonBuilderBase<J extends JsonBuilderBase<?>> implements JsonBuilder {
protected Properties p = Properties.create();
+ protected String[] fieldNames = new String[] {};
@SuppressWarnings("unchecked")
@Override
@@ -40,22 +50,36 @@ public abstract class JsonBuilderBase<J extends JsonBuilderBase<?>> implements J
@SuppressWarnings("unchecked")
@Override
+ public J strip() {
+ List<String> 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.<JsCache>cast().delete(jsonName);
+ }
+ }
+ return (J) this;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
public J load(Object prp) {
assert prp == null || prp instanceof JavaScriptObject || prp instanceof String;
if (prp != null && prp instanceof String) {
- return parse((String)prp);
+ return parse((String) prp);
}
if (prp != null) {
- p = (Properties)prp;
+ p = (Properties) prp;
}
- return (J)this;
+ return (J) this;
}
protected <T> void setArrayBase(String n, T[] r) {
if (r.length > 0 && r[0] instanceof JsonBuilder) {
JsArray<JavaScriptObject> a = JavaScriptObject.createArray().cast();
for (T o : r) {
- a.push(((JsonBuilder)o).<Properties>getDataImpl());
+ a.push(((JsonBuilder) o).<Properties> getDataImpl());
}
p.set(n, a);
} else {
@@ -69,12 +93,12 @@ public abstract class JsonBuilderBase<J extends JsonBuilderBase<?>> implements J
protected <T> T[] getArrayBase(String n, T[] r, Class<T> clazz) {
JsObjectArray<?> a = p.getArray(n).cast();
int l = r.length;
- for (int i = 0 ; i < l ; i++) {
+ for (int i = 0; i < l; i++) {
Object w = a.get(i);
Class<?> c = w.getClass();
do {
if (c.equals(clazz)) {
- r[i] = (T)w;
+ r[i] = (T) w;
break;
}
c = c.getSuperclass();
@@ -127,14 +151,18 @@ public abstract class JsonBuilderBase<J extends JsonBuilderBase<?>> implements J
@SuppressWarnings("unchecked")
public <T extends IsProperties> T set(Object key, Object val) {
if (val instanceof IsProperties) {
- p.set(key, ((IsProperties)val).getDataImpl());
+ p.set(key, ((IsProperties) val).getDataImpl());
} else {
p.set(key, val);
}
- return (T)this;
+ return (T) this;
}
public <T extends JsonBuilder> T as(Class<T> clz) {
return p.as(clz);
}
+
+ public final String[] getFieldNames() {
+ return fieldNames;
+ }
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonFactory.java
index b4d68323..4e93b043 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonFactory.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonFactory.java
@@ -17,8 +17,13 @@ package com.google.gwt.query.client.builders;
import com.google.gwt.query.client.IsProperties;
+/**
+ * Factory interface.
+ */
public interface JsonFactory {
<T extends JsonBuilder> T create(Class<T> clz);
+
IsProperties create(String s);
+
IsProperties create();
}
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..4d7cba47 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.
*/
@@ -39,32 +39,32 @@ public interface XmlBuilder {
Element getRootElement();
/**
- * Appends a node
+ * Appends a node.
*/
void append(XmlBuilder x);
/**
- * Appends xml content
+ * Appends xml content.
*/
void append(String x);
/**
- * Returns the text content of the element
+ * Returns the text content of the element.
*/
String getText();
/**
- * Sets the text content of the element
+ * Sets the text content of the element.
*/
<J> J setText(String t);
/**
- * Returns the text content of the element as a number
+ * Returns the text content of the element as a number.
*/
double getTextAsNumber();
/**
- * Returns the text content of the element as a date
+ * Returns the text content of the element as a date.
*/
Date getTextAsDate();
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..91c43874 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,10 +24,17 @@ 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;
+
+/**
+ * Common code in XmlBuilder implementations.
+ *
+ * @param <J>
+ */
public abstract class XmlBuilderBase<J extends XmlBuilderBase<?>> implements XmlBuilder {
- //TODO empty document
- protected GQuery g = $((Element)JsUtils.parseXML("<root/>"));
+ // TODO empty document
+ protected GQuery g = $((Element) JsUtils.parseXML("<root/>"));
public void append(String xml) {
g.append(JsUtils.parseXML(xml));
@@ -74,39 +79,40 @@ public abstract class XmlBuilderBase<J extends XmlBuilderBase<?>> implements Xml
}
public double getTextAsNumber() {
- String t = g.text().replaceAll("[^\\d\\.\\-]", "");
+ String t = g.text().replaceAll("[^\\d\\.\\-]", "");
return t.isEmpty() ? 0 : Double.parseDouble(t);
}
public Date getTextAsDate() {
- String t = g.text().trim();
+ String t = g.text().trim();
if (t.matches("\\d+")) {
return new Date(Long.parseLong(t));
} else {
- return new Date((long)JsDate.parse(t));
+ return new Date((long) JsDate.parse(t));
}
}
public boolean getTextAsBoolean() {
- String t = g.text().trim().toLowerCase();
+ String t = g.text().trim().toLowerCase();
return !t.matches("^(|false|off|0)$");
}
public <T extends Enum<T>> T getTextAsEnum(Class<T> clazz) {
- String t = g.text().trim();
+ String t = g.text().trim();
return Enum.valueOf(clazz, t);
}
@SuppressWarnings("unchecked")
public J load(Object o) {
- assert o == null || o instanceof JavaScriptObject && JsUtils.isElement((JavaScriptObject)o) || o instanceof String;
+ assert o == null || o instanceof JavaScriptObject && JsUtils.isElement((JavaScriptObject) o)
+ || o instanceof String;
if (o != null && o instanceof String) {
- return parse((String)o);
+ return parse((String) o);
}
if (o != null) {
- g=$((Element)o);
+ g = $((Element) o);
}
- return (J)this;
+ return (J) this;
}
@SuppressWarnings("unchecked")
@@ -116,7 +122,7 @@ public abstract class XmlBuilderBase<J extends XmlBuilderBase<?>> implements Xml
protected <T> void setArrayBase(String n, T[] r) {
String v = "";
- for (T t: r) {
+ for (T t : r) {
v += String.valueOf(t);
}
setBase(n, v);
@@ -129,7 +135,7 @@ public abstract class XmlBuilderBase<J extends XmlBuilderBase<?>> implements Xml
@SuppressWarnings("unchecked")
public <T> T setText(String t) {
g.text(t);
- return (T)this;
+ return (T) this;
}
public String toString() {
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..a3afad98 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
@@ -25,6 +25,9 @@ import com.google.gwt.dom.client.Style.HasCssName;
public class BackgroundAttachmentProperty extends
CssProperty<BackgroundAttachmentProperty.BackgroundAttachment> {
+ /**
+ * BackgroundAttachment.
+ */
public static enum BackgroundAttachment implements HasCssName {
/**
* Background image is fixed.
@@ -46,7 +49,6 @@ public class BackgroundAttachmentProperty extends
};
public abstract String getCssName();
-
}
private static final String CSS_PROPERTY = "backgroundAttachment";
@@ -60,5 +62,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..eb5f10d0 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
@@ -16,7 +16,7 @@
package com.google.gwt.query.client.css;
/**
- * This property sets the background image of an element,
+ * This property sets the background image of an element.
*/
public class BackgroundImageProperty extends CssProperty<UriValue> {
@@ -29,5 +29,4 @@ public class BackgroundImageProperty extends CssProperty<UriValue> {
private BackgroundImageProperty() {
super(CSS_PROPERTY);
}
-
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundPositionProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundPositionProperty.java
index c0b37fb4..87940bf5 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundPositionProperty.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundPositionProperty.java
@@ -27,19 +27,16 @@ public class BackgroundPositionProperty extends
/**
* Value for <i>background-position</i> property.
- *
- * @author Julien Dramaix (julien.dramaix@gmail.com)
- *
*/
public static class BackgroundPosition implements HasCssName {
/**
- * Equivalent to {@link BackgroundPosition#CENTER_BOTTOM}
+ * Equivalent to {@link BackgroundPosition#CENTER_BOTTOM}.
*/
public static BackgroundPosition BOTTOM;
/**
- * Equivalent to {@link BackgroundPosition#CENTER_CENTER}
+ * Equivalent to {@link BackgroundPosition#CENTER_CENTER}.
*/
public static BackgroundPosition CENTER;
@@ -62,7 +59,7 @@ public class BackgroundPositionProperty extends
public static BackgroundPosition CENTER_TOP;
/**
- * Equivalent to {@link BackgroundPosition#LEFT_CENTER}
+ * Equivalent to {@link BackgroundPosition#LEFT_CENTER}.
*/
public static BackgroundPosition LEFT;
@@ -85,7 +82,7 @@ public class BackgroundPositionProperty extends
public static BackgroundPosition LEFT_TOP;
/**
- * Equivalent to {@link BackgroundPosition#RIGHT_CENTER}
+ * Equivalent to {@link BackgroundPosition#RIGHT_CENTER}.
*/
public static BackgroundPosition RIGHT;
@@ -108,7 +105,7 @@ public class BackgroundPositionProperty extends
public static BackgroundPosition RIGHT_TOP;
/**
- * Equivalent to {@link BackgroundPosition#CENTER_TOP}
+ * Equivalent to {@link BackgroundPosition#CENTER_TOP}.
*/
public static BackgroundPosition TOP;
@@ -134,12 +131,11 @@ public class BackgroundPositionProperty extends
RIGHT_TOP = new BackgroundPosition(RIGHT_VALUE + " " + TOP_VALUE);
TOP = new BackgroundPosition(TOP_VALUE);
BOTTOM = new BackgroundPosition(BOTTOM_VALUE);
-
}
/**
* Return a {@link BackgroundPosition} by specifying the horizontal and
- * vertical position. Pixel will be used as Unit
+ * vertical position. Pixel will be used as Unit.
*/
public static BackgroundPosition position(int xpos, int ypos) {
return position(xpos, ypos, Unit.PX);
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundRepeatProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundRepeatProperty.java
index f7ee0ef8..fb69e7c0 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundRepeatProperty.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BackgroundRepeatProperty.java
@@ -47,7 +47,7 @@ public class BackgroundRepeatProperty extends
*/
REPEAT_Y;
- public String getCssName(){
+ public String getCssName() {
return name().toLowerCase().replace('_', '-');
}
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderCollapseProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderCollapseProperty.java
index 7a626105..edcfdac4 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderCollapseProperty.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderCollapseProperty.java
@@ -23,6 +23,9 @@ import com.google.gwt.dom.client.Style.HasCssName;
public class BorderCollapseProperty extends
CssProperty<BorderCollapseProperty.BorderCollapse> {
+ /**
+ * BorderCollapse.
+ */
public static enum BorderCollapse implements HasCssName {
/**
* Borders are collapsed into a single border when possible (border-spacing
@@ -45,7 +48,6 @@ public class BorderCollapseProperty extends
public static void init() {
CSS.BORDER_COLLAPSE = new BorderCollapseProperty();
-
}
private BorderCollapseProperty() {
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/BorderSpacingProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderSpacingProperty.java
index eee9f71d..81d58fd1 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderSpacingProperty.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderSpacingProperty.java
@@ -38,7 +38,7 @@ public class BorderSpacingProperty extends
/**
* Construct a {@link BorderSpacing} object with same horizontal and
- * vertical spacing
+ * vertical spacing.
*/
public BorderSpacing(Length spacing) {
this(spacing, spacing);
@@ -66,7 +66,6 @@ public class BorderSpacingProperty extends
public static void init() {
CSS.BORDER_SPACING = new BorderSpacingProperty();
-
}
private BorderSpacingProperty() {
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..d1431407 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
@@ -24,6 +24,9 @@ import com.google.gwt.dom.client.Style.HasCssName;
public class BorderStyleProperty extends
CssProperty<BorderStyleProperty.BorderStyle> {
+ /**
+ * BorderStyle.
+ */
public static enum BorderStyle implements HasCssName {
/**
* The border is a series of short line segments.
@@ -106,5 +109,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..c6a43756 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,8 @@
*/
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.
@@ -654,7 +625,7 @@ public class CSS {
/**
* CSS value specifying that the setting of the related property should be
- * inherited from the parent element
+ * inherited from the parent element.
*/
public static final String INHERIT = "inherit";
@@ -1313,7 +1284,5 @@ public class CSS {
WhiteSpaceProperty.init();
WordSpacingProperty.init();
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<ClearProperty.Clear> {
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<ClipProperty.Shape> {
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..21b1f4b7 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,13 +20,16 @@ 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 <T> Class of the value associated with the css property
*/
public class CssProperty<T extends HasCssName> implements
TakesCssValue<T> {
+ /**
+ * CssSetterImpl.
+ */
protected class CssSetterImpl implements CssSetter {
private T cssValue;
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CursorProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CursorProperty.java
index ed706423..8cb6ae03 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CursorProperty.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/CursorProperty.java
@@ -19,7 +19,7 @@ import com.google.gwt.dom.client.Style.Cursor;
/**
* The <i>cursor</i> property specifies the type of cursor to be displayed for
- * the pointing device
+ * the pointing device.
*/
public class CursorProperty extends CssProperty<Cursor> {
@@ -33,7 +33,7 @@ public class CursorProperty extends CssProperty<Cursor> {
super(CSS_PROPERTY);
}
- public CssSetter with(UriValue url){
+ public CssSetter with(UriValue url) {
return new SimpleCssSetter(this, url);
}
}
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<Length> {
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/HasCssValue.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/HasCssValue.java
index e219b4d8..f6ea511a 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/HasCssValue.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/HasCssValue.java
@@ -19,7 +19,7 @@ import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.HasCssName;
/**
- * Minimal contract for an object defining a css property
+ * Minimal contract for an object defining a css property.
*
*/
public interface HasCssValue extends HasCssName {
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..e2cd01ff 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
@@ -17,7 +17,7 @@ package com.google.gwt.query.client.css;
/**
* All height css properties : <i>max-height</i>, <i>min-height</i>,
- * <i>height</i>
+ * <i>height</i>.
*/
public class HeightProperty extends CssProperty<Length> {
@@ -34,5 +34,4 @@ public class HeightProperty extends CssProperty<Length> {
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<Length> {
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<Length> 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..6544508a 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
@@ -22,6 +22,9 @@ import com.google.gwt.dom.client.Style;
*/
public class MarginProperty extends CssProperty<Length> {
+ /**
+ * ShorthandMarginProperty.
+ */
public static class ShorthandMarginProperty implements HasCssValue {
private ShorthandMarginProperty() {
@@ -36,29 +39,26 @@ public class MarginProperty extends CssProperty<Length> {
}
/**
- * Apply the same margin to all sides
+ * Apply the same margin to all sides.
*/
public CssSetter with(Length margin) {
return new MultipleValueCssSetter(getCssName(), margin);
-
}
/**
* The top and bottom margins are set to the first value and the right and
- * left margins are set to the second
+ * left margins are set to the second.
*/
public CssSetter with(Length topAndBottom, Length leftAndRight) {
return new MultipleValueCssSetter(getCssName(), topAndBottom, leftAndRight);
-
}
/**
* The top margin is set to the first value, the left and right margins are
- * set to the second, and the bottom margin is set to the third
+ * set to the second, and the bottom margin is set to the third.
*/
public CssSetter with(Length top, Length leftAndRight, Length bottom) {
return new MultipleValueCssSetter(getCssName(), top, leftAndRight, bottom);
-
}
/**
@@ -68,9 +68,7 @@ public class MarginProperty extends CssProperty<Length> {
Length margin4) {
return new MultipleValueCssSetter(getCssName(), margin1, margin2,
margin3, margin4);
-
}
-
}
private static String MARGIN_BOTTOM_PROPERTY = "marginBottom";
@@ -90,5 +88,4 @@ public class MarginProperty extends CssProperty<Length> {
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..27dbca04 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
@@ -17,16 +17,19 @@ package com.google.gwt.query.client.css;
import com.google.gwt.dom.client.Style.HasCssName;
+/**
+ * MultipleValueCssSetter.
+ */
public class MultipleValueCssSetter extends SimpleCssSetter {
public MultipleValueCssSetter(String cssPropertyName, HasCssName... values) {
super(cssPropertyName, computeValue(values));
}
- protected static String computeValue(HasCssName... values){
+ protected static String computeValue(HasCssName... values) {
StringBuilder valueBuilder = new StringBuilder();
- for (HasCssName cssValue : values){
+ for (HasCssName cssValue : values) {
valueBuilder.append(notNull(cssValue));
}
@@ -36,5 +39,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..820967be 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
@@ -28,7 +28,7 @@ import com.google.gwt.query.client.css.TakesCssValue.CssSetter;
* declaration.
*/
public class OutlineProperty implements
- HasCssValue{
+ HasCssValue {
private static final String CSS_PROPERTY = "outline";
@@ -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..43a75f62 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
@@ -23,6 +23,9 @@ import com.google.gwt.dom.client.Style;
*/
public class PaddingProperty extends CssProperty<Length> {
+ /**
+ * ShorthandPaddingProperty.
+ */
public static class ShorthandPaddingProperty implements HasCssValue {
private ShorthandPaddingProperty() {
@@ -37,30 +40,27 @@ public class PaddingProperty extends CssProperty<Length> {
}
/**
- * Apply the same padding to all sides
+ * Apply the same padding to all sides.
*/
public CssSetter with(Length padding) {
return new MultipleValueCssSetter(getCssName(), padding);
-
}
/**
* The top and bottom paddings are set to the first value and the right and
- * left paddings are set to the second
+ * left paddings are set to the second.
*/
public CssSetter with(Length topAndBottom, Length leftAndRight) {
return new MultipleValueCssSetter(getCssName(), topAndBottom,
leftAndRight);
-
}
/**
* The top padding is set to the first value, the left and right paddings
- * are set to the second, and the bottom padding is set to the third
+ * are set to the second, and the bottom padding is set to the third.
*/
public CssSetter with(Length top, Length leftAndRight, Length bottom) {
return new MultipleValueCssSetter(getCssName(), top, leftAndRight, bottom);
-
}
/**
@@ -70,9 +70,7 @@ public class PaddingProperty extends CssProperty<Length> {
Length padding4) {
return new MultipleValueCssSetter(getCssName(), padding1, padding2,
padding3, padding4);
-
}
-
}
private static String PADDING_BOTTOM_PROPERTY = "paddingBottom";
@@ -92,5 +90,4 @@ public class PaddingProperty extends CssProperty<Length> {
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<Position> {
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..fb605568 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
@@ -21,7 +21,7 @@ import com.google.gwt.query.client.css.TakesCssValue.CssSetter;
/**
* Simple implementation of {@link CssSetter} interface. It does its job for the
- * most CSS property
+ * most CSS property.
*
*/
public class SimpleCssSetter implements CssSetter {
@@ -41,7 +41,5 @@ public class SimpleCssSetter implements CssSetter {
public void applyCss(Element e) {
assert e != null : "Impossible to apply css to a null object";
e.getStyle().setProperty(property, value != null ? value : "");
-
}
-
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesCssValue.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesCssValue.java
index 5f9d922d..def5d1f1 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesCssValue.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesCssValue.java
@@ -19,13 +19,17 @@ import com.google.gwt.dom.client.Element;
/**
* An CSS property with values of type T.
+ *
+ * @param <T>
*/
public interface TakesCssValue<T> extends HasCssValue {
- public interface CssSetter {
- public void applyCss(Element e);
+ /**
+ * CssSetter.
+ */
+ interface CssSetter {
+ void applyCss(Element e);
}
CssSetter with(T value);
-
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesInteger.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesInteger.java
index f298feaa..1ec7fadf 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesInteger.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesInteger.java
@@ -19,7 +19,7 @@ import com.google.gwt.query.client.css.TakesCssValue.CssSetter;
/**
* Interface to be implemented by properties which take a integer as defined in
- * css2 specification
+ * css2 specification.
*
* @see http://www.w3.org/TR/CSS21/syndata.html#value-def-number
*/
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesNumber.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesNumber.java
index fb443198..5fefe271 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesNumber.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/TakesNumber.java
@@ -19,7 +19,7 @@ import com.google.gwt.query.client.css.TakesCssValue.CssSetter;
/**
* Interface to be implemented by properties which take a number as defined in
- * css2 specification
+ * css2 specification.
*
* @see http://www.w3.org/TR/CSS21/syndata.html#value-def-number
*/
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<TextDecoration> {
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<Length> {
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..069f00ad 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
@@ -18,13 +18,13 @@ package com.google.gwt.query.client.css;
import com.google.gwt.dom.client.Style.HasCssName;
/**
- * This property defines the text direction/writing direction
+ * This property defines the text direction/writing direction.
*/
public class UnicodeBidiProperty extends
CssProperty<UnicodeBidiProperty.UnicodeBidi> {
/**
- * Define possible values for <i>unicode-bidi</i> property
+ * Define possible values for <i>unicode-bidi</i> property.
*
*/
public static enum UnicodeBidi implements HasCssName {
@@ -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..0ea5ca25 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
@@ -18,12 +18,12 @@ package com.google.gwt.query.client.css;
import com.google.gwt.dom.client.Style.HasCssName;
/**
- * Image as css value
+ * Image as css value.
*/
public class UriValue implements HasCssName {
/**
- * Define an uri by an url
+ * Define an uri by an url.
*/
public static UriValue url(String url) {
return new UriValue("url('" + url + "')");
@@ -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<VerticalAlign>
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<Visibility> {
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..38ecca52 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
@@ -19,11 +19,14 @@ import com.google.gwt.dom.client.Style.HasCssName;
/**
* The <i>white-space</i> property declares how white space inside the element
- * is handled
+ * is handled.
*/
public class WhiteSpaceProperty extends
CssProperty<WhiteSpaceProperty.WhiteSpace> {
+ /**
+ * WhiteSpace.
+ */
public enum WhiteSpace implements HasCssName {
/**
@@ -73,5 +76,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..b1f7be26 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
@@ -16,7 +16,7 @@
package com.google.gwt.query.client.css;
/**
- * All width css properties : <i>max-width</i>, <i>min-width</i>, <i>width</i>
+ * All width css properties : <i>max-width</i>, <i>min-width</i>, <i>width</i>.
*/
public class WidthProperty extends CssProperty<Length> {
@@ -33,5 +33,4 @@ public class WidthProperty extends CssProperty<Length> {
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<Length> {
private WordSpacingProperty() {
super(CSS_PROPERTY);
}
-
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ZIndexProperty.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ZIndexProperty.java
index 76c9bcb3..2bd55ac9 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ZIndexProperty.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/css/ZIndexProperty.java
@@ -52,19 +52,18 @@ public class ZIndexProperty implements TakesInteger {
/**
* returns a {@link CssSetter} object setting <i>z-index</i> property to the
- * specified <code>value</code>
+ * specified <code>value</code>.
*/
public CssSetter with(Integer value) {
return new SimpleCssSetter(CSS_PROPERTY, value != null ? value.toString() : null);
}
/**
- * See GWT issue 5548
+ * See GWT issue 5548.
* http://code.google.com/p/google-web-toolkit/issues/detail?id=5548
*/
private native String getZIndex(Style s) /*-{
- //force to return a string
+ // force to return a string
return "" + s["zIndex"];
}-*/;
-
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java
index 0a6a6642..3fc8e3bc 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java
@@ -1,4 +1,5 @@
-/* Copyright 2011, The gwtquery team.
+/*
+ * Copyright 2011, The gwtquery team.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -10,7 +11,8 @@
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
- * the License. */
+ * the License.
+ */
package com.google.gwt.query.client.impl;
import com.google.gwt.dom.client.Element;
@@ -28,9 +30,9 @@ public class AttributeImpl {
* Interface used for attribute setter implementations.
*/
public interface AttributeSetter {
- public boolean isRemoval(Object value);
+ boolean isRemoval(Object value);
- public void setAttribute(Element e, String name, Object value);
+ void setAttribute(Element e, String name, Object value);
}
/**
@@ -56,7 +58,7 @@ public class AttributeImpl {
}
/**
- * value must be set on element directly
+ * value must be set on element directly.
*/
protected static class ValueAttrSetter extends DefaultSetter {
private static AttributeSetter INSTANCE;
@@ -75,7 +77,7 @@ public class AttributeImpl {
}
/**
- * Boolean attribute :
+ * Boolean attribute.
* - Ensure to set a boolean value to the element's property with the same
* name if this last exists
* - Ensure to set an attribute having the value equals to the name (i.e
@@ -124,7 +126,7 @@ public class AttributeImpl {
/**
* For button and inputs, the type cannot be changed once the element is
- * attached to the dom !
+ * attached to the DOM.
*/
private static class TypeAttrSetter extends DefaultSetter {
private static AttributeSetter INSTANCE;
@@ -145,12 +147,12 @@ public class AttributeImpl {
String tag = e.getNodeName();
if (NOT_AUTHORIZED_NODE.test(tag)
&& GQuery.$(e).parents("body").length() > 0) {
- //TODO maybe it's better to simply do nothing...
+ // TODO maybe it's better to simply do nothing...
throw new RuntimeException(
"You cannot change type of button or input element if the element is already attached to the dom");
}
if ("input".equals(tag.toLowerCase()) && "radio".equals(value)) {
- //some browser (IE6-9) resets value property of the input when you change the type to radio button
+ // some browser (IE6-9) resets value property of the input when you change the type to radio button
InputElement ie = InputElement.as(e);
String keepValue = ie.getValue();
super.setAttribute(ie, "type", value);
@@ -190,7 +192,7 @@ public class AttributeImpl {
value = fixValue(key, value);
for (Element e : gQuery.elements()) {
int nodeType = e.getNodeType();
- //don't set attribute on text, comment and attributes nodes
+ // don't set attribute on text, comment and attributes nodes
if (nodeType == 3 || nodeType == 8 || nodeType == 2) {
continue;
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeTridentImpl.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeTridentImpl.java
index 2e22ceda..f12b65aa 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeTridentImpl.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeTridentImpl.java
@@ -60,7 +60,7 @@ public class AttributeTridentImpl extends AttributeImpl {
}
}
- private static native String getAttributeNode(Element e, String name)/*-{
+ private static native String getAttributeNode(Element e, String name) /*-{
var attrNode = e.getAttributeNode(name);
if (attrNode && attrNode.nodeValue !== "") {
return attrNode.nodeValue;
@@ -69,13 +69,13 @@ public class AttributeTridentImpl extends AttributeImpl {
}-*/;
private static native boolean setAttributeNode(Element e, String name,
- Object value)/*-{
- var attrNode = e.getAttributeNode(name);
- if (attrNode) {
- attrNode.nodeValue = value;
- return true;
- }
- return false;
+ Object value) /*-{
+ var attrNode = e.getAttributeNode(name);
+ if (attrNode) {
+ attrNode.nodeValue = value;
+ return true;
+ }
+ return false;
}-*/;
@Override
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/ConsoleBrowser.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/ConsoleBrowser.java
index 6b7fb162..22407506 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/ConsoleBrowser.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/ConsoleBrowser.java
@@ -27,11 +27,11 @@ import com.google.gwt.query.client.js.JsObjectArray;
public class ConsoleBrowser implements Console {
/**
- * http://whattheheadsaid.com/2011/04/internet-explorer-9s-problematic-console-object
+ * http://whattheheadsaid.com/2011/04/internet-explorer-9s-problematic-console-object.
*/
private static class ConsoleIe8 extends ConsoleIe9 {
@Override
- protected native void init()/*-{
+ protected native void init() /*-{
try {
Function.prototype.call.call($wnd.console.log, $wnd.console, Array.prototype.slice.call(arguments));
this.@com.google.gwt.query.client.impl.ConsoleBrowser.ConsoleIe9::initialized = true;
@@ -41,17 +41,17 @@ public class ConsoleBrowser implements Console {
}
/**
- * See: http://whattheheadsaid.com/2011/04/internet-explorer-9s-problematic-console-object
+ * See: http://whattheheadsaid.com/2011/04/internet-explorer-9s-problematic-console-object.
*/
private static class ConsoleIe9 extends ConsoleImpl {
private boolean initialized = false;
- public ConsoleIe9(){
+ public ConsoleIe9() {
init();
}
- protected native void init()/*-{
+ protected native void init() /*-{
try {
[ "log", "info", "warn", "error", "dir", "clear", "profile", "profileEnd" ]
.forEach(function(method) {
@@ -64,48 +64,80 @@ public class ConsoleBrowser implements Console {
@Override
public void clear() {
- if (initialized) super.clear();
+ if (initialized) {
+ super.clear();
+ }
}
+
@Override
public void dir(Object arg) {
- if (initialized) super.dir(arg);
+ if (initialized) {
+ super.dir(arg);
+ }
}
+
@Override
public void error(JavaScriptObject arg) {
- if (initialized) super.error(arg);
+ if (initialized) {
+ super.error(arg);
+ }
}
+
@Override
public void info(JavaScriptObject arg) {
- if (initialized) super.info(arg);
+ if (initialized) {
+ super.info(arg);
+ }
}
+
@Override
public void profile(String title) {
- if (initialized) super.profile(title);
+ if (initialized) {
+ super.profile(title);
+ }
}
+
@Override
public void profileEnd(String title) {
- if (initialized) super.profileEnd(title);
+ if (initialized) {
+ super.profileEnd(title);
+ }
}
+
@Override
public void warn(JavaScriptObject arg) {
- if (initialized) super.warn(arg);
+ if (initialized) {
+ super.warn(arg);
+ }
}
+
@Override
- public void group(Object arg) {}
+ public void group(Object arg) {
+ }
+
@Override
- public void groupCollapsed(Object arg) {}
+ public void groupCollapsed(Object arg) {
+ }
+
@Override
- public void groupEnd() {}
+ public void groupEnd() {
+ }
+
@Override
- public void time(String title) {}
+ public void time(String title) {
+ }
+
@Override
- public void timeStamp(Object arg) {}
+ public void timeStamp(Object arg) {
+ }
+
@Override
- public void timeEnd(String title) {}
+ public void timeEnd(String title) {
+ }
}
/**
- * Default implementation: webkit, opera, FF, ie10
+ * Default implementation: webkit, opera, FF, IE10.
*/
private static class ConsoleImpl {
public native void clear() /*-{
@@ -168,7 +200,9 @@ public class ConsoleBrowser implements Console {
private ConsoleImpl impl;
public ConsoleBrowser() {
- impl = GQuery.browser.ie8? new ConsoleIe8(): GQuery.browser.ie9? new ConsoleIe9(): new ConsoleImpl();
+ impl =
+ GQuery.browser.ie8 ? new ConsoleIe8() : GQuery.browser.ie9 ? new ConsoleIe9()
+ : new ConsoleImpl();
}
@Override
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java
index 4bd133ec..0a466a07 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java
@@ -31,7 +31,8 @@ import com.google.gwt.user.client.DOM;
*/
public class DocumentStyleImpl {
- private static final RegExp cssNumberRegex = RegExp.compile("^(fillOpacity|fontWeight|lineHeight|opacity|orphans|widows|zIndex|zoom)$", "i");
+ private static final RegExp cssNumberRegex = RegExp.compile(
+ "^(fillOpacity|fontWeight|lineHeight|opacity|orphans|widows|zIndex|zoom)$", "i");
private static final RegExp sizeRegex = RegExp.compile("^(client|offset|)(width|height)$", "i");
/**
@@ -92,7 +93,7 @@ public class DocumentStyleImpl {
return "";
}
name = fixPropertyName(name);
- //value defined in the element style
+ // value defined in the element style
String ret = elem.getStyle().getProperty(name);
if (force) {
@@ -121,10 +122,10 @@ public class DocumentStyleImpl {
}
private Element attachTemporary(Element elem) {
- Element lastParent = $(elem).parents().last().get(0);
+ Element lastParent = $(elem).parents().last().get(0);
- if (lastParent == null){
- //the element itself is detached
+ if (lastParent == null) {
+ // the element itself is detached
lastParent = elem;
}
@@ -167,7 +168,8 @@ public class DocumentStyleImpl {
// inline elements do not have width nor height unless we set it to inline-block
private void fixInlineElement(Element e) {
- if (e.getClientHeight() == 0 && e.getClientWidth() == 0 && "inline".equals(curCSS(e, "display", true))) {
+ if (e.getClientHeight() == 0 && e.getClientWidth() == 0
+ && "inline".equals(curCSS(e, "display", true))) {
setStyleProperty(e, "display", "inline-block");
setStyleProperty(e, "width", "auto");
setStyleProperty(e, "height", "auto");
@@ -194,7 +196,8 @@ public class DocumentStyleImpl {
public int getHeight(Element e) {
fixInlineElement(e);
- return (int) (e.getClientHeight() - num(curCSS(e, "paddingTop", true)) - num(curCSS(e, "paddingBottom", true)));
+ return (int) (e.getClientHeight() - num(curCSS(e, "paddingTop", true)) - num(curCSS(e,
+ "paddingBottom", true)));
}
public double getOpacity(Element e) {
@@ -204,11 +207,12 @@ public class DocumentStyleImpl {
public int getWidth(Element e) {
fixInlineElement(e);
- return (int) (e.getClientWidth() - num(curCSS(e, "paddingLeft", true)) - num(curCSS(e, "paddingRight", true)));
+ return (int) (e.getClientWidth() - num(curCSS(e, "paddingLeft", true)) - num(curCSS(e,
+ "paddingRight", true)));
}
/**
- * Return whether the element is visible
+ * Return whether the element is visible.
*/
public boolean isVisible(Element e) {
return SelectorEngine.filters.get("visible").f(e, 0);
@@ -253,8 +257,8 @@ public class DocumentStyleImpl {
protected native String getComputedStyle(Element elem, String hyphenName,
String camelName, String pseudo) /*-{
try {
- var cStyle = $doc.defaultView.getComputedStyle(elem, pseudo);
- return cStyle && cStyle.getPropertyValue ? cStyle.getPropertyValue(hyphenName) : null;
+ var cStyle = $doc.defaultView.getComputedStyle(elem, pseudo);
+ return cStyle && cStyle.getPropertyValue ? cStyle.getPropertyValue(hyphenName) : null;
} catch(e) {return null;}
}-*/;
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java
index 04074656..972e4645 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java
@@ -39,7 +39,8 @@ public class DocumentStyleImplIE extends DocumentStyleImpl {
@Override
public int getHeight(Element e) {
- return (int) (e.getOffsetHeight() - num(curCSS(e, "paddingTop", true)) - num(curCSS(e, "paddingBottom", true))
+ return (int) (e.getOffsetHeight() - num(curCSS(e, "paddingTop", true))
+ - num(curCSS(e, "paddingBottom", true))
- num(curCSS(e, "borderTopWidth", true)) - num(curCSS(e, "borderBottomWidth", true)));
}
@@ -55,7 +56,8 @@ public class DocumentStyleImplIE extends DocumentStyleImpl {
@Override
public int getWidth(Element e) {
- return (int) (e.getOffsetWidth() - num(curCSS(e, "paddingLeft", true)) - num(curCSS(e, "paddingRight", true))
+ return (int) (e.getOffsetWidth() - num(curCSS(e, "paddingLeft", true))
+ - num(curCSS(e, "paddingRight", true))
- num(curCSS(e, "borderRightWidth", true)) - num(curCSS(e, "borderRightWidth", true)));
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/HasSelector.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/HasSelector.java
index 8ca0a3b7..9e80cae2 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/HasSelector.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/HasSelector.java
@@ -19,6 +19,9 @@ import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
+/**
+ *
+ */
public interface HasSelector {
/**
@@ -29,5 +32,4 @@ public interface HasSelector {
* @return a list of matched nodes
*/
NodeList<Element> select(String selector, Node ctx);
-
}
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..c9bdef5a 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,16 +15,14 @@
*/
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;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
-import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.Predicate;
import com.google.gwt.query.client.js.JsMap;
import com.google.gwt.query.client.js.JsNodeArray;
@@ -32,6 +30,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.
*/
@@ -41,15 +41,15 @@ public class SelectorEngine implements HasSelector {
public static native NodeList<Element> getElementsByClassName(String clazz,
Node ctx) /*-{
- return ctx.getElementsByClassName(clazz);
+ return ctx.getElementsByClassName(clazz);
}-*/;
public static native Node getNextSibling(Node n) /*-{
- return n.nextSibling || null;
+ return n.nextSibling || null;
}-*/;
public static native Node getPreviousSibling(Node n) /*-{
- return n.previousSibling || null;
+ return n.previousSibling || null;
}-*/;
public NodeList<Element> querySelectorAll(String selector, Node ctx) {
@@ -65,17 +65,17 @@ public class SelectorEngine implements HasSelector {
public static native NodeList<Element> querySelectorAllImpl(String selector,
Node ctx) /*-{
- return ctx.querySelectorAll(selector);
+ return ctx.querySelectorAll(selector);
}-*/;
public static native NodeList<Element> elementsByTagName(String selector,
Node ctx) /*-{
- return ctx.getElementsByTagName(selector);
+ return ctx.getElementsByTagName(selector);
}-*/;
public static native NodeList<Element> elementsByClassName(String selector,
Node ctx) /*-{
- return ctx.getElementsByClassName(selector);
+ return ctx.getElementsByClassName(selector);
}-*/;
public static NodeList<Element> veryQuickId(String id, Node ctx) {
@@ -90,14 +90,14 @@ public class SelectorEngine implements HasSelector {
public static native NodeList<Element> xpathEvaluate(String selector,
Node ctx, JsNodeArray r) /*-{
- var node;
- var ownerDoc = ctx && (ctx.ownerDocument || ctx );
- var evalDoc = ownerDoc ? ownerDoc : $doc;
- var result = evalDoc.evaluate(selector, ctx, null, 0, null);
- while ((node = result.iterateNext())) {
- r.push(node);
- }
- return r;
+ var node;
+ var ownerDoc = ctx && (ctx.ownerDocument || ctx );
+ var evalDoc = ownerDoc ? ownerDoc : $doc;
+ var result = evalDoc.evaluate(selector, ctx, null, 0, null);
+ while ((node = result.iterateNext())) {
+ r.push(node);
+ }
+ return r;
}-*/;
public final SelectorEngineImpl impl;
@@ -117,10 +117,10 @@ public class SelectorEngine implements HasSelector {
static {
filters = JsMap.create();
- filters.put("visible", new Predicate(){
+ filters.put("visible", new Predicate() {
public boolean f(Element e, int index) {
return (e.getOffsetWidth() + e.getOffsetHeight()) > 0 &&
- !"none".equalsIgnoreCase(styleImpl.curCSS(e, "display", true));
+ !"none".equalsIgnoreCase(styleImpl.curCSS(e, "display", true));
}
});
filters.put("hidden", new Predicate() {
@@ -133,12 +133,12 @@ public class SelectorEngine implements HasSelector {
return e.getPropertyBoolean("selected");
}
});
- filters.put("input", new Predicate(){
+ filters.put("input", new Predicate() {
public boolean f(Element e, int index) {
return e.getNodeName().toLowerCase().matches("input|select|textarea|button");
}
});
- filters.put("header", new Predicate(){
+ filters.put("header", new Predicate() {
public boolean f(Element e, int index) {
return e.getNodeName().toLowerCase().matches("h\\d");
}
@@ -173,7 +173,7 @@ public class SelectorEngine implements HasSelector {
public NodeList<Element> filter(NodeList<Element> nodes, String selector, boolean filterDetached) {
JsNodeArray res = JsNodeArray.create();
- if (selector.isEmpty()){
+ if (selector.isEmpty()) {
return res;
}
Element ghostParent = null;
@@ -181,7 +181,8 @@ public class SelectorEngine implements HasSelector {
HashSet<Node> elmList = new HashSet<Node>();
for (int i = 0, l = nodes.getLength(); i < l; i++) {
Node e = nodes.getItem(i);
- if (e == window || e == document || e.getNodeName() == null || "html".equalsIgnoreCase(e.getNodeName())) {
+ if (e == window || e == document || e.getNodeName() == null
+ || "html".equalsIgnoreCase(e.getNodeName())) {
continue;
}
elmList.add(e);
@@ -198,11 +199,11 @@ public class SelectorEngine implements HasSelector {
parents.add(p);
}
} else if (parents.isEmpty()) {
- parents.add(document);
+ parents.add(document);
}
}
for (Node e : parents) {
- NodeList<Element> n = select(selector, e);
+ NodeList<Element> n = select(selector, e);
for (int i = 0, l = n.getLength(); i < l; i++) {
Element el = n.getItem(i);
if (elmList.remove(el)) {
@@ -217,9 +218,12 @@ public class SelectorEngine implements HasSelector {
}
// pseudo selectors which are computed by gquery in runtime
- RegExp gQueryPseudo = RegExp.compile("(.*):((visible|hidden|selected|input|header)|((button|checkbox|file|hidden|image|password|radio|reset|submit|text)\\s*(,|$)))(.*)", "i");
+ RegExp gQueryPseudo =
+ RegExp.compile(
+ "(.*):((visible|hidden|selected|input|header)|((button|checkbox|file|hidden|image|password|radio|reset|submit|text)\\s*(,|$)))(.*)", "i");
// pseudo selectors which work in engine
- RegExp nativePseudo = RegExp.compile("(.*):([\\w]+):(disabled|checked|enabled|empty|focus)\\s*([:,].*|$)", "i");
+ RegExp nativePseudo = RegExp.compile(
+ "(.*):([\\w]+):(disabled|checked|enabled|empty|focus)\\s*([:,].*|$)", "i");
public NodeList<Element> select(String selector, Node ctx) {
@@ -247,7 +251,7 @@ public class SelectorEngine implements HasSelector {
if (pred != null) {
nodes = filter(select(select, ctx), pred);
} else if (nativePseudo.test(pseudo)) {
- nodes = select(select, ctx);
+ nodes = select(select, ctx);
} else {
nodes = select(select + "[type=" + pseudo + "]", ctx);
}
@@ -280,7 +284,7 @@ public class SelectorEngine implements HasSelector {
}
/**
- * Check if the browser has native support for css selectors
+ * Check if the browser has native support for css selectors.
*/
public static native boolean hasQuerySelectorAll() /*-{
return $doc.location.href.indexOf("_force_no_native") < 0 &&
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..7a634c83 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().
@@ -42,14 +42,14 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
/**
* Interface for callbacks in replaceAll operations.
*/
- public static interface ReplaceCallback {
+ public interface ReplaceCallback {
String foundMatch(ArrayList<String> s);
}
/**
* Interface for replacer implementations (GWT and JVM).
*/
- public static interface Replacer {
+ public interface Replacer {
String replaceAll(String s, String expr, Object replacement);
}
@@ -58,20 +58,22 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
private static ReplaceCallback rc_scp = new ReplaceCallback() {
public String foundMatch(ArrayList<String> s) {
return s.get(1) + s.get(2) +
- (s.get(3).startsWith(" ") ? "%S%" : s.get(3).startsWith("#") ? "%H%" : "%P%") +
- s.get(4) + s.get(5);
+ (s.get(3).startsWith(" ") ? "%S%" : s.get(3).startsWith("#") ? "%H%" : "%P%") +
+ s.get(4) + s.get(5);
}
};
private static ReplaceCallback rc_$Attr = new ReplaceCallback() {
public String foundMatch(ArrayList<String> s) {
- return "[substring(@" + s.get(1) + ",string-length(@" + s.get(1) + ")-" + (s.get(2).replaceAll("'", "").length() - 1) + ")=" + s.get(2) + "]";
+ return "[substring(@" + s.get(1) + ",string-length(@" + s.get(1) + ")-"
+ + (s.get(2).replaceAll("'", "").length() - 1) + ")=" + s.get(2) + "]";
}
};
private static ReplaceCallback rc_Not = new ReplaceCallback() {
public String foundMatch(ArrayList<String> s) {
- return s.get(1) + "[not(" + getInstance().css2Xpath(s.get(2)).replaceAll("^[^\\[]+\\[([^\\]]*)\\].*$", "$1" + ")]");
+ return s.get(1) + "[not("
+ + getInstance().css2Xpath(s.get(2)).replaceAll("^[^\\[]+\\[([^\\]]*)\\].*$", "$1" + ")]");
}
};
@@ -82,7 +84,7 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
boolean afterAttr = "]".equals(s1);
String prefix = afterAttr ? s1 : "*";
- boolean noPrefix = afterAttr || s1 == null || s1.length() == 0 ;
+ boolean noPrefix = afterAttr || s1 == null || s1.length() == 0;
if ("n".equals(s2)) {
return s1;
@@ -95,85 +97,87 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
return prefix + "[(count(preceding-sibling::*) + 1) mod 2=1]";
}
- if (!s2.contains("n")){
- return prefix + "[position() = "+s2+"]" + (noPrefix ? "" : "/self::" + s1);
+ if (!s2.contains("n")) {
+ return prefix + "[position() = " + s2 + "]" + (noPrefix ? "" : "/self::" + s1);
}
String[] t = s2.replaceAll("^([0-9]*)n.*?([0-9]*)?$", "$1+$2").split("\\+");
String t0 = t[0];
String t1 = t.length > 1 ? t[1] : "0";
- return prefix + "[(position()-" + t1 + ") mod " + t0 + "=0 and position()>=" + t1 + "]" + (noPrefix ? "" : "/self::" + s1);
+ return prefix + "[(position()-" + t1 + ") mod " + t0 + "=0 and position()>=" + t1 + "]"
+ + (noPrefix ? "" : "/self::" + s1);
}
};
- public static Object[] regs = new Object[]{
- // scape some dots and spaces
- "(['\\[])([^'\\]]*)([\\s\\.#])([^'\\]]*)(['\\]])", rc_scp,
- // add @ for attrib
- "\\[([^@\\]~\\$\\*\\^\\|\\!]+)(=[^\\]]+)?\\]", "[@$1$2]",
- // multiple queries
- "\\s*,\\s*", "|.//",
- // , + ~ >
- "\\s*(\\+|~|>)\\s*", "$1",
- //* ~ + >
- "([\\w\\-\\*])~([\\w\\-\\*])", "$1/following-sibling::$2",
- "([\\w\\-\\*])\\+([\\w\\-\\*])", "$1/following-sibling::*[1]/self::$2",
- "([\\w\\-\\*])>([\\w\\-\\*])", "$1/$2",
- // all unescaped stuff escaped
- "\\[([^=]+)=([^'|\"][^\\]]*)\\]", "[$1='$2']",
- // all descendant or self to
- "(^|[^\\w\\-\\*])(#|\\.)([\\w\\-]+)", "$1*$2$3",
- "([\\>\\+\\|\\~\\,\\s])([a-zA-Z\\*]+)", "$1//$2",
- "\\s+//", "//",
- // :first-child
- "([\\w\\-\\*]+):first-child", "*[1]/self::$1",
- // :last-child
- "([\\w\\-\\*]+):last-child", "$1[not(following-sibling::*)]",
- // :only-child
- "([\\w\\-\\*]+):only-child", "*[last()=1]/self::$1",
- // :empty
- "([\\w\\-\\*]+):empty", "$1[not(*) and not(normalize-space())]",
- // :odd :even, this is intentional since sizzle behaves so
- ":odd" , ":nth-child(even)",
- ":even" , ":nth-child(odd)",
- // :not
- "(.+):not\\(([^\\)]*)\\)", rc_Not,
- // :nth-child
- "([a-zA-Z0-9\\_\\-\\*]*|\\]):nth-child\\(([^\\)]*)\\)", rc_nth_child,
- // :contains(selectors)
- ":contains\\(([^\\)]*)\\)", "[contains(string(.),'$1')]",
- // |= attrib
- "\\[([\\w\\-]+)\\|=([^\\]]+)\\]", "[@$1=$2 or starts-with(@$1,concat($2,'-'))]",
- // *= attrib
- "\\[([\\w\\-]+)\\*=([^\\]]+)\\]", "[contains(@$1,$2)]",
- // ~= attrib
- "\\[([\\w\\-]+)~=([^\\]]+)\\]", "[contains(concat(' ',normalize-space(@$1),' '),concat(' ',$2,' '))]",
- // ^= attrib
- "\\[([\\w\\-]+)\\^=([^\\]]+)\\]", "[starts-with(@$1,$2)]",
- // $= attrib
- "\\[([\\w\\-]+)\\$=([^\\]]+)\\]", rc_$Attr,
- // != attrib
- "\\[([\\w\\-]+)\\!=([^\\]]+)\\]", "[not(@$1) or @$1!=$2]",
- // ids and classes
- "#([\\w\\-]+)", "[@id='$1']",
- "\\.([\\w\\-]+)", "[contains(concat(' ',normalize-space(@class),' '),' $1 ')]",
- // normalize multiple filters
- "\\]\\[([^\\]]+)", " and ($1)",
- // tag:pseudo
- ":(enabled)", "[not(@disabled)]",
- ":(checked)", "[@$1='$1']",
- ":(disabled)", "[@$1]",
- ":(first)", "[1]",
- ":(last)", "[last()]",
- // put '*' when tag is omitted
- "(^|\\|[\\./]*)(\\[)", "$1*$2",
- // Replace escaped dots and spaces
- "%S%"," ",
- "%P%",".",
- "%H%","#",
- // Duplicated quotes
- "'+","'",
- };
+ public static Object[] regs = new Object[] {
+ // scape some dots and spaces
+ "(['\\[])([^'\\]]*)([\\s\\.#])([^'\\]]*)(['\\]])", rc_scp,
+ // add @ for attrib
+ "\\[([^@\\]~\\$\\*\\^\\|\\!]+)(=[^\\]]+)?\\]", "[@$1$2]",
+ // multiple queries
+ "\\s*,\\s*", "|.//",
+ // , + ~ >
+ "\\s*(\\+|~|>)\\s*", "$1",
+ // * ~ + >
+ "([\\w\\-\\*])~([\\w\\-\\*])", "$1/following-sibling::$2",
+ "([\\w\\-\\*])\\+([\\w\\-\\*])", "$1/following-sibling::*[1]/self::$2",
+ "([\\w\\-\\*])>([\\w\\-\\*])", "$1/$2",
+ // all unescaped stuff escaped
+ "\\[([^=]+)=([^'|\"][^\\]]*)\\]", "[$1='$2']",
+ // all descendant or self to
+ "(^|[^\\w\\-\\*])(#|\\.)([\\w\\-]+)", "$1*$2$3",
+ "([\\>\\+\\|\\~\\,\\s])([a-zA-Z\\*]+)", "$1//$2",
+ "\\s+//", "//",
+ // :first-child
+ "([\\w\\-\\*]+):first-child", "*[1]/self::$1",
+ // :last-child
+ "([\\w\\-\\*]+):last-child", "$1[not(following-sibling::*)]",
+ // :only-child
+ "([\\w\\-\\*]+):only-child", "*[last()=1]/self::$1",
+ // :empty
+ "([\\w\\-\\*]+):empty", "$1[not(*) and not(normalize-space())]",
+ // :odd :even, this is intentional since sizzle behaves so
+ ":odd", ":nth-child(even)",
+ ":even", ":nth-child(odd)",
+ // :not
+ "(.+):not\\(([^\\)]*)\\)", rc_Not,
+ // :nth-child
+ "([a-zA-Z0-9\\_\\-\\*]*|\\]):nth-child\\(([^\\)]*)\\)", rc_nth_child,
+ // :contains(selectors)
+ ":contains\\(([^\\)]*)\\)", "[contains(string(.),'$1')]",
+ // |= attrib
+ "\\[([\\w\\-]+)\\|=([^\\]]+)\\]", "[@$1=$2 or starts-with(@$1,concat($2,'-'))]",
+ // *= attrib
+ "\\[([\\w\\-]+)\\*=([^\\]]+)\\]", "[contains(@$1,$2)]",
+ // ~= attrib
+ "\\[([\\w\\-]+)~=([^\\]]+)\\]",
+ "[contains(concat(' ',normalize-space(@$1),' '),concat(' ',$2,' '))]",
+ // ^= attrib
+ "\\[([\\w\\-]+)\\^=([^\\]]+)\\]", "[starts-with(@$1,$2)]",
+ // $= attrib
+ "\\[([\\w\\-]+)\\$=([^\\]]+)\\]", rc_$Attr,
+ // != attrib
+ "\\[([\\w\\-]+)\\!=([^\\]]+)\\]", "[not(@$1) or @$1!=$2]",
+ // ids and classes
+ "#([\\w\\-]+)", "[@id='$1']",
+ "\\.([\\w\\-]+)", "[contains(concat(' ',normalize-space(@class),' '),' $1 ')]",
+ // normalize multiple filters
+ "\\]\\[([^\\]]+)", " and ($1)",
+ // tag:pseudo
+ ":(enabled)", "[not(@disabled)]",
+ ":(checked)", "[@$1='$1']",
+ ":(disabled)", "[@$1]",
+ ":(first)", "[1]",
+ ":(last)", "[last()]",
+ // put '*' when tag is omitted
+ "(^|\\|[\\./]*)(\\[)", "$1*$2",
+ // Replace escaped dots and spaces
+ "%S%", " ",
+ "%P%", ".",
+ "%H%", "#",
+ // Duplicated quotes
+ "'+", "'",
+ };
public static SelectorEngineCssToXPath getInstance() {
if (instance == null) {
@@ -254,7 +258,7 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
}
String xsel = cache.get(sel);
if (xsel == null) {
- xsel = sel.startsWith("./") || sel.startsWith("/") ? sel : css2Xpath(sel);
+ xsel = sel.startsWith("./") || sel.startsWith("/") ? sel : css2Xpath(sel);
cache.put(sel, xsel);
}
@@ -267,8 +271,8 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
if (!SelectorEngine.hasXpathEvaluate()) {
throw new RuntimeException("This Browser does not support Xpath selectors.", e);
}
- console.error("ERROR: xpathEvaluate invalid xpath expression:"
- + xsel + " css-selector:" + sel + " " + e.getMessage() + "\n");
+ console.error("ERROR: xpathEvaluate invalid xpath expression: "
+ + xsel + " css-selector: " + sel + " " + e.getMessage() + "\n");
}
return elm;
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineImpl.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineImpl.java
index a957334c..bc2a4587 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineImpl.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineImpl.java
@@ -19,5 +19,4 @@ package com.google.gwt.query.client.impl;
* Base/Utility class for runtime selector engine implementations.
*/
public abstract class SelectorEngineImpl implements HasSelector {
-
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNative.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNative.java
index c8058878..e00fa559 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNative.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNative.java
@@ -30,7 +30,8 @@ import com.google.gwt.query.client.js.JsNamedArray;
public class SelectorEngineNative extends SelectorEngineImpl {
// querySelectorAll unsupported selectors
- public static String NATIVE_EXCEPTIONS_REGEXP = "(^[\\./]/.*)|(.*(:contains|:first([^-]|$)|:last([^-]|$)|:even|:odd)).*";
+ public static String NATIVE_EXCEPTIONS_REGEXP =
+ "(^[\\./]/.*)|(.*(:contains|:first([^-]|$)|:last([^-]|$)|:even|:odd)).*";
private static HasSelector impl;
@@ -45,9 +46,9 @@ public class SelectorEngineNative extends SelectorEngineImpl {
public NodeList<Element> select(String selector, Node ctx) {
// querySelectorAllImpl does not support ids starting with a digit.
-// if (selector.matches("#[\\w\\-]+")) {
-// return SelectorEngine.veryQuickId(selector.substring(1), ctx);
-// } else
+ // if (selector.matches("#[\\w\\-]+")) {
+ // return SelectorEngine.veryQuickId(selector.substring(1), ctx);
+ // } else
if (selector.contains("!=")) {
if (cache == null) {
cache = JsNamedArray.create();
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..d31502bc 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
@@ -29,7 +29,8 @@ import com.google.gwt.dom.client.NodeList;
*/
public class SelectorEngineNativeIE8 extends SelectorEngineSizzleIE {
- public static String NATIVE_EXCEPTIONS_REGEXP = ".*(:contains|!=|:not|:nth-|:only-|:first|:last|:even|:odd).*";
+ public static String NATIVE_EXCEPTIONS_REGEXP =
+ ".*(:contains|!=|:not|:nth-|:only-|:first|:last|:even|:odd).*";
public NodeList<Element> select(String selector, Node ctx) {
if (!SelectorEngine.hasQuerySelector || selector.matches(NATIVE_EXCEPTIONS_REGEXP)) {
@@ -42,5 +43,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..2968a446 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
@@ -36,9 +36,9 @@ public class SelectorEngineNativeMin extends SelectorEngineImpl {
} catch (Exception e) {
console.error("GwtQuery: Selector '" + selector +
"' is unsupported in this SelectorEngineNativeMin engine."
- + " Do not use this syntax or configure your module to use a JS fallback. " + e.getMessage());
+ + " Do not use this syntax or configure your module to use a JS fallback. "
+ + e.getMessage());
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..dc7e09f6 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;
@@ -35,11 +34,11 @@ public class SelectorEngineNativeMinIE8 extends SelectorEngineImpl {
try {
return SelectorEngine.querySelectorAllImpl(selector, ctx);
} catch (Exception e) {
- console.error("GwtQuery: Selector '" + selector + "' is unsupported in this SelectorEngineNativeMinIE8 engine,"
+ console.error("GwtQuery: Selector '" + selector
+ + "' is unsupported in this SelectorEngineNativeMinIE8 engine,"
+ " check that you are in 'standards mode' or configure your module to use JS fallback. "
+ e.getMessage());
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..8b17d4fc 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
@@ -922,7 +922,7 @@ GQS.getText = function( elems ) {
div = null; // release memory in IE
})();
-//if ( document.querySelectorAll ) {
+// if ( document.querySelectorAll ) {
// (function(){
// var oldGQS = GQS, div = document.createElement("div");
// div.innerHTML = "<p class='TEST'></p>";
@@ -953,7 +953,7 @@ GQS.getText = function( elems ) {
//
// div = null; // release memory in IE
// })();
-//}
+// }
(function(){
var div = document.createElement("div");
@@ -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;
@@ -1089,9 +1088,7 @@ var posProcess = function(selector, context){
window.GQS = GQS;
$wnd.GQS = GQS;
-
})();
-
}-*/;
private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed) /*-{
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..0f4a387b 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;
@@ -929,9 +928,7 @@ var posProcess = function(selector, context){
window.IES = IES;
$wnd.IES = IES;
-
})();
-
}-*/;
private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed) /*-{
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineJS.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineJS.java
index 92da332d..deaa396b 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineJS.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineJS.java
@@ -90,21 +90,22 @@ public class SelectorEngineJS extends SelectorEngineImpl {
protected static Sequence getSequence(String expression) {
int start = 0, add = 2, max = -1, modVal = -1;
- JsRegexp expressionRegExp = new JsRegexp(
- "^((odd|even)|([1-9]\\d*)|((([1-9]\\d*)?)n((\\+|\\-)(\\d+))?)|(\\-(([1-9]\\d*)?)n\\+(\\d+)))$");
+ JsRegexp expressionRegExp =
+ new JsRegexp(
+ "^((odd|even)|([1-9]\\d*)|((([1-9]\\d*)?)n((\\+|\\-)(\\d+))?)|(\\-(([1-9]\\d*)?)n\\+(\\d+)))$");
JsObjectArray<String> pseudoValue = expressionRegExp.exec(expression);
if (!truth(pseudoValue)) {
return null;
} else {
- if (truth(pseudoValue.get(2))) { // odd or even
+ if (truth(pseudoValue.get(2))) { // odd or even
start = (eq(pseudoValue.get(2), "odd")) ? 1 : 2;
modVal = (start == 1) ? 1 : 0;
} else if (JsUtils
- .truth(pseudoValue.get(3))) { // single digit
+ .truth(pseudoValue.get(3))) { // single digit
start = Integer.parseInt(pseudoValue.get(3), 10);
add = 0;
max = start;
- } else if (truth(pseudoValue.get(4))) { // an+b
+ } else if (truth(pseudoValue.get(4))) { // an+b
add = truth(pseudoValue.get(6)) ? Integer
.parseInt(pseudoValue.get(6), 10) : 1;
start = truth(pseudoValue.get(7)) ? Integer.parseInt(
@@ -115,7 +116,7 @@ public class SelectorEngineJS extends SelectorEngineImpl {
}
modVal = (start > add) ? (start - add) % add
: ((start == add) ? 0 : start);
- } else if (truth(pseudoValue.get(10))) { // -an+b
+ } else if (truth(pseudoValue.get(10))) { // -an+b
add = truth(pseudoValue.get(12)) ? Integer
.parseInt(pseudoValue.get(12), 10) : 1;
start = max = Integer.parseInt(pseudoValue.get(13), 10);
@@ -145,7 +146,7 @@ public class SelectorEngineJS extends SelectorEngineImpl {
public static native NodeList<Element> getElementsByClassName(String clazz,
Node ctx) /*-{
- return ctx.getElementsByClassName(clazz);
+ return ctx.getElementsByClassName(clazz);
}-*/;
public static native boolean isAdded(Node prevRef) /*-{
@@ -213,9 +214,8 @@ public class SelectorEngineJS extends SelectorEngineImpl {
private static void getGeneralSiblingNodes(JsNodeArray matchingElms,
JsObjectArray<String> nextTag, JsRegexp nextRegExp, Node prevRef) {
- while (
- JsUtils.truth((prevRef = SelectorEngine.getNextSibling(prevRef)))
- && !isAdded(prevRef)) {
+ while (JsUtils.truth((prevRef = SelectorEngine.getNextSibling(prevRef)))
+ && !isAdded(prevRef)) {
if (!JsUtils.truth(nextTag) || nextRegExp
.test(prevRef.getNodeName())) {
setAdded(prevRef, true);
@@ -226,9 +226,8 @@ public class SelectorEngineJS extends SelectorEngineImpl {
private static void getSiblingNodes(JsNodeArray matchingElms, JsObjectArray<String> nextTag,
JsRegexp nextRegExp, Node prevRef) {
- while (
- JsUtils.truth(prevRef = SelectorEngine.getNextSibling(prevRef))
- && prevRef.getNodeType() != Node.ELEMENT_NODE) {
+ while (JsUtils.truth(prevRef = SelectorEngine.getNextSibling(prevRef))
+ && prevRef.getNodeType() != Node.ELEMENT_NODE) {
}
if (JsUtils.truth(prevRef)) {
if (!JsUtils.truth(nextTag) || nextRegExp
@@ -252,20 +251,20 @@ public class SelectorEngineJS extends SelectorEngineImpl {
private static native JsNodeArray subtractArray(JsNodeArray previousMatch,
JsNodeArray elementsByPseudo) /*-{
- for (var i=0, src1; (src1=arr1[i]); i++) {
- var found = false;
- for (var j=0, src2; (src2=arr2[j]); j++) {
- if (src2 === src1) {
- found = true;
- break;
- }
- }
- if (found) {
- arr1.splice(i--, 1);
- }
+ for (var i=0, src1; (src1=arr1[i]); i++) {
+ var found = false;
+ for (var j=0, src2; (src2=arr2[j]); j++) {
+ if (src2 === src1) {
+ found = true;
+ break;
}
- return arr;
- }-*/;
+ }
+ if (found) {
+ arr1.splice(i--, 1);
+ }
+ }
+ return arr;
+ }-*/;
private JsRegexp cssSelectorRegExp;
@@ -276,8 +275,9 @@ public class SelectorEngineJS extends SelectorEngineImpl {
public SelectorEngineJS() {
selectorSplitRegExp = new JsRegexp("[^\\s]+", "g");
childOrSiblingRefRegExp = new JsRegexp("^(>|\\+|~)$");
- cssSelectorRegExp = new JsRegexp(
- "^(\\w+)?(#[\\w\\u00C0-\\uFFFF\\-\\_]+|(\\*))?((\\.[\\w\\u00C0-\\uFFFF\\-_]+)*)?((\\[\\w+(\\^|\\$|\\*|\\||~)?(=[\"']*[\\w\\u00C0-\\uFFFF\\s\\-\\_\\.]+[\"']*)?\\]+)*)?(((:\\w+[\\w\\-]*)(\\((odd|even|\\-?\\d*n?((\\+|\\-)\\d+)?|[\\w\\u00C0-\\uFFFF\\-_]+|((\\w*\\.[\\w\\u00C0-\\uFFFF\\-_]+)*)?|(\\[#?\\w+(\\^|\\$|\\*|\\||~)?=?[\\w\\u00C0-\\uFFFF\\s\\-\\_\\.]+\\]+)|(:\\w+[\\w\\-]*))\\))?)*)?");
+ cssSelectorRegExp =
+ new JsRegexp(
+ "^(\\w+)?(#[\\w\\u00C0-\\uFFFF\\-\\_]+|(\\*))?((\\.[\\w\\u00C0-\\uFFFF\\-_]+)*)?((\\[\\w+(\\^|\\$|\\*|\\||~)?(=[\"']*[\\w\\u00C0-\\uFFFF\\s\\-\\_\\.]+[\"']*)?\\]+)*)?(((:\\w+[\\w\\-]*)(\\((odd|even|\\-?\\d*n?((\\+|\\-)\\d+)?|[\\w\\u00C0-\\uFFFF\\-_]+|((\\w*\\.[\\w\\u00C0-\\uFFFF\\-_]+)*)?|(\\[#?\\w+(\\^|\\$|\\*|\\||~)?=?[\\w\\u00C0-\\uFFFF\\s\\-\\_\\.]+\\]+)|(:\\w+[\\w\\-]*))\\))?)*)?");
}
public NodeList<Element> select(String sel, Node ctx) {
@@ -359,8 +359,7 @@ public class SelectorEngineJS extends SelectorEngineImpl {
for (int l = 0, ll = prevElem.size(); l < ll; l++) {
tagCollectionMatches = getElementsByTagName(splitRule.tag,
prevElem.getNode(l));
- for (int m = 0, mlen = tagCollectionMatches.getLength(); m < mlen;
- m++) {
+ for (int m = 0, mlen = tagCollectionMatches.getLength(); m < mlen; m++) {
Node tagMatch = tagCollectionMatches.getItem(m);
if (!isAdded(tagMatch)) {
@@ -430,8 +429,7 @@ public class SelectorEngineJS extends SelectorEngineImpl {
for (int r = 0, rlen = matchingElms.size(); r < rlen; r++) {
Element current = matchingElms.getElement(r);
boolean addElm = false;
- for (int s = 0, sl = regExpAttributes.length;
- s < sl; s++) {
+ for (int s = 0, sl = regExpAttributes.length; s < sl; s++) {
addElm = false;
JsRegexp attributeRegexp = regExpAttributes[s];
String currentAttr = getAttr(current, regExpAttributesStr[s]);
@@ -476,7 +474,7 @@ public class SelectorEngineJS extends SelectorEngineImpl {
elm.pushAll(prevElem);
}
- return JsUtils.unique(elm.<JsArray<Element>>cast()).cast();
+ return JsUtils.unique(elm.<JsArray<Element>> cast()).cast();
}
protected String getAttr(Element current, String name) {
@@ -600,9 +598,8 @@ public class SelectorEngineJS extends SelectorEngineImpl {
&& next.getNodeType() != Node.ELEMENT_NODE) {
}
} else {
- while (
- JsUtils.truth((next = SelectorEngine.getNextSibling(next)))
- && next.getNodeType() != Node.ELEMENT_NODE) {
+ while (JsUtils.truth((next = SelectorEngine.getNextSibling(next)))
+ && next.getNodeType() != Node.ELEMENT_NODE) {
}
}
if (!JsUtils.truth(next)) {
@@ -619,9 +616,8 @@ public class SelectorEngineJS extends SelectorEngineImpl {
next = previous = previousMatch.getNode(n);
if (previousDir) {
- while (
- JsUtils.truth(next = SelectorEngine.getPreviousSibling(next))
- && !JsUtils
+ while (JsUtils.truth(next = SelectorEngine.getPreviousSibling(next))
+ && !JsUtils
.eq(next.getNodeName(), previous.getNodeName())) {
}
} else {
@@ -652,7 +648,7 @@ public class SelectorEngineJS extends SelectorEngineImpl {
.exec(pseudoValue);
JsRegexp notRegExp = new JsRegexp("(^|\\s)"
+ (JsUtils.truth(notTag) ? notTag.get(1)
- : JsUtils.truth(notClass) ? notClass.get(1) : "")
+ : JsUtils.truth(notClass) ? notClass.get(1) : "")
+ "(\\s|$)", "i");
if (JsUtils.truth(notAttr)) {
String notAttribute = JsUtils.truth(notAttr.get(3)) ? notAttr
@@ -768,9 +764,8 @@ public class SelectorEngineJS extends SelectorEngineImpl {
prev = next = previous = previousMatch.getNode(k);
Node prevParent = previous.getParentNode();
if (prevParent != kParent) {
- while (
- JsUtils.truth(prev = SelectorEngine.getPreviousSibling(prev))
- && prev.getNodeType() != Node.ELEMENT_NODE) {
+ while (JsUtils.truth(prev = SelectorEngine.getPreviousSibling(prev))
+ && prev.getNodeType() != Node.ELEMENT_NODE) {
}
while (JsUtils.truth(next = SelectorEngine.getNextSibling(next))
&& next.getNodeType() != Node.ELEMENT_NODE) {
@@ -793,9 +788,8 @@ public class SelectorEngineJS extends SelectorEngineImpl {
prev = next = previous = previousMatch.getNode(o);
Node prevParent = previous.getParentNode();
if (prevParent != oParent) {
- while (
- JsUtils.truth(prev = SelectorEngine.getPreviousSibling(prev))
- && !JsUtils
+ while (JsUtils.truth(prev = SelectorEngine.getPreviousSibling(prev))
+ && !JsUtils
.eq(prev.getNodeName(), previous.getNodeName())) {
}
while (JsUtils.truth(next = SelectorEngine.getNextSibling(next))
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineSizzleGwt.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineSizzleGwt.java
index c536c3c8..7bbf1031 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineSizzleGwt.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineSizzleGwt.java
@@ -28,7 +28,7 @@ import com.google.gwt.query.client.js.JsUtils;
* Sizzle CSS Selector Engine v1.0.
*
* It has so many JSNI code, the idea is to make an entire implementation
- * using Java. Right now it performs worse than pure JSNI implementation
+ * using Java. Right now it performs worse than pure JSNI implementation.
*
*/
public class SelectorEngineSizzleGwt extends SelectorEngineImpl {
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineXPath.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineXPath.java
index 47322d6c..73e58740 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineXPath.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/research/SelectorEngineXPath.java
@@ -146,13 +146,14 @@ public class SelectorEngineXPath extends SelectorEngineImpl {
}
SelectorEngine.xpathEvaluate(xPathExpression, ctx, elm);
}
- return JsUtils.unique(elm.<JsArray<Element>>cast()).cast();
+ return JsUtils.unique(elm.<JsArray<Element>> cast()).cast();
}
private void init() {
if (cssSelectorRegExp == null) {
- cssSelectorRegExp = new JsRegexp(
- "^(\\w+)?(#[\\w\\u00C0-\\uFFFF\\-\\_]+|(\\*))?((\\.[\\w\\u00C0-\\uFFFF\\-_]+)*)?((\\[\\w+(\\^|\\$|\\*|\\||~)?(=[\"']*[\\w\\u00C0-\\uFFFF\\s\\-\\_\\.]+[\"']*)?\\]+)*)?(((:\\w+[\\w\\-]*)(\\((odd|even|\\-?\\d*n?((\\+|\\-)\\d+)?|[\\w\\u00C0-\\uFFFF\\-_]+|((\\w*\\.[\\w\\u00C0-\\uFFFF\\-_]+)*)?|(\\[#?\\w+(\\^|\\$|\\*|\\||~)?=?[\\w\\u00C0-\\uFFFF\\s\\-\\_\\.]+\\]+)|(:\\w+[\\w\\-]*))\\))?)*)?(>|\\+|~)?");
+ cssSelectorRegExp =
+ new JsRegexp(
+ "^(\\w+)?(#[\\w\\u00C0-\\uFFFF\\-\\_]+|(\\*))?((\\.[\\w\\u00C0-\\uFFFF\\-_]+)*)?((\\[\\w+(\\^|\\$|\\*|\\||~)?(=[\"']*[\\w\\u00C0-\\uFFFF\\s\\-\\_\\.]+[\"']*)?\\]+)*)?(((:\\w+[\\w\\-]*)(\\((odd|even|\\-?\\d*n?((\\+|\\-)\\d+)?|[\\w\\u00C0-\\uFFFF\\-_]+|((\\w*\\.[\\w\\u00C0-\\uFFFF\\-_]+)*)?|(\\[#?\\w+(\\^|\\$|\\*|\\||~)?=?[\\w\\u00C0-\\uFFFF\\s\\-\\_\\.]+\\]+)|(:\\w+[\\w\\-]*))\\))?)*)?(>|\\+|~)?");
selectorSplitRegExp = new JsRegexp("[^\\s]+", "g");
combinator = new JsRegexp("(>|\\+|~)");
}
@@ -184,9 +185,9 @@ public class SelectorEngineXPath extends SelectorEngineImpl {
xpath = "(count(preceding-sibling::*) + 1) mod " + sequence.add
+ " = " + sequence.modVal
+ ((sequence.start > 1) ? " and count(preceding-sibling::*) >= "
- + (sequence.start - 1) : "") + ((sequence.max > 0) ?
- " and count(preceding-sibling::*) <= " + (sequence.max - 1)
- : "");
+ + (sequence.start - 1) : "") + ((sequence.max > 0) ?
+ " and count(preceding-sibling::*) <= " + (sequence.max - 1)
+ : "");
}
}
}
@@ -199,8 +200,8 @@ public class SelectorEngineXPath extends SelectorEngineImpl {
} else {
xpath = "position() mod " + sequence.add + " = " + sequence.modVal
+ ((sequence.start > 1) ? " and position() >= " + sequence.start
- : "") + ((sequence.max > 0) ? " and position() <= "
- + sequence.max : "");
+ : "") + ((sequence.max > 0) ? " and position() <= "
+ + sequence.max : "");
}
}
}
@@ -240,7 +241,6 @@ public class SelectorEngineXPath extends SelectorEngineImpl {
function(a,b,c,d) {
return @com.google.gwt.query.client.impl.research.SelectorEngineXPath::attrToXPath(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)(a,b || "",c || "",d || "");
});
-
}-*/;
private native String replaceAttr2(String allAttr) /*-{
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java
index dff21481..13f6c4a3 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java
@@ -20,9 +20,9 @@ import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArrayMixed;
import com.google.gwt.core.client.JsArrayString;
- /**
- * A Lightweight JSO class to store data.
- */
+/**
+ * A Lightweight JSO class to store data.
+ */
public class JsCache extends JavaScriptObject {
protected JsCache() {
@@ -69,19 +69,24 @@ public class JsCache extends JavaScriptObject {
Object o = get(id);
if (o != null && clz != null) {
if (o instanceof Double) {
- Double d = (Double)o;
- if (clz == Float.class) o = d.floatValue();
- else if (clz == Integer.class) o = d.intValue();
- else if (clz == Long.class) o = d.longValue();
- else if (clz == Short.class) o = d.shortValue();
- else if (clz == Byte.class) o = d.byteValue();
+ Double d = (Double) o;
+ if (clz == Float.class)
+ o = d.floatValue();
+ else if (clz == Integer.class)
+ o = d.intValue();
+ else if (clz == Long.class)
+ o = d.longValue();
+ else if (clz == Short.class)
+ o = d.shortValue();
+ else if (clz == Byte.class)
+ o = d.byteValue();
} else if (clz == Boolean.class && !(o instanceof Boolean)) {
o = Boolean.valueOf(String.valueOf(o));
} else if (clz == String.class && !(o instanceof String)) {
o = String.valueOf(o);
}
}
- return (T)o;
+ return (T) o;
}
public final native <T> T get(Object id) /*-{
@@ -89,7 +94,7 @@ public class JsCache extends JavaScriptObject {
}-*/;
public final JsCache getCache(int id) {
- return (JsCache)get(id);
+ return (JsCache) get(id);
}
public final boolean getBoolean(Object id) {
@@ -126,7 +131,7 @@ public class JsCache extends JavaScriptObject {
public final <T extends JavaScriptObject> T getJavaScriptObject(Object name) {
Object o = get(name);
- return (o != null && o instanceof JavaScriptObject) ? ((JavaScriptObject)o).<T>cast() : null;
+ return (o != null && o instanceof JavaScriptObject) ? ((JavaScriptObject) o).<T> cast() : null;
}
public final native boolean isEmpty() /*-{
@@ -134,7 +139,7 @@ public class JsCache extends JavaScriptObject {
return true;
}-*/;
- public final native boolean contains(Object o)/*-{
+ public final native boolean contains(Object o) /*-{
return this.indexOf(o) >= 0;
}-*/;
@@ -158,11 +163,11 @@ public class JsCache extends JavaScriptObject {
return this;
}-*/;
- public final JsCache put(Object id, Object obj) {
+ public final JsCache put(Object id, Object obj) {
if (obj instanceof Boolean) {
- putBoolean(id, ((Boolean)obj).booleanValue());
+ putBoolean(id, ((Boolean) obj).booleanValue());
} else if (obj instanceof Number) {
- putNumber(id, ((Number)obj).doubleValue());
+ putNumber(id, ((Number) obj).doubleValue());
} else {
putObject(id, obj);
}
@@ -203,7 +208,7 @@ public class JsCache extends JavaScriptObject {
JsArrayString a = keysImpl();
String[] ret = new String[a.length()];
for (int i = 0; i < a.length(); i++) {
- ret[i] = a.get(i);
+ ret[i] = a.get(i);
}
return ret;
}
@@ -211,8 +216,8 @@ public class JsCache extends JavaScriptObject {
public final Object[] elements() {
String[] keys = keys();
Object[] ret = new Object[keys.length];
- int i=0;
- for (String s: keys) {
+ int i = 0;
+ for (String s : keys) {
ret[i++] = get(s);
}
return ret;
@@ -220,7 +225,7 @@ public class JsCache extends JavaScriptObject {
public final String tostring() {
String ret = getClass().getName() + "{ ";
- for (String k: keys()){
+ for (String k : keys()) {
ret += k + "=" + get(k) + " ";
}
return ret + "}";
@@ -231,7 +236,7 @@ public class JsCache extends JavaScriptObject {
checkNull(this);
}
- private final native JsArrayString keysImpl() /*-{
+ private native JsArrayString keysImpl() /*-{
var key, keys=[];
// Chrome in DevMode sets '__gwt_ObjectId' to JS objects
// GWT sets '$H' when calling getHashCode (see com/google/gwt/core/client/impl/Impl.java)
@@ -240,7 +245,7 @@ public class JsCache extends JavaScriptObject {
}-*/;
/**
- * Throw a NPE when a js is null
+ * Throw a NPE when a js is null.
*/
public static final <T extends JavaScriptObject> T checkNull(T js) {
if (!GWT.isProdMode() && js == null) {
@@ -251,7 +256,7 @@ public class JsCache extends JavaScriptObject {
/**
* Gets an object wrapped in a js array and boxes it with the appropriate
- * Object in the GWT world.
+ * object in the GWT world.
*
* It is thought to be called from other jsni code without dealing with casting issues.
*
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsMap.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsMap.java
index 4806d4cd..010b7a69 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsMap.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsMap.java
@@ -19,8 +19,11 @@ import com.google.gwt.core.client.JavaScriptObject;
/**
* Lightweight JSO backed implemented of a Map, using Object.hashCode() as key.
+ *
+ * @param <S>
+ * @param <T>
*/
-final public class JsMap<S, T> extends JavaScriptObject {
+public final class JsMap<S, T> extends JavaScriptObject {
protected JsMap() {
}
@@ -31,7 +34,7 @@ final public class JsMap<S, T> extends JavaScriptObject {
@SuppressWarnings("unchecked")
public T get(int hashCode) {
- return (T)c().get(hashCode);
+ return (T) c().get(hashCode);
}
public T get(S key) {
@@ -42,19 +45,19 @@ final public class JsMap<S, T> extends JavaScriptObject {
c().put(key.hashCode(), val);
}
- public T remove(S key){
+ public T remove(S key) {
T old = get(key);
c().delete(key.hashCode());
return old;
}
- public T remove(int key){
+ public T remove(int key) {
T old = get(key);
c().delete(key);
return old;
}
- public final String[] keys() {
+ public String[] keys() {
return c().keys();
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsNamedArray.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsNamedArray.java
index a3b49332..5a1b7820 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsNamedArray.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsNamedArray.java
@@ -18,9 +18,11 @@ package com.google.gwt.query.client.js;
import com.google.gwt.core.client.JavaScriptObject;
/**
- * Lightweight JSO backed implemented of a named array
+ * Lightweight JSO backed implemented of a named array.
+ *
+ * @param <T>
*/
-final public class JsNamedArray<T> extends JavaScriptObject {
+public final class JsNamedArray<T> extends JavaScriptObject {
protected JsNamedArray() {
}
@@ -31,14 +33,14 @@ final public class JsNamedArray<T> extends JavaScriptObject {
@SuppressWarnings("unchecked")
public T get(String key) {
- return (T)c().get(key);
+ return (T) c().get(key);
}
public void put(String key, T val) {
c().put(key, val);
}
- public final String[] keys() {
+ public String[] keys() {
return c().keys();
}
@@ -46,19 +48,19 @@ final public class JsNamedArray<T> extends JavaScriptObject {
return c().length();
}
- public final Object[] values() {
+ public Object[] values() {
return c().elements();
}
- public final boolean exists(String key){
+ public boolean exists(String key) {
return c().exists(key);
}
- public final void delete(String key){
+ public void delete(String key) {
c().delete(key);
}
- public final static <T> JsNamedArray<T> create() {
+ public static <T> JsNamedArray<T> create() {
return createObject().cast();
}
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsNodeArray.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsNodeArray.java
index 8b989a50..da8ccf05 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsNodeArray.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsNodeArray.java
@@ -26,7 +26,7 @@ import com.google.gwt.dom.client.NodeList;
public class JsNodeArray extends NodeList<Element> {
public static JsNodeArray create() {
- return create((Node)null);
+ return create((Node) null);
}
public static native JsNodeArray create(Node node) /*-{
@@ -34,15 +34,15 @@ public class JsNodeArray extends NodeList<Element> {
}-*/;
public static JsNodeArray create(NodeList<?> nl) {
- JsNodeArray ret = create((Node)null);
+ JsNodeArray ret = create((Node) null);
ret.pushAll(nl);
return ret;
}
- protected JsNodeArray(){
+ protected JsNodeArray() {
}
- public final void addNode(Node n){
+ public final void addNode(Node n) {
c().add(n);
}
@@ -80,7 +80,7 @@ public class JsNodeArray extends NodeList<Element> {
public final Element[] elements() {
Element[] ret = new Element[size()];
- for (int i=0 ; i<size(); i++) {
+ for (int i = 0; i < size(); i++) {
ret[i] = getElement(i);
}
return ret;
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..3a1b5ee8 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
@@ -19,6 +19,8 @@ import com.google.gwt.core.client.JavaScriptObject;
/**
* Lightweight JSO based array class that can store objects.
+ *
+ * @param <T>
*/
public final class JsObjectArray<T> extends JavaScriptObject {
@@ -33,12 +35,12 @@ public final class JsObjectArray<T> extends JavaScriptObject {
return cast();
}
- public JsObjectArray<T> add(T...vals) {
- for (T t: vals) {
+ public JsObjectArray<T> add(T... vals) {
+ for (T t : vals) {
if (t instanceof Number) {
- c().putNumber(length(), (((Number)t).doubleValue()));
+ c().putNumber(length(), (((Number) t).doubleValue()));
} else if (t instanceof Boolean) {
- c().putBoolean(length(), ((Boolean)t).booleanValue());
+ c().putBoolean(length(), ((Boolean) t).booleanValue());
} else {
c().put(length(), t);
}
@@ -53,7 +55,7 @@ public final class JsObjectArray<T> extends JavaScriptObject {
@SuppressWarnings("unchecked")
public T get(int index) {
- return (T)c().get(index);
+ return (T) c().get(index);
}
public int length() {
@@ -85,5 +87,4 @@ public final class JsObjectArray<T> extends JavaScriptObject {
public Object[] elements() {
return c().elements();
}
-
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsRegexp.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsRegexp.java
index b4018cf8..bdf767a9 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsRegexp.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsRegexp.java
@@ -70,7 +70,7 @@ public class JsRegexp {
return test0(regexp, rule);
}
- private native JsObjectArray<String> match0(JavaScriptObject regexp, String currentRule)/*-{
+ private native JsObjectArray<String> match0(JavaScriptObject regexp, String currentRule) /*-{
return currentRule.match(regexp);
}-*/;
@@ -78,7 +78,7 @@ public class JsRegexp {
return regexp.test(rule);
}-*/;
- public String getPattern(){
+ public String getPattern() {
return regexp.toString();
};
}
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..13520fe4 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;
@@ -40,6 +39,7 @@ public class JsUtils {
*/
public static class JsFunction extends Function implements Command {
private JavaScriptObject jso = null;
+
public JsFunction(JavaScriptObject f) {
if (JsUtils.isFunction(f)) {
jso = f;
@@ -50,6 +50,10 @@ public class JsUtils {
return jso.equals(obj);
}
+ public int hashCode() {
+ return jso.hashCode();
+ }
+
private native Object exec(JavaScriptObject f, Object data) /*-{
return @com.google.gwt.query.client.js.JsCache::gwtBox(*)([ f(data) ]);
}-*/;
@@ -69,7 +73,7 @@ public class JsUtils {
* Wraps a GQuery function into a native javascript one so as we can
* export Java methods without using JSNI.
*/
- public static native JavaScriptObject wrapFunction (Function f) /*-{
+ public static native JavaScriptObject wrapFunction(Function f) /*-{
return function(r) {
var o = @java.util.ArrayList::new()();
for (i in arguments) {
@@ -82,6 +86,9 @@ public class JsUtils {
}
}-*/;
+ /**
+ * Default JsUtils implementation.
+ */
public static class JsUtilsImpl {
public native Properties parseJSON(String json) /*-{
return $wnd.JSON.parse(json);
@@ -118,6 +125,9 @@ public class JsUtils {
}-*/;
}
+ /**
+ * IE JsUtils implemetation.
+ */
public static class JsUtilsImplIE6 extends JsUtilsImpl {
public static final native Properties evalImpl(String properties) /*-{
return eval(properties);
@@ -137,13 +147,13 @@ public class JsUtils {
// @see https://github.com/douglascrockford/JSON-js/blob/master/json2.js
Properties prop = js.cast();
String ret = "";
- for (String k : prop.keys()){
+ for (String k : prop.keys()) {
String ky = k.matches("\\d+") ? k : "\"" + k + "\"";
JsCache o = prop.getArray(k).cast();
if (o != null) {
ret += ky + ":[";
- for (int i = 0, l = o.length(); i < l ; i++) {
- Properties p = o.<JsCache>cast().getJavaScriptObject(i);
+ for (int i = 0, l = o.length(); i < l; i++) {
+ Properties p = o.<JsCache> cast().getJavaScriptObject(i);
if (p != null) {
ret += p.toJsonString() + ",";
} else {
@@ -160,9 +170,9 @@ public class JsUtils {
}
}
}
- return "{" + ret.replaceAll(",\\s*([\\]}]|$)","$1")
- .replaceAll("([:,\\[])\"(-?[\\d\\.]+|null|false|true)\"", "$1$2")
- + "}";
+ return "{" + ret.replaceAll(",\\s*([\\]}]|$)", "$1")
+ .replaceAll("([:,\\[])\"(-?[\\d\\.]+|null|false|true)\"", "$1$2")
+ + "}";
}
@Override
@@ -202,29 +212,30 @@ public class JsUtils {
* Returns a property present in a javascript object.
*/
public static <T> T prop(JavaScriptObject o, Object id, Class<? extends T> type) {
- return o == null ? null : o.<JsCache>cast().get(id, type);
+ return o == null ? null : o.<JsCache> cast().get(id, type);
}
/**
* Returns a property present in a javascript object.
*/
public static <T> T prop(JavaScriptObject o, Object id) {
- return o == null ? null : o.<JsCache>cast().<T>get(id);
+ return o == null ? null : o.<JsCache> cast().<T> get(id);
}
/**
- * Set a property to a javascript object
+ * Set a property to a javascript object.
*/
public static void prop(JavaScriptObject o, Object id, Object val) {
if (o != null) {
- o.<JsCache>cast().put(id, val);
+ o.<JsCache> cast().put(id, val);
}
}
/**
- * Camelize style property names. for instance: font-name -> fontName
+ * Camelize style property names.
+ * for instance: font-name -> fontName
*/
- public static native String camelize(String s)/*-{
+ public static native String camelize(String s) /*-{
return s.replace(/\-(\w)/g, function(all, letter) {
return letter.toUpperCase();
});
@@ -257,7 +268,8 @@ public class JsUtils {
}
/**
- * Use the method in the gquery class $(elem).cur(prop, force);
+ * Use the method in the gquery class.
+ * $(elem).cur(prop, force);
*/
@Deprecated
public static double cur(Element elem, String prop, boolean force) {
@@ -290,28 +302,29 @@ public class JsUtils {
* Check if an object has already a property with name <code>name</code>
* defined.
*/
- public static native boolean hasProperty(JavaScriptObject o, String name)/*-{
+ public static native boolean hasProperty(JavaScriptObject o, String name) /*-{
return o && name in o;
}-*/;
/**
* Check whether an element has an attribute, this is here since GWT Element.getAttribute
* implementation returns an empty string instead of null when the attribute is not
- * present
+ * present.
*/
- public static native boolean hasAttribute(Element o, String name)/*-{
+ public static native boolean hasAttribute(Element o, String name) /*-{
return !!(o && o.getAttribute(name));
}-*/;
/**
- * Hyphenize style property names. for instance: fontName -> font-name
+ * Hyphenize style property names.
+ * for instance: fontName -> font-name
*/
public static native String hyphenize(String name) /*-{
return name.replace(/([A-Z])/g, "-$1").toLowerCase();
}-*/;
/**
- * Check is a javascript object can be used as an array
+ * Check is a javascript object can be used as an array.
*/
public static native boolean isArray(JavaScriptObject o) /*-{
return Object.prototype.toString.call(o) == '[object Array]'
@@ -319,28 +332,29 @@ public class JsUtils {
}-*/;
/**
- * Check is a javascript object is a FormData
+ * Check is a javascript object is a FormData.
*/
public static native boolean isFormData(JavaScriptObject o) /*-{
return Object.prototype.toString.call(o) == '[object FormData]';
}-*/;
/**
- * Return whether the event was prevented
+ * Return whether the event was prevented.
*/
- public static native boolean isDefaultPrevented(JavaScriptObject e)/*-{
+ public static native boolean isDefaultPrevented(JavaScriptObject e) /*-{
return e.defaultPrevented || e.returnValue === false || e.getPreventDefault
&& e.getPreventDefault() ? true : false;
}-*/;
/**
- * Return whether a node is detached to the dom
+ * Return whether a node is detached to the DOM.
+ *
* Be careful : This method works only on node that should be inserted within the body node.
*/
public static boolean isDetached(Node n) {
assert n != null;
- if ("html".equalsIgnoreCase(n.getNodeName())){
+ if ("html".equalsIgnoreCase(n.getNodeName())) {
return false;
}
@@ -348,28 +362,28 @@ public class JsUtils {
}
/**
- * Check is a javascript object can be cast to an Element
+ * 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;
}-*/;
/**
- * Check is a javascript object can be cast to an Event
+ * Check is a javascript object can be cast to an Event.
*/
public static boolean isEvent(JavaScriptObject o) {
return hasProperty(o, "currentTarget");
}
/**
- * Check is a javascript object is a function
+ * Check is a javascript object is a function.
*/
public static native boolean isFunction(JavaScriptObject o) /*-{
return Object.prototype.toString.call(o) == '[object Function]';
}-*/;
/**
- * Check is a javascript can be cast to a node list
+ * Check is a javascript can be cast to a node list.
*/
public static native boolean isNodeList(JavaScriptObject o) /*-{
var r = Object.prototype.toString.call(o);
@@ -378,14 +392,14 @@ public class JsUtils {
}-*/;
/**
- * Check is a javascript object is a Window
+ * Check is a javascript object is a Window.
*/
public static boolean isWindow(JavaScriptObject o) {
return hasProperty(o, "alert");
}
/**
- * Check if an element is a DOM or a XML node
+ * Check if an element is a DOM or a XML node.
*/
public static boolean isXML(Node o) {
return o == null ? false
@@ -462,7 +476,7 @@ public class JsUtils {
/**
* Utility method to cast objects to array of string in production.
*/
- public static native String[] castArrayString(Object a)/*-{
+ public static native String[] castArrayString(Object a) /*-{
return a
}-*/;
@@ -486,10 +500,12 @@ public class JsUtils {
* @return the javascript object returned by the jsni method or null.
*/
public static <T> T runJavascriptFunction(JavaScriptObject o, String meth, Object... args) {
- return runJavascriptFunctionImpl(o, meth, JsObjectArray.create().add(args).<JsArrayMixed>cast());
+ return runJavascriptFunctionImpl(o, meth, JsObjectArray.create().add(args)
+ .<JsArrayMixed> cast());
}
- private static native <T> T runJavascriptFunctionImpl(JavaScriptObject o, String meth, JsArrayMixed args) /*-{
+ private static native <T> T runJavascriptFunctionImpl(JavaScriptObject o, String meth,
+ JsArrayMixed args) /*-{
return (f = o && o[meth])
&& @com.google.gwt.query.client.js.JsUtils::isFunction(*)(f)
&& @com.google.gwt.query.client.js.JsCache::gwtBox(*)([f.apply(o, args)]);
@@ -510,7 +526,7 @@ public class JsUtils {
}-*/;
/**
- * Remove duplicates from an elements array
+ * Remove duplicates from an elements array.
*/
public static JsArray<Element> unique(JsArray<Element> a) {
return utilsImpl.unique(a);
@@ -526,6 +542,7 @@ public class JsUtils {
/**
* Returns a QueryString representation of a JavascriptObject.
+ *
* TODO: jquery implementation accepts a second parameter (traditional)
*/
public static String param(JavaScriptObject js) {
@@ -535,13 +552,13 @@ public class JsUtils {
ret += ret.isEmpty() ? "" : "&";
JsCache o = prop.getArray(k).cast();
if (o != null) {
- for (int i = 0, l = o.length(); i < l ; i++) {
+ for (int i = 0, l = o.length(); i < l; i++) {
ret += i > 0 ? "&" : "";
- Properties p = o.<JsCache>cast().getJavaScriptObject(i);
+ Properties p = o.<JsCache> cast().getJavaScriptObject(i);
if (p != null) {
ret += k + "[]=" + p.toJsonString();
} else {
- ret += k + "[]=" + o.getString(i) ;
+ ret += k + "[]=" + o.getString(i);
}
}
} else {
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java
index fc2c726d..acb7fc17 100755
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java
@@ -35,7 +35,7 @@ public class Effects extends QueuePlugin<Effects> {
/**
* Class to access protected methods in Animation.
*/
- public static abstract class GQAnimation extends Animation {
+ public abstract static class GQAnimation extends Animation {
private static final String ACTUAL_ANIMATION = "EffectsRunnning";
@@ -47,20 +47,24 @@ public class Effects extends QueuePlugin<Effects> {
e = element;
return this;
}
+
protected GQAnimation setProperties(Properties properties) {
prps = properties == null ? Properties.create() : properties;
return this;
}
+
protected void onStart() {
// Mark this animation as actual, so as we can stop it in the GQuery.stop() method
$(e).data(ACTUAL_ANIMATION, this);
super.onStart();
}
+
protected void onComplete() {
// avoid memory leak (issue #132)
$(e).removeData(ACTUAL_ANIMATION);
super.onComplete();
}
+
public void cancel() {
// avoid memory leak (issue #132)
$(e).removeData(ACTUAL_ANIMATION);
@@ -100,6 +104,7 @@ public class Effects extends QueuePlugin<Effects> {
anim.cancel();
}
}
+
public void f(Element e) {
anim.run(duration);
}
@@ -125,8 +130,8 @@ public class Effects extends QueuePlugin<Effects> {
* Example:
*
* <pre class="code">
- * //move the element from its original position to the position top:500px and left:500px for 400ms.
- * //use a swing easing function for the transition
+ * // move the element from its original position to the position top:500px and left:500px for 400ms.
+ * // use a swing easing function for the transition
* $("#foo").animate(Properties.create("{top:'500px',left:'500px'}"), 400, EasingCurve.swing);
* // Change the width and border attributes of a table
* $("table").animate(Properties.create("{$width: '500', $border: '10'}"), 400, EasingCurve.linear);
@@ -142,8 +147,8 @@ public class Effects extends QueuePlugin<Effects> {
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left and 5OOpx down for 400ms.
- * //use a swing easing function for the transition
+ * // move the element from its original position to 500px to the left and 5OOpx down for 400ms.
+ * // use a swing easing function for the transition
* $("#foo").animate(Properties.create("{top:'+=500px',left:'+=500px'}"), 400, Easing.SWING);
* </pre>
*
@@ -157,7 +162,7 @@ public class Effects extends QueuePlugin<Effects> {
* $("#foo").animate($$("{backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)'}"), 400, EasingCurve.swing);
* </pre>
*
- * @param p a {@link Properties} object containing css properties to animate.
+ * @param stringOrProperties object containing css properties to animate.
* @param funcs an array of {@link Function} called once the animation is
* complete
* @param duration the duration in milliseconds of the animation
@@ -175,7 +180,7 @@ public class Effects extends QueuePlugin<Effects> {
duration = Math.abs(duration);
- for (Element e: elements()) {
+ for (Element e : elements()) {
if (Fx.css3) {
new TransitionsClipAnimation(easing, e, p, funcs).run(duration);
} else {
@@ -200,7 +205,7 @@ public class Effects extends QueuePlugin<Effects> {
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms
+ * // move the element from its original position to left:500px for 500ms
* $("#foo").animate("left:'500'");
* // Change the width attribute of a table
* $("table").animate("$width:'500'"), 400, EasingCurve.swing);
@@ -216,7 +221,7 @@ public class Effects extends QueuePlugin<Effects> {
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 500ms and
+ * // move the element from its original position to 500px to the left for 500ms and
* // change the background color of the element at the end of the animation
* $("#foo").animate("left:'+=500'", new Function(){
*
@@ -238,7 +243,7 @@ public class Effects extends QueuePlugin<Effects> {
* $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)'");
* </pre>
*
- * @param prop the property to animate : "cssName:'value'"
+ * @param stringOrProperties the property to animate : "cssName:'value'"
* @param funcs an array of {@link Function} called once the animation is
* complete
*/
@@ -260,7 +265,7 @@ public class Effects extends QueuePlugin<Effects> {
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 2s
+ * // move the element from its original position to left:500px for 2s
* $("#foo").animate("left:'500px'", 2000);
* // Change the width attribute of a table
* $("table").animate("$width:'500'"), 400);
@@ -276,7 +281,7 @@ public class Effects extends QueuePlugin<Effects> {
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 1000ms and
+ * // move the element from its original position to 500px to the left for 1000ms and
* // change the background color of the element at the end of the animation
* $("#foo").animate("left:'+=500'", 1000, new Function(){
* public void f(Element e){
@@ -294,7 +299,7 @@ public class Effects extends QueuePlugin<Effects> {
* $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)', 1000");
* </pre>
*
- * @param prop the property to animate : "cssName:'value'"
+ * @param stringOrProperties the property to animate : "cssName:'value'"
* @param funcs an array of {@link Function} called once the animation is
* complete
* @param duration the duration in milliseconds of the animation
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java
index a35ebb70..3983791a 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java
@@ -39,7 +39,8 @@ public class Events extends GQuery {
* Don't apply events on text and comment nodes !!
*/
private static boolean isEventCapable(Node n) {
- return JsUtils.isWindow(n) || JsUtils.isElement(n) && n.getNodeType() != 3 && n.getNodeType() != 8;
+ return JsUtils.isWindow(n) || JsUtils.isElement(n) && n.getNodeType() != 3
+ && n.getNodeType() != 8;
}
public Events(GQuery gq) {
@@ -113,7 +114,7 @@ public class Events extends GQuery {
}
public GQuery die(int eventbits) {
- return die(eventbits, null);
+ return die(eventbits, null);
}
/**
@@ -129,14 +130,12 @@ public class Events extends GQuery {
public GQuery live(int eventbits, final Object data, Function... funcs) {
return live(eventbits, null, data, funcs);
-
}
public GQuery live(int eventbits, String nameSpace, final Object data, Function... funcs) {
EventsListener.getInstance(Element.is(currentContext) ? (Element) currentContext : body).live(
eventbits, nameSpace, null, currentSelector, data, funcs);
return this;
-
}
public GQuery live(String eventName, final Object data, Function... funcs) {
@@ -182,7 +181,6 @@ public class Events extends GQuery {
}
return bind("mouseleave", null, fs);
-
}
/**
@@ -301,7 +299,7 @@ public class Events extends GQuery {
for (EventName part : EventName.split(htmlEvent)) {
NativeEvent e = document.createHtmlEvent(part.eventName, true, true);
JsUtils.prop(e, "namespace", part.nameSpace);
- if ("submit".equals(part.eventName)){
+ if ("submit".equals(part.eventName)) {
Function submitFunction = new Function() {
public void f(Element e) {
// first submit the form then call the others functions
@@ -403,7 +401,7 @@ public class Events extends GQuery {
// Ie6-8 don't dispatch bitless event
if ((browser.ie6 || browser.ie8) && Event.getTypeInt(evt.getType()) == -1) {
- bubbleEventForIE(e, evt.<Event>cast());
+ bubbleEventForIE(e, evt.<Event> cast());
} else {
e.dispatchEvent(evt);
}
@@ -427,16 +425,16 @@ public class Events extends GQuery {
}
/**
- * Only valid for IE6-8
+ * Only valid for IE6-8.
* @param event
* @return
*/
private boolean isEventPropagationStopped(Event event) {
// trick to avoid jnsi
- return event.<Element>cast().getPropertyBoolean("cancelBubble");
+ return event.<Element> cast().getPropertyBoolean("cancelBubble");
}
- private void callHandlers(Element e, NativeEvent evt, Function... functions){
+ private void callHandlers(Element e, NativeEvent evt, Function... functions) {
for (Function f : functions) {
f.setEvent(Event.as(evt));
f.f(e);
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..eb63a22a 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,21 +14,16 @@
* 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.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;
+import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.Easing;
-public interface LazyEffects<T> extends LazyBase<T>{
+/**
+ * LazyEffects.
+ * @param <T>
+ */
+public interface LazyEffects<T> extends LazyBase<T> {
/**
* The animate() method allows you to create animation effects on any numeric
@@ -44,8 +39,8 @@ public interface LazyEffects<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to the position top:500px and left:500px for 400ms.
- * //use a swing easing function for the transition
+ * // move the element from its original position to the position top:500px and left:500px for 400ms.
+ * // use a swing easing function for the transition
* $("#foo").animate(Properties.create("{top:'500px',left:'500px'}"), 400, EasingCurve.swing);
* // Change the width and border attributes of a table
* $("table").animate(Properties.create("{$width: '500', $border: '10'}"), 400, EasingCurve.linear);
@@ -61,8 +56,8 @@ public interface LazyEffects<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left and 5OOpx down for 400ms.
- * //use a swing easing function for the transition
+ * // move the element from its original position to 500px to the left and 5OOpx down for 400ms.
+ * // use a swing easing function for the transition
* $("#foo").animate(Properties.create("{top:'+=500px',left:'+=500px'}"), 400, Easing.SWING);
* </pre>
*
@@ -76,7 +71,7 @@ public interface LazyEffects<T> extends LazyBase<T>{
* $("#foo").animate($$("{backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)'}"), 400, EasingCurve.swing);
* </pre>
*
- * @param p a {@link Properties} object containing css properties to animate.
+ * @param stringOrProperties {@link Properties} object containing css properties to animate.
* @param funcs an array of {@link Function} called once the animation is
* complete
* @param duration the duration in milliseconds of the animation
@@ -99,7 +94,7 @@ public interface LazyEffects<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms
+ * // move the element from its original position to left:500px for 500ms
* $("#foo").animate("left:'500'");
* // Change the width attribute of a table
* $("table").animate("$width:'500'"), 400, EasingCurve.swing);
@@ -115,7 +110,7 @@ public interface LazyEffects<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 500ms and
+ * // move the element from its original position to 500px to the left for 500ms and
* // change the background color of the element at the end of the animation
* $("#foo").animate("left:'+=500'", new Function(){
*
@@ -137,7 +132,7 @@ public interface LazyEffects<T> extends LazyBase<T>{
* $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)'");
* </pre>
*
- * @param prop the property to animate : "cssName:'value'"
+ * @param stringOrProperties the property to animate : "cssName:'value'"
* @param funcs an array of {@link Function} called once the animation is
* complete
*/
@@ -157,7 +152,7 @@ public interface LazyEffects<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 2s
+ * // move the element from its original position to left:500px for 2s
* $("#foo").animate("left:'500px'", 2000);
* // Change the width attribute of a table
* $("table").animate("$width:'500'"), 400);
@@ -173,7 +168,7 @@ public interface LazyEffects<T> extends LazyBase<T>{
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 1000ms and
+ * // move the element from its original position to 500px to the left for 1000ms and
* // change the background color of the element at the end of the animation
* $("#foo").animate("left:'+=500'", 1000, new Function(){
* public void f(Element e){
@@ -191,7 +186,7 @@ public interface LazyEffects<T> extends LazyBase<T>{
* $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)', 1000");
* </pre>
*
- * @param prop the property to animate : "cssName:'value'"
+ * @param stringOrProperties the property to animate : "cssName:'value'"
* @param funcs an array of {@link Function} called once the animation is
* complete
* @param duration the duration in milliseconds of the animation
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 98eaf97e..55404170 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,20 +12,17 @@
* 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.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<T> extends LazyBase<T>{
+/**
+ * LazyEvents.
+ * @param <T>
+ */
+public interface LazyEvents<T> extends LazyBase<T> {
/**
* Binds a set of handlers to a particular Event for each matched element.
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..f08a0538 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,36 +14,30 @@
* 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<T> extends LazyBase<T>{
+/**
+ * LazyWidgets.
+ * @param <T>
+ */
+public interface LazyWidgets<T> extends LazyBase<T> {
/**
* Try to create a widget using the given factory and the given options for
* each element of the query. Returns a new gquery set of elements with the
* new widgets created.
*/
- <W extends Widget> LazyWidgets<T> widgets(WidgetFactory<W> factory, WidgetInitializer<W> initializers);
+ <W extends Widget> LazyWidgets<T> widgets(WidgetFactory<W> factory,
+ WidgetInitializer<W> initializers);
/**
* Create a {@link Button} widget for each selected element.
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/MouseOptions.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/MouseOptions.java
index 4d010276..772f8e9f 100755
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/MouseOptions.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/MouseOptions.java
@@ -16,7 +16,7 @@
package com.google.gwt.query.client.plugins;
/**
- * Object use to configure a Plugin extending {@link MousePlugin}
+ * Object use to configure a Plugin extending {@link MousePlugin}.
*
*/
public class MouseOptions {
@@ -58,7 +58,7 @@ public class MouseOptions {
}
/**
- * Prevents starting of the plugin on specified elements
+ * Prevents starting of the plugin on specified elements.
*
* @param cancel
* array of css selectors
@@ -89,6 +89,6 @@ public class MouseOptions {
protected void initDefault() {
delay = 0;
distance = 1; // by default, the mouse have to move one pixel !
- cancel = new String[] { "input", "option" };
+ cancel = new String[] {"input", "option"};
}
}
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..2202bc71 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
@@ -52,7 +52,7 @@ public abstract class MousePlugin extends UiPlugin {
protected abstract String getPluginName();
/**
- * This method initialize all needed handlers
+ * This method initialize all needed handlers.
*
*/
protected void initMouseHandler(MouseOptions options) {
@@ -67,7 +67,6 @@ public abstract class MousePlugin extends UiPlugin {
return true;
}
return mouseDown(e, GqEvent.create(event));
-
}
}).bind(Event.ONTOUCHSTART, getPluginName(), (Object) null, new Function() {
public boolean f(com.google.gwt.user.client.Event event) {
@@ -77,7 +76,6 @@ public abstract class MousePlugin extends UiPlugin {
touchSupported = true;
return mouseDown(e, GqEvent.create(event));
-
}
}).bind(Event.ONCLICK, getPluginName(), (Object) null, new Function() {
@Override
@@ -96,20 +94,17 @@ public abstract class MousePlugin extends UiPlugin {
}
});
}
-
}
/**
* Test if the mouse down event must be handled by the plugin or not.
- *
*/
protected boolean mouseCapture(Element draggable, GqEvent event) {
return true;
}
/**
- * Method called when mouse click
- *
+ * Method called when mouse click.
*/
protected boolean mouseClick(Element element, GqEvent event) {
return true;
@@ -119,8 +114,7 @@ public abstract class MousePlugin extends UiPlugin {
* Method called when mouse down occur on the element.
*
* You should not override this method. Instead, override {@link #mouseStart(Element, GqEvent)}
- * method
- *
+ * method.
*/
protected boolean mouseDown(Element element, GqEvent event) {
@@ -150,7 +144,7 @@ public abstract class MousePlugin extends UiPlugin {
bindOtherEvents(element);
- if (!touchSupported){ //click event are not triggered if we call preventDefault on touchstart event.
+ if (!touchSupported) { // click event are not triggered if we call preventDefault on touchstart event.
event.getOriginalEvent().preventDefault();
}
@@ -160,8 +154,7 @@ public abstract class MousePlugin extends UiPlugin {
}
/**
- * Method called when the mouse is dragging
- *
+ * Method called when the mouse is dragging.
*/
protected abstract boolean mouseDrag(Element element, GqEvent event);
@@ -198,8 +191,7 @@ public abstract class MousePlugin extends UiPlugin {
protected abstract boolean mouseStart(Element element, GqEvent event);
/**
- * Method called when the mouse button is released
- *
+ * Method called when the mouse button is released.
*/
protected abstract boolean mouseStop(Element element, GqEvent event);
@@ -207,8 +199,7 @@ public abstract class MousePlugin extends UiPlugin {
* Method called when mouse is released..
*
* You should not override this method. Instead, override {@link #mouseStop(Element, GqEvent)}
- * method
- *
+ * method.
*/
protected boolean mouseUp(Element element, GqEvent event) {
@@ -220,7 +211,6 @@ public abstract class MousePlugin extends UiPlugin {
}
return true;
-
}
private void bindOtherEvents(final Element element) {
@@ -253,9 +243,7 @@ public abstract class MousePlugin extends UiPlugin {
return false;
}
});
-
}
-
}
private boolean delayConditionMet() {
@@ -280,12 +268,12 @@ public abstract class MousePlugin extends UiPlugin {
return mouseDistance >= neededDistance;
}
- private native boolean isEventAlreadyHandled(GqEvent event)/*-{
+ private native boolean isEventAlreadyHandled(GqEvent event) /*-{
var result = event.mouseHandled ? event.mouseHandled : false;
return result;
}-*/;
- private native void markEventAsHandled(GqEvent event)/*-{
+ private native void markEventAsHandled(GqEvent event) /*-{
event.mouseHandled = true;
}-*/;
@@ -300,7 +288,6 @@ public abstract class MousePlugin extends UiPlugin {
}
return isNotBoutonLeft || isElementCancel || !mouseCapture(element, mouseDownEvent);
-
}
private void reset(GqEvent nativeEvent) {
@@ -333,5 +320,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..8951ccad 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,8 +22,13 @@ 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.
+ *
+ * @param <T>
*/
public class QueuePlugin<T extends QueuePlugin<?>> extends GQuery {
@@ -80,14 +82,14 @@ public class QueuePlugin<T extends QueuePlugin<?>> extends GQuery {
}
/**
- * remove all queued functions from the effects queue
+ * remove all queued functions from the effects queue.
*/
public T clearQueue() {
return clearQueue(DEFAULT_NAME);
}
/**
- * remove all queued function from the named queue
+ * remove all queued function from the named queue.
*/
@SuppressWarnings("unchecked")
public T clearQueue(String name) {
@@ -98,21 +100,21 @@ public class QueuePlugin<T extends QueuePlugin<?>> extends GQuery {
}
/**
- * Add a delay in the effects queue
+ * Add a delay in the effects queue.
*/
public T delay(int milliseconds, Function... f) {
return delay(milliseconds, DEFAULT_NAME, f);
}
/**
- * Add a delay in the named queue
+ * Add a delay in the named queue.
*/
@SuppressWarnings("unchecked")
public T delay(int milliseconds, String name, Function... funcs) {
for (Element e : elements()) {
queue(e, name, new DelayFunction(e, name, milliseconds, funcs));
}
- return (T)this;
+ return (T) this;
}
/**
@@ -154,7 +156,7 @@ public class QueuePlugin<T extends QueuePlugin<?>> extends GQuery {
int count = 1;
// Inner functions don't have constructors, we use a block to initialize it
{
- for (Element elem: elements()) {
+ for (Element elem : elements()) {
// Add this resolve function only to those elements with active queue
if (queue(elem, name, null) != null) {
emptyHooks(elem, name).add(this);
@@ -190,7 +192,7 @@ public class QueuePlugin<T extends QueuePlugin<?>> extends GQuery {
*/
public int queue(String name) {
Queue<?> q = isEmpty() ? null : queue(get(0), name, null);
- return q == null? 0 : q.size();
+ return q == null ? 0 : q.size();
}
/**
@@ -204,7 +206,7 @@ public class QueuePlugin<T extends QueuePlugin<?>> extends GQuery {
queue(e, DEFAULT_NAME, f);
}
}
- return (T)this;
+ return (T) this;
}
/**
@@ -213,12 +215,12 @@ public class QueuePlugin<T extends QueuePlugin<?>> extends GQuery {
*/
@SuppressWarnings("unchecked")
public T queue(final String name, Function... funcs) {
- for (final Function f: funcs) {
- for (Element e: elements()) {
+ for (final Function f : funcs) {
+ for (Element e : elements()) {
queue(e, name, f);
}
}
- return (T)this;
+ return (T) this;
}
/**
@@ -368,9 +370,9 @@ public class QueuePlugin<T extends QueuePlugin<?>> extends GQuery {
private Callbacks emptyHooks(Element elem, String name) {
String key = name + EMPTY_HOOKS;
- Callbacks c = (Callbacks)data(elem, key, null);
+ Callbacks c = (Callbacks) data(elem, key, null);
if (c == null) {
- c = (Callbacks)data(elem, key, new Callbacks("once memory"));
+ c = (Callbacks) data(elem, key, new Callbacks("once memory"));
}
return c;
}
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..92938d17 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
@@ -25,13 +25,13 @@ import com.google.gwt.query.client.Predicate;
/**
* GWT clone of jQueryUi-core. This class define some function present in the
- * jQuery-ui core and not directly in jQuery
+ * jQuery-ui core and not directly in jQuery.
*
*/
public class UiPlugin extends GQuery {
/**
- * A POJO used to store dimension of an element
+ * A POJO used to store dimension of an element.
*
*/
public static class Dimension {
@@ -56,7 +56,7 @@ public class UiPlugin extends GQuery {
}
/**
- * return the width value
+ * return the width value.
*/
public int getWidth() {
return width;
@@ -76,14 +76,13 @@ public class UiPlugin extends GQuery {
scrollParent = gQueryUi.parents().filter(new Predicate() {
public boolean f(Element e, int index) {
- GQuery $e = GQuery.$(e);
- String position = $e.css("position", true);
+ GQuery g = GQuery.$(e);
+ String position = g.css("position", true);
return ("relative".equals(position) || "absolute".equals(position) || "fixed"
.equals(position))
- && isOverflowEnabled($e);
+ && isOverflowEnabled(g);
}
});
-
} else {
scrollParent = gQueryUi.parents().filter(new Predicate() {
@@ -94,14 +93,13 @@ public class UiPlugin extends GQuery {
}
return scrollParent.length() > 0 ? $(scrollParent.get(0))
: $(getViewportElement());
-
}
protected boolean scrollParentPositionTest(UiPlugin gQueryUi) {
return "absolute".equals(gQueryUi.css("position"));
}
- private final Element getViewportElement() {
+ private Element getViewportElement() {
return GQuery.document.isCSS1Compat() ? GQuery.document
.getDocumentElement() : GQuery.document.getBody();
}
@@ -111,7 +109,6 @@ public class UiPlugin extends GQuery {
+ e.css("overflow-y", true);
return overflow.contains("auto") || overflow.contains("scroll");
}
-
}
@SuppressWarnings("unused")
@@ -123,7 +120,6 @@ public class UiPlugin extends GQuery {
return ("absolute".equals(position) || "relative".equals(position) || "static"
.equals(position));
}
-
}
public static Class<UiPlugin> GQueryUi = UiPlugin.class;
@@ -150,7 +146,7 @@ public class UiPlugin extends GQuery {
handlerManager.fireEvent(e);
}
if (callback != null) {
- callback.f(element.<com.google.gwt.dom.client.Element>cast());
+ callback.f(element.<com.google.gwt.dom.client.Element> cast());
}
}
@@ -176,5 +172,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..0c26c0bc 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.
@@ -84,7 +84,7 @@ public class Widgets extends QueuePlugin<Widgets> {
}
/**
- * Create and return a widget using the given factory and the given options
+ * Create and return a widget using the given factory and the given options.
*/
protected <W extends Widget> W widget(Element e, WidgetFactory<W> factory,
WidgetInitializer<W> initializer) {
@@ -101,7 +101,7 @@ public class Widgets extends QueuePlugin<Widgets> {
}
/**
- * Create and return a widget using the given factory and the given options
+ * Create and return a widget using the given factory and the given options.
*/
protected <W extends Widget> W widget(WidgetFactory<W> factory,
WidgetInitializer<W> initializers) {
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..eb58f93d 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;
@@ -51,7 +51,10 @@ public class Ajax extends GQuery {
public static final String JSON_CONTENT_TYPE_UTF8 = JSON_CONTENT_TYPE + "; charset=utf-8";
- public static interface AjaxTransport {
+ /**
+ * Ajax Transport object.
+ */
+ public interface AjaxTransport {
Promise getJsonP(Settings settings);
Promise getLoadScript(Settings settings);
@@ -60,36 +63,63 @@ public class Ajax extends GQuery {
}
/**
- * Ajax Settings object
+ * Ajax Settings object.
*/
public interface Settings extends JsonBuilder {
String getContentType();
+
Element getContext();
+
IsProperties getData();
+
String getDataString();
+
String getDataType();
+
Function getError();
+
IsProperties getHeaders();
+
String getPassword();
+
Function getSuccess();
+
int getTimeout();
+
String getType();
+
String getUrl();
+
String getUsername();
+
boolean getWithCredentials();
+
Settings setContentType(String t);
+
Settings setContext(Element e);
+
Settings setData(Object p);
+
Settings setDataString(String d);
+
Settings setDataType(String t);
+
Settings setError(Function f);
+
Settings setHeaders(IsProperties p);
+
Settings setPassword(String p);
+
Settings setSuccess(Function f);
+
Settings setTimeout(int t);
+
Settings setType(String t);
+
Settings setUrl(String u);
+
Settings setUsername(String u);
+
Settings setWithCredentials(boolean b);
}
@@ -126,10 +156,6 @@ public class Ajax extends GQuery {
}, properties);
* </pre>
*
- * @param url The url to connect
- * @param onSuccess a function to execute in the case of success
- * @param onError the function to execute on error
- * @param settings a Properties object with the configuration of the Ajax request.
*/
public static Promise ajax(Settings settings) {
resolveSettings(settings);
@@ -150,45 +176,45 @@ public class Ajax extends GQuery {
if ("jsonp".equalsIgnoreCase(dataType)) {
ret = GQ.getAjaxTransport().getJsonP(settings);
- } else if ("loadscript".equalsIgnoreCase(dataType)){
+ } else if ("loadscript".equalsIgnoreCase(dataType)) {
ret = GQ.getAjaxTransport().getLoadScript(settings);
} else {
ret = GQ.getAjaxTransport().getXhr(settings)
- .then(new Function() {
- public Object f(Object...args) {
- Response response = arguments(0);
- Request request = arguments(1);
- Object retData = response.getText();
- if (retData != null && !"".equals(retData)) {
- try {
- if ("xml".equalsIgnoreCase(dataType)) {
- retData = JsUtils.parseXML(response.getText());
- } else if ("json".equalsIgnoreCase(dataType)) {
- retData = GQ.create(response.getText());
- } else {
- retData = response.getText();
- if ("script".equalsIgnoreCase(dataType)) {
- ScriptInjector.fromString((String)retData).setWindow(window).inject();
+ .then(new Function() {
+ public Object f(Object... args) {
+ Response response = arguments(0);
+ Request request = arguments(1);
+ Object retData = response.getText();
+ if (retData != null && !"".equals(retData)) {
+ try {
+ if ("xml".equalsIgnoreCase(dataType)) {
+ retData = JsUtils.parseXML(response.getText());
+ } else if ("json".equalsIgnoreCase(dataType)) {
+ retData = GQ.create(response.getText());
+ } else {
+ retData = response.getText();
+ if ("script".equalsIgnoreCase(dataType)) {
+ ScriptInjector.fromString((String) retData).setWindow(window).inject();
+ }
+ }
+ } catch (Exception e) {
+ if (GWT.isClient() && GWT.getUncaughtExceptionHandler() != null) {
+ GWT.getUncaughtExceptionHandler().onUncaughtException(e);
+ } else {
+ e.printStackTrace();
}
- }
- } catch (Exception e) {
- if (GWT.isClient() && GWT.getUncaughtExceptionHandler() != null) {
- GWT.getUncaughtExceptionHandler().onUncaughtException(e);
- } else {
- e.printStackTrace();
}
}
+ return new Object[] {retData, "success", request, response};
}
- return new Object[]{retData, "success", request, response};
- }
- }, new Function() {
- public Object f(Object...args) {
- Throwable exception = arguments(0);
- Request request = getArgument(1, Request.class);
- String msg = String.valueOf(exception);
- return new Object[]{null, msg, request, null, exception};
- }
- });
+ }, new Function() {
+ public Object f(Object... args) {
+ Throwable exception = arguments(0);
+ Request request = getArgument(1, Request.class);
+ String msg = String.valueOf(exception);
+ return new Object[] {null, msg, request, null, exception};
+ }
+ });
}
if (onSuccess != null) {
ret.done(onSuccess);
@@ -201,7 +227,7 @@ public class Ajax extends GQuery {
private static void resolveSettings(Settings settings) {
String url = settings.getUrl();
- assert settings != null && settings.getUrl() != null: "no url found in settings";
+ assert settings != null && settings.getUrl() != null : "no url found in settings";
String type = "POST";
if (settings.getType() != null) {
@@ -215,10 +241,12 @@ public class Ajax extends GQuery {
IsProperties data = settings.getData();
if (data != null) {
String dataString = null, contentType = null;
- if (data.getDataImpl() instanceof JavaScriptObject && JsUtils.isFormData(data.<JavaScriptObject>getDataImpl())) {
+ if (data.getDataImpl() instanceof JavaScriptObject
+ && JsUtils.isFormData(data.<JavaScriptObject> getDataImpl())) {
dataString = null;
contentType = FormPanel.ENCODING_URLENCODED;
- } else if (settings.getType().matches("(POST|PUT)") && "json".equalsIgnoreCase(settings.getDataType())) {
+ } else if (settings.getType().matches("(POST|PUT)")
+ && "json".equalsIgnoreCase(settings.getDataType())) {
dataString = data.toJson();
contentType = JSON_CONTENT_TYPE_UTF8;
} else {
@@ -280,7 +308,7 @@ public class Ajax extends GQuery {
}
public static Promise get(String url, IsProperties data) {
- return get(url, (IsProperties)data, null);
+ return get(url, (IsProperties) data, null);
}
public static Promise get(String url, IsProperties data, Function onSuccess) {
@@ -312,7 +340,7 @@ public class Ajax extends GQuery {
}
public static Promise getJSONP(String url, IsProperties data) {
- return getJSONP(url, (IsProperties)data, null);
+ return getJSONP(url, (IsProperties) data, null);
}
public static Promise getJSONP(String url, IsProperties data, Function onSuccess) {
@@ -327,13 +355,12 @@ public class Ajax extends GQuery {
public static Promise getJSONP(String url, Function success, Function error, int timeout) {
return ajax(createSettings()
- .setUrl(url)
- .setDataType("jsonp")
- .setType("get")
- .setTimeout(timeout)
- .setSuccess(success)
- .setError(error)
- );
+ .setUrl(url)
+ .setDataType("jsonp")
+ .setType("get")
+ .setTimeout(timeout)
+ .setSuccess(success)
+ .setError(error));
}
/**
@@ -345,15 +372,14 @@ public class Ajax extends GQuery {
public static Promise getScript(final String url, Function success) {
return ajax(createSettings()
- .setUrl(url)
- .setType("get")
- .setDataType("script")
- .setSuccess(success)
- );
+ .setUrl(url)
+ .setType("get")
+ .setDataType("script")
+ .setSuccess(success));
}
/**
- * Load a JavaScript file from any url using the script tag mechanism
+ * Load a JavaScript file from any url using the script tag mechanism.
*/
public static Promise loadScript(String url) {
return loadScript(url, null);
@@ -361,15 +387,14 @@ public class Ajax extends GQuery {
public static Promise loadScript(final String url, Function success) {
return ajax(createSettings()
- .setUrl(url)
- .setType("get")
- .setDataType("loadscript")
- .setSuccess(success)
- );
+ .setUrl(url)
+ .setType("get")
+ .setDataType("loadscript")
+ .setSuccess(success));
}
public static Promise post(String url, IsProperties data) {
- return post(url, (IsProperties)data, null);
+ return post(url, (IsProperties) data, null);
}
public static Promise post(String url, IsProperties data, final Function onSuccess) {
@@ -405,10 +430,10 @@ public class Ajax extends GQuery {
// not support java embedded flag expressions (?s) and javascript does
// not have multidot flag.
String s = arguments(0).toString().replaceAll("<![^>]+>\\s*", "")
- .replaceAll("</?html[\\s\\S]*?>\\s*", "")
- .replaceAll("<head[\\s\\S]*?</head>\\s*", "")
- .replaceAll("<script[\\s\\S]*?</script>\\s*", "")
- .replaceAll("</?body[\\s\\S]*?>\\s*", "");
+ .replaceAll("</?html[\\s\\S]*?>\\s*", "")
+ .replaceAll("<head[\\s\\S]*?</head>\\s*", "")
+ .replaceAll("<script[\\s\\S]*?</script>\\s*", "")
+ .replaceAll("</?body[\\s\\S]*?>\\s*", "");
// We wrap the results in a div
s = "<div>" + s + "</div>";
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..15406a68 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
@@ -41,20 +41,22 @@ public class AjaxTransportJs implements AjaxTransport {
public Promise getLoadScript(final Settings settings) {
return new PromiseFunction() {
private ScriptElement scriptElement;
+
public void f(final Deferred dfd) {
scriptElement = ScriptInjector.fromUrl(settings.getUrl()).setWindow(GQuery.window)
- .setCallback(new Callback<Void, Exception>() {
- public void onSuccess(Void result) {
- GQuery.$(GQuery.window).delay(0, new Function(){
- public void f() {
- dfd.resolve(scriptElement);
+ .setCallback(new Callback<Void, Exception>() {
+ public void onSuccess(Void result) {
+ GQuery.$(GQuery.window).delay(0, new Function() {
+ public void f() {
+ dfd.resolve(scriptElement);
+ }
+ });
+ }
+
+ public void onFailure(Exception reason) {
+ dfd.reject(reason);
}
- });
- }
- public void onFailure(Exception reason) {
- dfd.reject(reason);
- }
- }).inject().cast();
+ }).inject().cast();
}
};
}
@@ -62,5 +64,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..508c82e5 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.
*/
@@ -26,14 +26,13 @@ public class Callbacks {
/**
* Iterface used for callbacks which could cancel the execution
- * when returning false;
- *
+ * when returning false.
*/
- public static interface Callback {
+ public interface Callback {
/**
- * Return false to avoid executing the rest of functions
+ * Return false to avoid executing the rest of functions.
*/
- boolean f(Object ...objects);
+ boolean f(Object... objects);
}
private List<Object> stack = new ArrayList<Object>();
@@ -67,7 +66,7 @@ public class Callbacks {
*
*/
public Callbacks add(Callback... c) {
- addAll((Object[])c);
+ addAll((Object[]) c);
return this;
}
@@ -75,7 +74,7 @@ public class Callbacks {
* Add a Callback or a collection of callbacks to a callback list.
*/
public Callbacks add(com.google.gwt.core.client.Callback<?, ?>... c) {
- addAll((Object[])c);
+ addAll((Object[]) c);
return this;
}
@@ -83,7 +82,7 @@ public class Callbacks {
* Add a Function or a collection of Function to a callback list.
*/
public Callbacks add(Function... f) {
- addAll((Object[])f);
+ addAll((Object[]) f);
return this;
}
@@ -97,7 +96,7 @@ public class Callbacks {
}
/**
- * lock
+ * lock.
*/
public Callbacks lock() {
if (!isMemory) {
@@ -116,11 +115,12 @@ public class Callbacks {
if (isMemory) {
memory = new ArrayList<Object>(Arrays.asList(o));
}
- if (stack != null) for (Object c : stack) {
- if (!run(c, o) && stopOnFalse) {
- break;
+ if (stack != null)
+ for (Object c : stack) {
+ if (!run(c, o) && stopOnFalse) {
+ break;
+ }
}
- }
}
return this;
}
@@ -133,7 +133,7 @@ public class Callbacks {
return this;
}
- private void addAll(Object...o) {
+ private void addAll(Object... o) {
for (Object c : o) {
if (!done && stack != null && c != null && (!isUnique || !stack.contains(c))) {
stack.add(c);
@@ -146,19 +146,19 @@ public class Callbacks {
}
@SuppressWarnings({"unchecked", "rawtypes"})
- private boolean run(Object c, Object...o) {
+ private boolean run(Object c, Object... o) {
// Unbox array inside array when there is only an element.
// It happens when running filters in Promise.then()
if (o != null && o.length == 1 && o[0] != null && o[0].getClass().isArray()) {
- o = (Object[])o[0];
+ o = (Object[]) o[0];
}
if (c instanceof Callback) {
- return ((Callback)c).f(o);
+ return ((Callback) c).f(o);
} else if (c instanceof Function) {
- Object r = ((Function)c).f(o);
- return (r instanceof Boolean) ? (Boolean)r : true;
+ Object r = ((Function) c).f(o);
+ return (r instanceof Boolean) ? (Boolean) r : true;
} else if (c instanceof com.google.gwt.core.client.Callback) {
- ((com.google.gwt.core.client.Callback)c).onSuccess(o);
+ ((com.google.gwt.core.client.Callback) c).onSuccess(o);
}
return true;
}
@@ -167,4 +167,3 @@ public class Callbacks {
return "stack=" + (stack == null ? "null" : stack.size()) + " " + done;
}
}
-
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..9cb7b624 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;
@@ -46,7 +48,8 @@ public class Deferred implements Promise.Deferred {
// Whether break the flow if old deferred fails
boolean cont = false;
- public ThenFunction(Deferred newDfd, Function[] subordinates, int funcType, boolean continueFlow) {
+ public ThenFunction(Deferred newDfd, Function[] subordinates, int funcType,
+ boolean continueFlow) {
type = funcType;
filter = subordinates.length > type ? subordinates[type] : null;
dfd = newDfd;
@@ -63,18 +66,23 @@ public class Deferred implements Promise.Deferred {
// If filter function returns a promise we pipeline it.
final Promise p = (Promise) newArgs;
if (type == PROGRESS) {
- p.progress(new Function(){public void f() {
- settle(PROGRESS, getArguments());
- }});
+ p.progress(new Function() {
+ public void f() {
+ settle(PROGRESS, getArguments());
+ }
+ });
} else {
- p.always(new Function(){public void f() {
- settle((type == DONE || type == FAIL && cont) && p.isResolved() ? DONE : FAIL, getArguments());
- }});
+ p.always(new Function() {
+ public void f() {
+ settle((type == DONE || type == FAIL && cont) && p.isResolved() ? DONE : FAIL,
+ getArguments());
+ }
+ });
}
} else {
// Otherwise we change the arguments by the new ones
newArgs = Boolean.TRUE.equals(newArgs) ? oldArgs :
- newArgs != null && newArgs.getClass().isArray() ? (Object[])newArgs : newArgs;
+ newArgs != null && newArgs.getClass().isArray() ? (Object[]) newArgs : newArgs;
settle(type, newArgs);
}
} else {
@@ -84,9 +92,12 @@ public class Deferred implements Promise.Deferred {
}
private void settle(int action, Object... args) {
- if (action == DONE) dfd.resolve(args);
- if (action == FAIL) dfd.reject(args);
- if (action == PROGRESS) dfd.notify(args);
+ if (action == DONE)
+ dfd.resolve(args);
+ if (action == FAIL)
+ dfd.reject(args);
+ if (action == PROGRESS)
+ dfd.notify(args);
}
}
@@ -276,11 +287,11 @@ public class Deferred implements Promise.Deferred {
private static Promise makePromise(final Object o) {
if (o instanceof Promise) {
- return (Promise)o;
+ return (Promise) o;
} else if (o instanceof Function) {
- return makePromise(((Function)o).f(new Object[0]));
+ return makePromise(((Function) o).f(new Object[0]));
} else if (o instanceof GQuery) {
- return ((GQuery)o).promise();
+ return ((GQuery) o).promise();
} else {
return new PromiseFunction() {
public void f(Deferred dfd) {
@@ -334,7 +345,8 @@ public class Deferred implements Promise.Deferred {
* Call the progressCallbacks on a Deferred object with the given args.
*/
public Deferred notify(Object... o) {
- if (state == PENDING) notify.fire(o);
+ if (state == PENDING)
+ notify.fire(o);
return this;
}
@@ -352,7 +364,8 @@ public class Deferred implements Promise.Deferred {
* Reject a Deferred object and call any failCallbacks with the given args.
*/
public Deferred reject(Object... o) {
- if (state == PENDING) reject.fire(o);
+ if (state == PENDING)
+ reject.fire(o);
return this;
}
@@ -360,12 +373,14 @@ public class Deferred implements Promise.Deferred {
* Resolve a Deferred object and call any doneCallbacks with the given args.
*/
public Deferred resolve(Object... o) {
- if (state == PENDING) resolve.fire(o);
+ if (state == PENDING)
+ resolve.fire(o);
return this;
}
@Override
public String toString() {
- return "Deferred this=" + hashCode() + " promise=" + promise().hashCode() + " state=" + promise.state() + " restatus=" + resolve.status();
+ return "Deferred this=" + hashCode() + " promise=" + promise().hashCode() + " state="
+ + promise.state() + " restatus=" + resolve.status();
}
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/FunctionDeferred.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/FunctionDeferred.java
index 38a03632..25295e46 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/FunctionDeferred.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/FunctionDeferred.java
@@ -45,7 +45,12 @@ import com.google.gwt.query.client.Promise.Deferred;
*/
public abstract class FunctionDeferred extends Function {
- public static enum CacheType {NONE, ALL, RESOLVED, REJECTED};
+ /**
+ * Cache types.
+ */
+ public static enum CacheType {
+ NONE, ALL, RESOLVED, REJECTED
+ };
protected Deferred dfd;
public Function resolve, reject;
@@ -64,10 +69,10 @@ public abstract class FunctionDeferred extends Function {
* is resolved.
*/
public final Object f(Object... args) {
- return dfd != null &&
+ return dfd != null &&
(cache == CacheType.ALL ||
- cache == CacheType.RESOLVED && dfd.promise().isResolved() ||
- cache == CacheType.REJECTED && dfd.promise().isRejected())
+ cache == CacheType.RESOLVED && dfd.promise().isResolved() ||
+ cache == CacheType.REJECTED && dfd.promise().isRejected())
? dfd.promise()
: new PromiseFunction() {
public void f(Deferred dfd) {
@@ -76,7 +81,7 @@ public abstract class FunctionDeferred extends Function {
FunctionDeferred.this.dfd = dfd;
FunctionDeferred.this.f(dfd);
}
- };
+ };
}
/**
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseRPC.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseRPC.java
index 1c2f3338..b108f56e 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseRPC.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseRPC.java
@@ -34,6 +34,8 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
* }
* });
* </pre>
+ *
+ * @param <T>
*/
public class PromiseRPC<T> extends DeferredPromiseImpl implements AsyncCallback<T> {
public void onFailure(Throwable caught) {
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..af9b9641 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;
@@ -76,14 +76,16 @@ public class PromiseReqBuilder extends DeferredPromiseImpl implements RequestCal
/**
* Using this constructor we access to some things in the xmlHttpRequest
* which are not available in GWT, like adding progress handles or sending
- * javascript data (like forms in modern html5 file api)
+ * javascript data (like forms in modern html5 file api).
*/
public PromiseReqBuilder(Settings settings) {
String httpMethod = settings.getType();
String url = settings.getUrl();
IsProperties data = settings.getData();
String ctype = settings.getContentType();
- Boolean isFormData = data != null && data.getDataImpl() instanceof JavaScriptObject && JsUtils.isFormData(data.<JavaScriptObject>getDataImpl());
+ Boolean isFormData =
+ data != null && data.getDataImpl() instanceof JavaScriptObject
+ && JsUtils.isFormData(data.<JavaScriptObject> getDataImpl());
XMLHttpRequest xmlHttpRequest = XMLHttpRequest.create();
try {
@@ -149,7 +151,8 @@ public class PromiseReqBuilder extends DeferredPromiseImpl implements RequestCal
});
try {
- JsUtils.runJavascriptFunction(xmlHttpRequest, "send", isFormData ? data.getDataImpl() : settings.getDataString());
+ JsUtils.runJavascriptFunction(xmlHttpRequest, "send", isFormData ? data.getDataImpl()
+ : settings.getDataString());
} catch (JavaScriptException e) {
onError(null, e);
}
@@ -163,21 +166,22 @@ public class PromiseReqBuilder extends DeferredPromiseImpl implements RequestCal
int status = response.getStatusCode();
if (status <= 0 || status >= 400) {
String statusText = status <= 0 ? "Bad CORS" : response.getStatusText();
- onError(request, new RequestException("HTTP ERROR: " + status + " " + statusText + "\n" + response.getText()));
+ onError(request, new RequestException("HTTP ERROR: " + status + " " + statusText + "\n"
+ + response.getText()));
} else {
dfd.resolve(response, request);
}
}
/**
- * Using violator pattern to execute private method
+ * Using violator pattern to execute private method.
*/
private native void fireOnResponseReceivedVltr(Request rq, RequestCallback cb) /*-{
rq.@com.google.gwt.http.client.Request::fireOnResponseReceived(Lcom/google/gwt/http/client/RequestCallback;)(cb);
}-*/;
/**
- * Using violator pattern to use protected constructor
+ * Using violator pattern to use protected constructor.
*/
private native Request createRequestVltr(XMLHttpRequest rq, int ms, RequestCallback cb) /*-{
return @com.google.gwt.http.client.Request::new(Lcom/google/gwt/xhr/client/XMLHttpRequest;ILcom/google/gwt/http/client/RequestCallback;)(rq,ms,cb);
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseReqBuilderJSONP.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseReqBuilderJSONP.java
index 6bb96f83..0935fb2f 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseReqBuilderJSONP.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseReqBuilderJSONP.java
@@ -55,7 +55,7 @@ public class PromiseReqBuilderJSONP extends DeferredPromiseImpl {
// jQuery allows a parameter callback=? to figure out the callback parameter
if (callbackParam == null) {
MatchResult tmp = callbackRegex.exec(url);
- if (tmp != null && tmp.getGroupCount() == 4) {
+ if (tmp != null && tmp.getGroupCount() == 4) {
callbackParam = tmp.getGroup(2);
url = tmp.getGroup(1) + tmp.getGroup(3);
}
@@ -75,7 +75,7 @@ public class PromiseReqBuilderJSONP extends DeferredPromiseImpl {
}
// Using jsni because method send in JsonpRequestBuilder is private
- private final native void send(JsonpRequestBuilder bld, String url, AsyncCallback<?> cb) /*-{
+ private native void send(JsonpRequestBuilder bld, String url, AsyncCallback<?> cb) /*-{
bld.@com.google.gwt.jsonp.client.JsonpRequestBuilder::send(Ljava/lang/String;Lcom/google/gwt/user/client/rpc/AsyncCallback;Z)(url,cb,false);
}-*/;
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Bezier.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Bezier.java
index cdc6da44..d167979e 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Bezier.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Bezier.java
@@ -26,42 +26,48 @@ package com.google.gwt.query.client.plugins.effects;
*/
public class Bezier {
- private double x1, y1 , x2, y2;
+ private double x1, y1, x2, y2;
public Bezier(double x1, double y1, double x2, double y2) {
- this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2;
+ this.x1 = x1;
+ this.y1 = y1;
+ this.x2 = x2;
+ this.y2 = y2;
}
private double a(double a1, double a2) {
return 1.0 - 3.0 * a2 + 3.0 * a1;
}
+
private double b(double a1, double a2) {
return 3.0 * a2 - 6.0 * a1;
}
- private double c(double a1){
+
+ private double c(double a1) {
return 3.0 * a1;
}
private double calcBezier(double t, double a1, double a2) {
- return ((a(a1, a2)*t + b(a1, a2))*t + c(a1))*t;
+ return ((a(a1, a2) * t + b(a1, a2)) * t + c(a1)) * t;
}
private double calcSlope(double t, double a1, double a2) {
- return 3.0 * a(a1, a2)*t*t + 2.0 * b(a1, a2) * t + c(a1);
+ return 3.0 * a(a1, a2) * t * t + 2.0 * b(a1, a2) * t + c(a1);
}
private double getTForX(double x) {
double t = x;
for (double i = 0; i < 4; ++i) {
double currentSlope = calcSlope(t, x1, x2);
- if (currentSlope == 0.0) return t;
+ if (currentSlope == 0.0)
+ return t;
double currentX = calcBezier(t, x1, x2) - x;
t -= currentX / currentSlope;
}
return t;
}
- public double f (double x) {
+ public double f(double x) {
return calcBezier(getTForX(x), y1, y2);
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/ClipAnimation.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/ClipAnimation.java
index deead04d..627c0b47 100755
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/ClipAnimation.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/ClipAnimation.java
@@ -48,8 +48,8 @@ public class ClipAnimation extends PropertiesAnimation {
BIDIRECTIONAL, HORIZONTAL, VERTICAL
}
- private static final String[] attrsToSave = new String[]{
- "position", "overflow", "visibility", "white-space", "top", "left", "width", "height"};
+ private static final String[] attrsToSave = new String[] {
+ "position", "overflow", "visibility", "white-space", "top", "left", "width", "height"};
private Action action;
private Corner corner;
@@ -120,7 +120,7 @@ public class ClipAnimation extends PropertiesAnimation {
if (action == null) {
return;
}
- currentAction = action != Action.TOGGLE ? action : hidden ? Action.SHOW : Action.HIDE;
+ currentAction = action != Action.TOGGLE ? action : hidden ? Action.SHOW : Action.HIDE;
g.saveCssAttrs(attrsToSave);
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..b81a9de9 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
@@ -29,7 +29,7 @@ import com.google.gwt.regexp.shared.RegExp;
public class Fx {
/**
- * Public variable to enable/disable effects
+ * Public variable to enable/disable effects.
*/
public static boolean off = false;
@@ -64,7 +64,7 @@ public class Fx {
public static class ColorFx extends Fx {
/**
- * Specific class handle specific borderColor shortcut properties
+ * Specific class handle specific borderColor shortcut properties.
*/
public static class BorderColorFx extends ColorFx {
@@ -81,10 +81,10 @@ public class Fx {
endColor = parseColor(endColorString);
startColors = JsNamedArray.create();
- GQuery $e = GQuery.$(e);
+ GQuery g = GQuery.$(e);
for (String border : borderColorProperties) {
- int[] startColor = parseColor($e.css(border, true));
+ int[] startColor = parseColor(g.css(border, true));
startColors.put(border, startColor);
}
}
@@ -100,60 +100,62 @@ public class Fx {
}
// hexadecimal regex
- public static RegExp REGEX_HEX_COLOR_PATTERN = RegExp.compile("#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})");
+ public static RegExp REGEX_HEX_COLOR_PATTERN = RegExp
+ .compile("#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})");
private static JsNamedArray<int[]> htmlColorToRgb;
// rgb and rgba regex
public static RegExp REGEX_RGB_COLOR_PATTERN =
- RegExp.compile("rgba?\\(\\s*([0-9]{1,3}%?)\\s*,\\s*([0-9]{1,3}%?)\\s*,\\s*([0-9]{1,3}%?).*\\)$");
+ RegExp
+ .compile("rgba?\\(\\s*([0-9]{1,3}%?)\\s*,\\s*([0-9]{1,3}%?)\\s*,\\s*([0-9]{1,3}%?).*\\)$");
static {
htmlColorToRgb = JsNamedArray.create();
- htmlColorToRgb.put("white", new int[]{255, 255, 255});
- htmlColorToRgb.put("aqua", new int[]{0, 255, 255});
- htmlColorToRgb.put("azure", new int[]{240, 255, 255});
- htmlColorToRgb.put("beige", new int[]{245, 245, 220});
- htmlColorToRgb.put("black", new int[]{0, 0, 0});
- htmlColorToRgb.put("blue", new int[]{0, 0, 255});
- htmlColorToRgb.put("brown", new int[]{165, 42, 42});
- htmlColorToRgb.put("cyan", new int[]{0, 255, 255});
- htmlColorToRgb.put("darkblue", new int[]{0, 0, 139});
- htmlColorToRgb.put("darkcyan", new int[]{0, 139, 139});
- htmlColorToRgb.put("darkgrey", new int[]{169, 169, 169});
- htmlColorToRgb.put("darkgreen", new int[]{0, 100, 0});
- htmlColorToRgb.put("darkkhaki", new int[]{189, 183, 107});
- htmlColorToRgb.put("darkmagenta", new int[]{139, 0, 139});
- htmlColorToRgb.put("darkolivegreen", new int[]{85, 107, 47});
- htmlColorToRgb.put("darkorange", new int[]{255, 140, 0});
- htmlColorToRgb.put("darkorchid", new int[]{153, 50, 204});
- htmlColorToRgb.put("darkred", new int[]{139, 0, 0});
- htmlColorToRgb.put("darksalmon", new int[]{233, 150, 122});
- htmlColorToRgb.put("darkviolet", new int[]{148, 0, 211});
- htmlColorToRgb.put("fuchsia", new int[]{255, 0, 255});
- htmlColorToRgb.put("gold", new int[]{255, 215, 0});
- htmlColorToRgb.put("green", new int[]{0, 128, 0});
- htmlColorToRgb.put("indigo", new int[]{75, 0, 130});
- htmlColorToRgb.put("khaki", new int[]{240, 230, 140});
- htmlColorToRgb.put("lightblue", new int[]{173, 216, 230});
- htmlColorToRgb.put("lightcyan", new int[]{224, 255, 255});
- htmlColorToRgb.put("lightgreen", new int[]{144, 238, 144});
- htmlColorToRgb.put("lightgrey", new int[]{211, 211, 211});
- htmlColorToRgb.put("lightpink", new int[]{255, 182, 193});
- htmlColorToRgb.put("lightyellow", new int[]{255, 255, 224});
- htmlColorToRgb.put("lime", new int[]{0, 255, 0});
- htmlColorToRgb.put("magenta", new int[]{255, 0, 255});
- htmlColorToRgb.put("maroon", new int[]{128, 0, 0});
- htmlColorToRgb.put("navy", new int[]{0, 0, 128});
- htmlColorToRgb.put("olive", new int[]{128, 128, 0});
- htmlColorToRgb.put("orange", new int[]{255, 165, 0});
- htmlColorToRgb.put("pink", new int[]{255, 192, 203});
- htmlColorToRgb.put("purple", new int[]{128, 0, 128});
- htmlColorToRgb.put("violet", new int[]{128, 0, 128});
- htmlColorToRgb.put("red", new int[]{255, 0, 0});
- htmlColorToRgb.put("silver", new int[]{192, 192, 192});
- htmlColorToRgb.put("white", new int[]{255, 255, 255});
- htmlColorToRgb.put("yellow", new int[]{255, 255, 0});
+ htmlColorToRgb.put("white", new int[] {255, 255, 255});
+ htmlColorToRgb.put("aqua", new int[] {0, 255, 255});
+ htmlColorToRgb.put("azure", new int[] {240, 255, 255});
+ htmlColorToRgb.put("beige", new int[] {245, 245, 220});
+ htmlColorToRgb.put("black", new int[] {0, 0, 0});
+ htmlColorToRgb.put("blue", new int[] {0, 0, 255});
+ htmlColorToRgb.put("brown", new int[] {165, 42, 42});
+ htmlColorToRgb.put("cyan", new int[] {0, 255, 255});
+ htmlColorToRgb.put("darkblue", new int[] {0, 0, 139});
+ htmlColorToRgb.put("darkcyan", new int[] {0, 139, 139});
+ htmlColorToRgb.put("darkgrey", new int[] {169, 169, 169});
+ htmlColorToRgb.put("darkgreen", new int[] {0, 100, 0});
+ htmlColorToRgb.put("darkkhaki", new int[] {189, 183, 107});
+ htmlColorToRgb.put("darkmagenta", new int[] {139, 0, 139});
+ htmlColorToRgb.put("darkolivegreen", new int[] {85, 107, 47});
+ htmlColorToRgb.put("darkorange", new int[] {255, 140, 0});
+ htmlColorToRgb.put("darkorchid", new int[] {153, 50, 204});
+ htmlColorToRgb.put("darkred", new int[] {139, 0, 0});
+ htmlColorToRgb.put("darksalmon", new int[] {233, 150, 122});
+ htmlColorToRgb.put("darkviolet", new int[] {148, 0, 211});
+ htmlColorToRgb.put("fuchsia", new int[] {255, 0, 255});
+ htmlColorToRgb.put("gold", new int[] {255, 215, 0});
+ htmlColorToRgb.put("green", new int[] {0, 128, 0});
+ htmlColorToRgb.put("indigo", new int[] {75, 0, 130});
+ htmlColorToRgb.put("khaki", new int[] {240, 230, 140});
+ htmlColorToRgb.put("lightblue", new int[] {173, 216, 230});
+ htmlColorToRgb.put("lightcyan", new int[] {224, 255, 255});
+ htmlColorToRgb.put("lightgreen", new int[] {144, 238, 144});
+ htmlColorToRgb.put("lightgrey", new int[] {211, 211, 211});
+ htmlColorToRgb.put("lightpink", new int[] {255, 182, 193});
+ htmlColorToRgb.put("lightyellow", new int[] {255, 255, 224});
+ htmlColorToRgb.put("lime", new int[] {0, 255, 0});
+ htmlColorToRgb.put("magenta", new int[] {255, 0, 255});
+ htmlColorToRgb.put("maroon", new int[] {128, 0, 0});
+ htmlColorToRgb.put("navy", new int[] {0, 0, 128});
+ htmlColorToRgb.put("olive", new int[] {128, 128, 0});
+ htmlColorToRgb.put("orange", new int[] {255, 165, 0});
+ htmlColorToRgb.put("pink", new int[] {255, 192, 203});
+ htmlColorToRgb.put("purple", new int[] {128, 0, 128});
+ htmlColorToRgb.put("violet", new int[] {128, 0, 128});
+ htmlColorToRgb.put("red", new int[] {255, 0, 0});
+ htmlColorToRgb.put("silver", new int[] {192, 192, 192});
+ htmlColorToRgb.put("white", new int[] {255, 255, 255});
+ htmlColorToRgb.put("yellow", new int[] {255, 255, 0});
}
protected int[] endColor;
@@ -218,7 +220,6 @@ public class Fx {
color += color;
}
result[i] = Math.max(0, Math.min(255, Integer.parseInt(color, 16)));
-
}
return result;
@@ -246,7 +247,6 @@ public class Fx {
}
return result;
}
-
}
public String cssprop;
@@ -271,15 +271,15 @@ public class Fx {
public void applyValue(GQuery g, double progress) {
double ret = (start + ((end - start) * progress));
- String value = ("px".equals(unit) ? ((int) ret) : ret) + unit;
+ String val = ("px".equals(unit) ? ((int) ret) : ret) + unit;
if ("scrollTop".equals(cssprop)) {
- g.scrollTop((int)ret);
+ g.scrollTop((int) ret);
} else if ("scrollLeft".equals(cssprop)) {
- g.scrollLeft((int)ret);
+ g.scrollLeft((int) ret);
} else if (attribute != null) {
- g.attr(attribute, value);
+ g.attr(attribute, val);
} else {
- g.css(cssprop, value);
+ g.css(cssprop, val);
}
}
@@ -288,5 +288,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..e5a4c8f6 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
@@ -37,17 +37,18 @@ public class PropertiesAnimation extends GQAnimation {
/**
* Easing method to use.
*/
- public static interface Easing {
- public double interpolate(double progress);
+ public interface Easing {
+ double interpolate(double progress);
+
/**
* @deprecated use EasingCurve.linear instead
*/
- public Easing LINEAR = EasingCurve.linear;
+ Easing LINEAR = EasingCurve.linear;
/**
* @deprecated use EasingCurve.swing instead
*/
- public Easing SWING = EasingCurve.swing;
+ Easing SWING = EasingCurve.swing;
}
/**
@@ -73,71 +74,89 @@ public class PropertiesAnimation extends GQAnimation {
*
*/
public static enum EasingCurve implements Easing {
- linear (0, 0, 1, 1) {
- public double interpolate(double p){return p;}
- public String toString() {return "linear";}
- },
- ease (0.25, 0.1, 0.25, 1) {
- public String toString() {return "ease";}
- },
- easeIn (0.42, 0, 1, 1) {
- public String toString() {return "ease-in";}
- },
- easeOut (0, 0, 0.58, 1) {
- public String toString() {return "ease-out";}
- },
- easeInOut (0.42, 0, 0.58, 1) {
- public String toString() {return "ease-in-out";}
- },
- snap (0,1,.5,1),
- swing (.02,.01,.47,1),
- easeInCubic (.550,.055,.675,.190),
- easeOutCubic (.215,.61,.355,1),
- easeInOutCubic (.645,.045,.355,1),
- easeInCirc (.6,.04,.98,.335),
- easeOutCirc (.075,.82,.165,1),
- easeInOutCirc (.785,.135,.15,.86),
- easeInExpo (.95,.05,.795,.035),
- easeOutExpo (.19,1,.22,1),
- easeInOutExpo (1,0,0,1),
- easeInQuad (.55,.085,.68,.53),
- easeOutQuad (.25,.46,.45,.94),
- easeInOutQuad (.455,.03,.515,.955),
- easeInQuart (.895,.03,.685,.22),
- easeOutQuart (.165,.84,.44,1),
- easeInOutQuart (.77,0,.175,1),
- easeInQuint (.755,.05,.855,.06),
- easeOutQuint (.23,1,.32,1),
- easeInOutQuint (.86,0,.07,1),
- easeInSine (.47,0,.745,.715),
- easeOutSine (.39,.575,.565,1),
- easeInOutSine (.445,.05,.55,.95),
- easeInBack (.6,-.28,.735,.045),
- easeOutBack (.175, .885,.32,1.275),
- easeInOutBack (.68,-.55,.265,1.55),
- custom(0, 0, 1, 1);
-
- private Bezier c = new Bezier(0, 0, 1, 1);
- EasingCurve(double x1, double y1, double x2, double y2) {
- with(x1, y1, x2, y2);
- }
- public Easing with(double x1, double y1, double x2, double y2) {
- c = new Bezier(x1, y1, x2, y2);
- return this;
- }
- public double interpolate(double progress) {
- return c.f(progress);
- }
- public String toString() {
+ linear(0, 0, 1, 1) {
+ public double interpolate(double p) {
+ return p;
+ }
+
+ public String toString() {
+ return "linear";
+ }
+ },
+ ease(0.25, 0.1, 0.25, 1) {
+ public String toString() {
+ return "ease";
+ }
+ },
+ easeIn(0.42, 0, 1, 1) {
+ public String toString() {
+ return "ease-in";
+ }
+ },
+ easeOut(0, 0, 0.58, 1) {
+ public String toString() {
+ return "ease-out";
+ }
+ },
+ easeInOut(0.42, 0, 0.58, 1) {
+ public String toString() {
+ return "ease-in-out";
+ }
+ },
+ snap(0, 1, .5, 1),
+ swing(.02, .01, .47, 1),
+ easeInCubic(.550, .055, .675, .190),
+ easeOutCubic(.215, .61, .355, 1),
+ easeInOutCubic(.645, .045, .355, 1),
+ easeInCirc(.6, .04, .98, .335),
+ easeOutCirc(.075, .82, .165, 1),
+ easeInOutCirc(.785, .135, .15, .86),
+ easeInExpo(.95, .05, .795, .035),
+ easeOutExpo(.19, 1, .22, 1),
+ easeInOutExpo(1, 0, 0, 1),
+ easeInQuad(.55, .085, .68, .53),
+ easeOutQuad(.25, .46, .45, .94),
+ easeInOutQuad(.455, .03, .515, .955),
+ easeInQuart(.895, .03, .685, .22),
+ easeOutQuart(.165, .84, .44, 1),
+ easeInOutQuart(.77, 0, .175, 1),
+ easeInQuint(.755, .05, .855, .06),
+ easeOutQuint(.23, 1, .32, 1),
+ easeInOutQuint(.86, 0, .07, 1),
+ easeInSine(.47, 0, .745, .715),
+ easeOutSine(.39, .575, .565, 1),
+ easeInOutSine(.445, .05, .55, .95),
+ easeInBack(.6, -.28, .735, .045),
+ easeOutBack(.175, .885, .32, 1.275),
+ easeInOutBack(.68, -.55, .265, 1.55),
+ custom(0, 0, 1, 1);
+
+ private Bezier c = new Bezier(0, 0, 1, 1);
+
+ EasingCurve(double x1, double y1, double x2, double y2) {
+ with(x1, y1, x2, y2);
+ }
+
+ public Easing with(double x1, double y1, double x2, double y2) {
+ c = new Bezier(x1, y1, x2, y2);
+ return this;
+ }
+
+ public double interpolate(double progress) {
+ return c.f(progress);
+ }
+
+ public String toString() {
return "cubic-bezier(" + c + ")";
- }
- }
+ }
+ }
- protected static final String[] ATTRS_TO_SAVE = new String[]{"overflow"};
+ protected static final String[] ATTRS_TO_SAVE = new String[] {"overflow"};
private static final RegExp REGEX_NUMBER_UNIT = RegExp.compile("^([0-9+-.]+)(.*)?$");
- protected static final RegExp REGEX_SYMBOL_NUMBER_UNIT = RegExp.compile("^([+-]=)?([0-9+-.]+)(.*)?$");
+ protected static final RegExp REGEX_SYMBOL_NUMBER_UNIT = RegExp
+ .compile("^([+-]=)?([0-9+-.]+)(.*)?$");
protected static final RegExp REGEX_NON_PIXEL_ATTRS =
RegExp.compile("z-?index|font-?weight|opacity|zoom|line-?height|scale|rotation|^\\$", "i");
@@ -146,7 +165,7 @@ public class PropertiesAnimation extends GQAnimation {
private static final RegExp REGEX_BORDERCOLOR = RegExp.compile("^bordercolor$", "i");
- private static final RegExp REGEX_BACKGROUNDCOLOR =RegExp.compile("^backgroundcolor$", "i");
+ private static final RegExp REGEX_BACKGROUNDCOLOR = RegExp.compile("^backgroundcolor$", "i");
public static Fx computeFxProp(Element e, String key, String val,
boolean hidden) {
@@ -170,7 +189,8 @@ public class PropertiesAnimation extends GQAnimation {
// transparent)
Element current = e;
- while ((initialColor == null || initialColor.length() == 0 || initialColor.equals("transparent"))
+ while ((initialColor == null || initialColor.length() == 0 || initialColor
+ .equals("transparent"))
&& current != null) {
initialColor = GQuery.$(current).css(key, false);
current = !"body".equalsIgnoreCase(current.getTagName())
@@ -212,10 +232,10 @@ public class PropertiesAnimation extends GQAnimation {
String attr = g.attr(rkey);
MatchResult parts = REGEX_NUMBER_UNIT.exec(attr);
if (parts != null) {
- String $1 = parts.getGroup(1);
- String $2 = parts.getGroup(2);
- cur = Double.parseDouble($1);
- unit = $2 == null ? "" : $2;
+ String p1 = parts.getGroup(1);
+ String p2 = parts.getGroup(2);
+ cur = Double.parseDouble(p1);
+ unit = p2 == null ? "" : p2;
} else {
cur = g.cur(key, true);
key = rkey;
@@ -241,26 +261,26 @@ public class PropertiesAnimation extends GQAnimation {
MatchResult parts = REGEX_SYMBOL_NUMBER_UNIT.exec(val);
if (parts != null) {
- String $1 = parts.getGroup(1);
- String $2 = parts.getGroup(2);
- String $3 = parts.getGroup(3);
- end = Double.parseDouble($2);
+ String p1 = parts.getGroup(1);
+ String p2 = parts.getGroup(2);
+ String p3 = parts.getGroup(3);
+ end = Double.parseDouble(p2);
if (rkey == null) {
unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : //
- $3 == null || $3.isEmpty() ? "px" : $3;
+ p3 == null || p3.isEmpty() ? "px" : p3;
if (!"px".equals(unit)) {
double to = end == 0 ? 1 : end;
g.css(key, to + unit);
start = to * start / g.cur(key, true);
g.css(key, start + unit);
}
- } else if ($3 != null && !$3.isEmpty()) {
- unit = $3;
+ } else if (p3 != null && !p3.isEmpty()) {
+ unit = p3;
}
- if ($1 != null && !$1.isEmpty()) {
- end = (("-=".equals($1) ? -1 : 1) * end) + start;
+ if (p1 != null && !p1.isEmpty()) {
+ end = (("-=".equals(p1) ? -1 : 1) * end) + start;
}
}
}
@@ -298,7 +318,7 @@ public class PropertiesAnimation extends GQAnimation {
@Override
public void onCancel() {
Boolean jumpToEnd = Effects.$(e).data(Effects.JUMP_TO_END, Boolean.class);
- if (jumpToEnd != null && jumpToEnd){
+ if (jumpToEnd != null && jumpToEnd) {
onComplete();
} else {
g.dequeue();
@@ -365,5 +385,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..cefedceb 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,10 +43,16 @@ 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.
*
- * It is inspired on jquery.transit (http://github.com/rstacruz/jquery.transit)
+ * It is inspired on jquery.transit (http://github.com/rstacruz/jquery.transit).
*
* Usage examples:
* <pre>
@@ -268,7 +268,7 @@ public class Transitions extends GQuery {
t.setFromString(prop, value);
getStyleImpl().setStyleProperty(e, transform, t.toString());
}
- } else if (!invalidTransitionNamesRegex.test(prop)){
+ } else if (!invalidTransitionNamesRegex.test(prop)) {
super.css(prop, value);
}
return this;
@@ -297,7 +297,7 @@ public class Transitions extends GQuery {
private Transform getTransform(Element e, String initial) {
Transform t = data(e, TRANSFORM);
- if (t == null || initial != null && !initial.isEmpty() ) {
+ if (t == null || initial != null && !initial.isEmpty()) {
t = new Transform(initial);
data(e, TRANSFORM, t);
}
@@ -334,12 +334,12 @@ public class Transitions extends GQuery {
final double queuedAt = delay > 0 ? Duration.currentTimeMillis() : 0;
// Use gQuery queue, so as we can chain transitions, animations etc.
- queue(new Function(){
+ queue(new Function() {
public void f() {
// This is called once per element
final String oldTransitionValue = $(this).css(transition);
// Recompute delay based on the time spent in the queue
- int d = Math.max(0, delay - (int)(Duration.currentTimeMillis() - queuedAt));
+ int d = Math.max(0, delay - (int) (Duration.currentTimeMillis() - queuedAt));
// Generate transition value
String attribs = duration + "ms" + " " + ease + " " + d + "ms";
String newTransitionValue = "";
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..4636b12e 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
@@ -30,10 +30,13 @@ import com.google.gwt.regexp.shared.MatchResult;
/**
* Animation effects on any numeric CSS3 property or transformation
- * using CSS3 transitions
+ * using CSS3 transitions.
*/
public class TransitionsAnimation extends PropertiesAnimation {
+ /**
+ * TransitionAnimation with Clip capabilities.
+ */
public static class TransitionsClipAnimation extends TransitionsAnimation {
private Action action;
@@ -82,8 +85,8 @@ public class TransitionsAnimation extends PropertiesAnimation {
int bit = currentAction == Action.HIDE ? 1 : 0;
String originX = "left", originY = "top";
- int scaleXini = 0^bit, scaleYini = scaleXini;
- int scaleXend = 1^bit, scaleYend = scaleXend;
+ int scaleXini = 0 ^ bit, scaleYini = scaleXini;
+ int scaleXend = 1 ^ bit, scaleYend = scaleXend;
if (direction == Direction.VERTICAL) {
scaleXini = scaleXend = 1;
@@ -171,7 +174,7 @@ public class TransitionsAnimation extends PropertiesAnimation {
trsStart = "" + st;
double en = Double.parseDouble(trsEnd);
- trsEnd = "" + (st + n*en);
+ trsEnd = "" + (st + n * en);
}
// Deal with non px units like "%"
@@ -183,7 +186,6 @@ public class TransitionsAnimation extends PropertiesAnimation {
trsStart = "" + start;
g.css(key, start + unit);
}
-
} else {
trsStart = "";
trsEnd = val;
@@ -208,7 +210,7 @@ public class TransitionsAnimation extends PropertiesAnimation {
private Properties getFxProperties(boolean isStart) {
Properties p = $$();
for (int i = 0; i < effects.length(); i++) {
- TransitFx fx = (TransitFx)effects.get(i);
+ TransitFx fx = (TransitFx) effects.get(i);
String val = isStart ? fx.transitStart : fx.transitEnd;
if (!val.isEmpty()) {
p.set(fx.cssprop, val + fx.unit);
@@ -238,8 +240,10 @@ public class TransitionsAnimation extends PropertiesAnimation {
// Compute final properties
p = getFxProperties(false);
- g.transition(p, duration, easing, delay, new Function(){public void f() {
- onComplete();
- }});
+ g.transition(p, duration, easing, delay, new Function() {
+ public void f() {
+ onComplete();
+ }
+ });
}
}
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 a19142b8..7d88ac7c 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
@@ -40,7 +40,7 @@ import java.util.Map;
* This class implements an event queue instance for one Element. The queue instance is configured
* as the default event listener in GWT.
*
- * The reference to this queue is stored as a unique variable in the element's DOM
+ * The reference to this queue is stored as a unique variable in the element's DOM.
*
* The class takes care of calling the appropriate functions for each browser event and it also
* calls sinkEvents method.
@@ -49,7 +49,7 @@ import java.util.Map;
public class EventsListener implements EventListener {
/**
- * Used for simulating mouseenter and mouseleave events
+ * Used for simulating mouseenter and mouseleave events.
*/
private static class MouseSpecialEvent extends DefaultSpecialEvent {
public MouseSpecialEvent(final String type, String delegateType) {
@@ -72,7 +72,7 @@ public class EventsListener implements EventListener {
}
/**
- * Utility class to split a list of events with or without namespaces
+ * Utility class to split a list of events with or without namespaces.
*/
public static class EventName {
public final String nameSpace;
@@ -143,7 +143,6 @@ public class EventsListener implements EventListener {
return type != BITLESS && etype != BITLESS && (type & etype) != 0;
}
-
public boolean isTypeOf(String eName) {
return eventName != null && eventName.equalsIgnoreCase(eName);
}
@@ -194,7 +193,7 @@ public class EventsListener implements EventListener {
}
/**
- * Add a {@link BindFunction} for a specific css selector
+ * Add a {@link BindFunction} for a specific css selector.
*/
public void addBindFunctionForSelector(String cssSelector, BindFunction f) {
JsObjectArray<BindFunction> bindFunctions = bindFunctionBySelector.get(cssSelector);
@@ -277,7 +276,7 @@ public class EventsListener implements EventListener {
}
/**
- * Remove the BindFunction associated to this cssSelector
+ * Remove the BindFunction associated to this cssSelector.
*/
public void removeBindFunctionForSelector(String cssSelector, String nameSpace) {
if (nameSpace == null) {
@@ -301,12 +300,11 @@ public class EventsListener implements EventListener {
if (newFunctions.length() > 0) {
bindFunctionBySelector.put(cssSelector, newFunctions);
}
-
}
}
/**
- * Tell if no {@link BindFunction} are linked to this object
+ * Tell if no {@link BindFunction} are linked to this object.
*
* @return
*/
@@ -322,7 +320,7 @@ public class EventsListener implements EventListener {
/**
* Return the element whose the listener fired last. It represent the context element where the
- * {@link LiveBindFunction} was binded
+ * {@link LiveBindFunction} was binded.
*
*/
private Element getCurrentEventTarget(Event e) {
@@ -336,7 +334,7 @@ public class EventsListener implements EventListener {
}
/**
- * Return the element that was the actual target of the element
+ * Return the element that was the actual target of the element.
*/
private Element getEventTarget(Event e) {
EventTarget eventTarget = e.getEventTarget();
@@ -347,7 +345,6 @@ public class EventsListener implements EventListener {
return Element.as(eventTarget);
}
-
}
public static final String EVENT_DATA = "___event_datas";
@@ -404,7 +401,7 @@ public class EventsListener implements EventListener {
return elem.__gwtlistener;
}-*/;
- private static native void init(Element elem, EventsListener gqevent)/*-{
+ private static native void init(Element elem, EventsListener gqevent) /*-{
elem.__gwtlistener = @com.google.gwt.user.client.DOM::getEventListener(*)(elem);
elem.__gqueryevent = gqevent;
// Someone has reported that in IE the init can be called multiple times
@@ -532,7 +529,7 @@ public class EventsListener implements EventListener {
int eventbits, String eventName, String nameSpace) {
if (liveBindFunction != null) {
liveBindFunction.removeBindFunctionForSelector(cssSelector, nameSpace);
- if (liveBindFunction.isEmpty()){
+ if (liveBindFunction.isEmpty()) {
if (eventbits != BITLESS) {
liveBindFunctionByEventType.remove(eventbits);
} else {
@@ -738,7 +735,6 @@ public class EventsListener implements EventListener {
}
DOM.sinkEvents((com.google.gwt.user.client.Element) element, eventBits
| DOM.getEventsSunk((com.google.gwt.user.client.Element) element));
-
} else {
sinkBitlessEvent(element, eventName);
}
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 19f251b4..8493fd81 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
@@ -60,23 +60,23 @@ public class GqEvent extends Event {
}
/**
- * Return the original event (the one created by the browser)
+ * Return the original event (the one created by the browser).
*/
- public final native Event getOriginalEvent()/*-{
+ public final native Event getOriginalEvent() /*-{
return this.originalEvent;
}-*/;
- public final native void setCurrentElementTarget(Element e)/*-{
+ public final native void setCurrentElementTarget(Element e) /*-{
this.currentTarget = e;
- //ie don't have a currentEventTarget field on event
+ // ie don't have a currentEventTarget field on event
try{
@com.google.gwt.dom.client.DOMImplTrident::currentEventTarget = e;
}catch(e){}
}-*/;
/**
- * Tell whether ctrl or cmd key is pressed
+ * Tell whether ctrl or cmd key is pressed.
*
*/
public final boolean isMetaKeyPressed() {
@@ -84,13 +84,13 @@ public class GqEvent extends Event {
}
/**
- * The mouse position relative to the left edge of the document
+ * The mouse position relative to the left edge of the document.
*
*/
public final int pageX() {
- if (getTouches() != null && getTouches().length() > 0){
+ if (getTouches() != null && getTouches().length() > 0) {
return getTouches().get(0).getPageX();
- }else{
+ } else {
return getClientX() + GQuery.document.getScrollLeft();
}
}
@@ -100,9 +100,9 @@ public class GqEvent extends Event {
*
*/
public final int pageY() {
- if (getTouches() != null && getTouches().length() > 0){
+ if (getTouches() != null && getTouches().length() > 0) {
return getTouches().get(0).getPageY();
- }else{
+ } else {
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..fe99fb7b 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;
/**
@@ -32,15 +30,15 @@ public class ButtonWidgetFactory implements WidgetFactory<Button> {
Button button = new Button();
button.getElement().setInnerText(e.getInnerText());
- if ("button".equalsIgnoreCase(e.getTagName())){
- copyAttributes((ButtonElement)e.cast(), (ButtonElement)button.getElement().cast());
+ if ("button".equalsIgnoreCase(e.getTagName())) {
+ copyAttributes((ButtonElement) e.cast(), (ButtonElement) button.getElement().cast());
}
WidgetsUtils.replaceOrAppend(e, button);
return button;
}
- protected void copyAttributes(ButtonElement source,ButtonElement destination) {
+ protected void copyAttributes(ButtonElement source, ButtonElement destination) {
destination.setAccessKey(source.getAccessKey());
destination.setDisabled(source.isDisabled());
destination.setName(source.getName());
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..c9c54dd6 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
@@ -18,10 +18,12 @@ package com.google.gwt.query.client.plugins.widgets;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.HTMLPanel;
+/**
+ * HtmlPanelWidgetFactory.
+ */
public class HtmlPanelWidgetFactory implements WidgetFactory<HTMLPanel> {
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..a6e01fff 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
@@ -18,6 +18,9 @@ package com.google.gwt.query.client.plugins.widgets;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Label;
+/**
+ * LabelWidgetFactory.
+ */
public class LabelWidgetFactory implements WidgetFactory<Label> {
public Label create(Element e) {
@@ -26,5 +29,4 @@ public class LabelWidgetFactory implements WidgetFactory<Label> {
WidgetsUtils.replaceOrAppend(e, label);
return label;
}
-
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextAreaWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextAreaWidgetFactory.java
index 9200578e..fe5a9e5e 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextAreaWidgetFactory.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextAreaWidgetFactory.java
@@ -27,7 +27,7 @@ public class TextAreaWidgetFactory extends TextBoxBaseWidgetFactory<TextArea> {
@Override
protected void copyAttributes(Element src, Element dest) {
- TextAreaElement source= src.cast();
+ TextAreaElement source = src.cast();
TextAreaElement destination = dest.cast();
destination.setAccessKey(source.getAccessKey());
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextBoxBaseWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextBoxBaseWidgetFactory.java
index 55135962..4ca5179b 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextBoxBaseWidgetFactory.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextBoxBaseWidgetFactory.java
@@ -20,7 +20,9 @@ import com.google.gwt.dom.client.InputElement;
import com.google.gwt.user.client.ui.TextBoxBase;
/**
+ * TextBoxBaseWidgetFactory.
*
+ * @param <T>
*/
public abstract class TextBoxBaseWidgetFactory<T extends TextBoxBase>
implements WidgetFactory<T> {
@@ -39,7 +41,7 @@ public abstract class TextBoxBaseWidgetFactory<T extends TextBoxBase>
return (T) textBox;
}
- protected String getEquivalentTagName(){
+ protected String getEquivalentTagName() {
return "input";
}
@@ -50,7 +52,8 @@ public abstract class TextBoxBaseWidgetFactory<T extends TextBoxBase>
destination.setAccessKey(source.getAccessKey());
destination.setDefaultValue(source.getDefaultValue());
destination.setDisabled(source.isDisabled());
- if (source.getMaxLength() > 0) destination.setMaxLength(source.getMaxLength());
+ if (source.getMaxLength() > 0)
+ destination.setMaxLength(source.getMaxLength());
destination.setReadOnly(source.isReadOnly());
destination.setSize(source.getSize());
destination.setName(source.getName());
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetFactory.java
index 353befce..82ab0c54 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetFactory.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetFactory.java
@@ -19,11 +19,10 @@ import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Widget;
/**
- * Factory interface
- *
- * @param <W>
- * @param <O>
- */
- public interface WidgetFactory<W extends Widget> {
- public W create(Element e);
- }
+ * Factory interface.
+ *
+ * @param <W>
+ */
+public interface WidgetFactory<W extends Widget> {
+ W create(Element e);
+}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetInitializer.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetInitializer.java
index 47369c82..806edfcb 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetInitializer.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetInitializer.java
@@ -18,11 +18,16 @@ package com.google.gwt.query.client.plugins.widgets;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Widget;
+/**
+ * WidgetInitializer.
+ *
+ * @param <W>
+ */
public interface WidgetInitializer<W extends Widget> {
- /**
- * Initialize the newly created widget <code>w</code>. The element <code>e</code>
- * is the element used to construct the widget.
- *
- */
- void initialize(W w, Element e);
- }
+ /**
+ * Initialize the newly created widget <code>w</code>. The element <code>e</code>
+ * is the element used to construct the widget.
+ *
+ */
+ void initialize(W w, Element e);
+}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsHtmlPanel.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsHtmlPanel.java
index 657f1ff6..d216df1e 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsHtmlPanel.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsHtmlPanel.java
@@ -60,9 +60,9 @@ public class WidgetsHtmlPanel extends HTMLPanel {
}
/**
- * use jsni to access private attribute
+ * use jsni to access private attribute.
*/
- private native void setElementImpl(Element e)/*-{
+ private native void setElementImpl(Element e) /*-{
this.@com.google.gwt.user.client.ui.UIObject::element = e;
}-*/;
@@ -110,7 +110,6 @@ public class WidgetsHtmlPanel extends HTMLPanel {
if (RootPanel.isInDetachList(w)) {
RootPanel.detachNow(w);
}
-
} else if (parent instanceof HTMLPanel) {
WidgetsUtils.doLogicalDetachFromHtmlPanel(w);
} else {
@@ -126,6 +125,5 @@ public class WidgetsHtmlPanel extends HTMLPanel {
}
adopt(w);
-
}
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java
index 200cb8c9..c48082c7 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java
@@ -17,8 +17,6 @@ package com.google.gwt.query.client.plugins.widgets;
import static com.google.gwt.query.client.GQuery.$;
-import java.util.Iterator;
-
import com.google.gwt.dom.client.BodyElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
@@ -35,28 +33,33 @@ import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.WidgetCollection;
+import java.util.Iterator;
+
+/**
+ * WidgetsUtils.
+ */
public class WidgetsUtils {
static final String[] appendingTags = {
- "td", "th", "li"};
+ "td", "th", "li"};
/**
* Append a widget to a dom element, and hide it.
* Element classes will be copied to the new widget.
*/
- public static void hideAndAfter(Element e, Widget widget) {
- assert e != null && widget != null;
- if ($(e).widget() != null && $(e).widget().isAttached()) {
- replaceWidget($(e).widget(), widget, false);
- } else {
- detachWidget(widget);
- hideAndAfter(e, widget.getElement());
- attachWidget(widget, getFirstParentWidget(widget));
- }
- }
+ public static void hideAndAfter(Element e, Widget widget) {
+ assert e != null && widget != null;
+ if ($(e).widget() != null && $(e).widget().isAttached()) {
+ replaceWidget($(e).widget(), widget, false);
+ } else {
+ detachWidget(widget);
+ hideAndAfter(e, widget.getElement());
+ attachWidget(widget, getFirstParentWidget(widget));
+ }
+ }
/**
- * Test if the tag name of the element is one of tag names given in parameter
+ * Test if the tag name of the element is one of tag names given in parameter.
*
* @param tagNames
* @return
@@ -76,205 +79,202 @@ public class WidgetsUtils {
regExp.append(")$");
return e.getTagName().toUpperCase().matches(regExp.toString());
-
}
- /**
- * Replace a dom element by a widget.
- * Old element classes will be copied to the new widget.
- */
- public static void replaceOrAppend(Element e, Widget widget) {
- assert e != null && widget != null;
- if ($(e).widget() != null && $(e).widget().isAttached()) {
- replaceWidget($(e).widget(), widget, true);
- } else {
- detachWidget(widget);
- replaceOrAppend(e, widget.getElement());
- attachWidget(widget, getFirstParentWidget(widget));
- }
- }
+ /**
+ * Replace a dom element by a widget.
+ * Old element classes will be copied to the new widget.
+ */
+ public static void replaceOrAppend(Element e, Widget widget) {
+ assert e != null && widget != null;
+ if ($(e).widget() != null && $(e).widget().isAttached()) {
+ replaceWidget($(e).widget(), widget, true);
+ } else {
+ detachWidget(widget);
+ replaceOrAppend(e, widget.getElement());
+ attachWidget(widget, getFirstParentWidget(widget));
+ }
+ }
- private static Widget getFirstParentWidget(Widget w) {
- Element e = w.getElement().getParentElement();
- BodyElement body = Document.get().getBody();
- while ((e != null) && (body != e)) {
- if (Event.getEventListener(e) != null) {
- Widget p = $(e).widget();
- if (p != null){
- return p;
- }
- }
- e = e.getParentElement();
- }
- return null;
- }
+ private static Widget getFirstParentWidget(Widget w) {
+ Element e = w.getElement().getParentElement();
+ BodyElement body = Document.get().getBody();
+ while ((e != null) && (body != e)) {
+ if (Event.getEventListener(e) != null) {
+ Widget p = $(e).widget();
+ if (p != null) {
+ return p;
+ }
+ }
+ e = e.getParentElement();
+ }
+ return null;
+ }
- private static void hideAndAfter(Element oldElement, Element newElement) {
- assert oldElement != null && newElement != null;
- GQuery.$(oldElement).hide().after(newElement);
- String c = oldElement.getClassName();
- if (!c.isEmpty()) {
- newElement.addClassName(c);
- }
- }
+ private static void hideAndAfter(Element oldElement, Element newElement) {
+ assert oldElement != null && newElement != null;
+ GQuery.$(oldElement).hide().after(newElement);
+ String c = oldElement.getClassName();
+ if (!c.isEmpty()) {
+ newElement.addClassName(c);
+ }
+ }
- /**
+ /**
* If the <code>oldElement</code> is a td, th, li tags, the new element will replaced its content.
* In other cases, the <code>oldElement</code> will be replaced by the <code>newElement</code>
* and the old element classes will be copied to the new element.
*/
- private static void replaceOrAppend(Element oldElement, Element newElement) {
+ private static void replaceOrAppend(Element oldElement, Element newElement) {
assert oldElement != null && newElement != null;
- if(matchesTags(oldElement, appendingTags)){
+ if (matchesTags(oldElement, appendingTags)) {
GQuery.$(oldElement).html("").append(newElement);
- }else{
+ } else {
GQuery.$(oldElement).replaceWith(newElement);
- //copy class
+ // copy class
String c = oldElement.getClassName();
if (!c.isEmpty()) {
newElement.addClassName(c);
}
- //copy id
+ // copy id
newElement.setId(oldElement.getId());
- //ensure no duplicate id
+ // ensure no duplicate id
oldElement.setId("");
-
}
- }
+ }
- private static void replaceWidget(Widget oldWidget, Widget newWidget, boolean remove) {
- Widget parent = oldWidget.getParent();
- boolean removed = false;
- // TODO: handle tables
- if (parent instanceof HTMLPanel) {
- ((HTMLPanel) parent).addAndReplaceElement(newWidget,
- (com.google.gwt.dom.client.Element)oldWidget.getElement());
- if (!remove) {
- $(newWidget).before($(oldWidget));
- }
- removed = true;
- } else if (parent instanceof ComplexPanel) {
- ((ComplexPanel) parent).add(newWidget);
- } else if (parent instanceof SimplePanel) {
- ((SimplePanel) parent).setWidget(newWidget);
- } else if (parent instanceof Panel) {
- ((Panel) parent).add(newWidget);
- } else {
- assert false : "Can not replace an attached widget whose parent is a " + parent.getClass().getName();
- }
- if (remove && !removed && oldWidget.isAttached()) {
- oldWidget.removeFromParent();
- } else {
- oldWidget.setVisible(false);
- }
- }
+ private static void replaceWidget(Widget oldWidget, Widget newWidget, boolean remove) {
+ Widget parent = oldWidget.getParent();
+ boolean removed = false;
+ // TODO: handle tables
+ if (parent instanceof HTMLPanel) {
+ ((HTMLPanel) parent).addAndReplaceElement(newWidget,
+ (com.google.gwt.dom.client.Element) oldWidget.getElement());
+ if (!remove) {
+ $(newWidget).before($(oldWidget));
+ }
+ removed = true;
+ } else if (parent instanceof ComplexPanel) {
+ ((ComplexPanel) parent).add(newWidget);
+ } else if (parent instanceof SimplePanel) {
+ ((SimplePanel) parent).setWidget(newWidget);
+ } else if (parent instanceof Panel) {
+ ((Panel) parent).add(newWidget);
+ } else {
+ assert false : "Can not replace an attached widget whose parent is a "
+ + parent.getClass().getName();
+ }
+ if (remove && !removed && oldWidget.isAttached()) {
+ oldWidget.removeFromParent();
+ } else {
+ oldWidget.setVisible(false);
+ }
+ }
- /**
- * Attach a widget to the GWT widget list. Normally used when GQuery
- * creates widgets wrapping existing dom elements.
- * It does nothing if the widget is already attached to another widget.
- *
- * @param widget to attach
- * @param firstParentWidget the parent widget,
- * If it is null and it is not inside any other widget, we just add
- * the widget to the gwt detach list
- */
- public static void attachWidget(Widget widget, Widget firstParentWidget) {
- if (widget != null && widget.getParent() == null) {
- if (firstParentWidget == null) {
- firstParentWidget = getFirstParentWidget(widget);
- if (firstParentWidget == null) {
- RootPanel.detachOnWindowClose(widget);
- widgetOnAttach(widget);
- } else {
- attachWidget(widget, firstParentWidget);
- }
- } else if (firstParentWidget instanceof HTMLPanel) {
- HTMLPanel h = (HTMLPanel) firstParentWidget;
- Element p = widget.getElement().getParentElement();
- if (p != null) {
- h.add(widget, p);
- } else {
- h.add(widget);
- }
- } else if (firstParentWidget instanceof HasOneWidget) {
- ((HasOneWidget)firstParentWidget).setWidget(widget);
- } else if (firstParentWidget instanceof HasWidgets) {
- try {
- ((HasWidgets)firstParentWidget).add(widget);
- } catch (UnsupportedOperationException e) {
- // Some widgets like 'table' has no implementation of 'add(widget)'
- widgetSetParent(widget, firstParentWidget);
- }
- } else {
- widgetSetParent(widget, firstParentWidget);
- }
- }
- }
+ /**
+ * Attach a widget to the GWT widget list. Normally used when GQuery
+ * creates widgets wrapping existing dom elements.
+ * It does nothing if the widget is already attached to another widget.
+ *
+ * @param widget to attach
+ * @param firstParentWidget the parent widget,
+ * If it is null and it is not inside any other widget, we just add
+ * the widget to the gwt detach list
+ */
+ public static void attachWidget(Widget widget, Widget firstParentWidget) {
+ if (widget != null && widget.getParent() == null) {
+ if (firstParentWidget == null) {
+ firstParentWidget = getFirstParentWidget(widget);
+ if (firstParentWidget == null) {
+ RootPanel.detachOnWindowClose(widget);
+ widgetOnAttach(widget);
+ } else {
+ attachWidget(widget, firstParentWidget);
+ }
+ } else if (firstParentWidget instanceof HTMLPanel) {
+ HTMLPanel h = (HTMLPanel) firstParentWidget;
+ Element p = widget.getElement().getParentElement();
+ if (p != null) {
+ h.add(widget, p);
+ } else {
+ h.add(widget);
+ }
+ } else if (firstParentWidget instanceof HasOneWidget) {
+ ((HasOneWidget) firstParentWidget).setWidget(widget);
+ } else if (firstParentWidget instanceof HasWidgets) {
+ try {
+ ((HasWidgets) firstParentWidget).add(widget);
+ } catch (UnsupportedOperationException e) {
+ // Some widgets like 'table' has no implementation of 'add(widget)'
+ widgetSetParent(widget, firstParentWidget);
+ }
+ } else {
+ widgetSetParent(widget, firstParentWidget);
+ }
+ }
+ }
- /**
- * Remove a widget from the detach list
- */
- public static void detachWidget(final Widget widget) {
- if (widget != null) {
- widget.removeFromParent();
- }
- }
+ /**
+ * Remove a widget from the detach list.
+ */
+ public static void detachWidget(final Widget widget) {
+ if (widget != null) {
+ widget.removeFromParent();
+ }
+ }
- /**
- * This method detach a widget of its parent without doing a physical
- * detach (DOM manipulation)
- *
- * @param w
- */
- public static void doLogicalDetachFromHtmlPanel(Widget w) {
- Widget parent = w.getParent();
+ /**
+ * This method detach a widget of its parent without doing a physical
+ * detach (DOM manipulation).
+ */
+ public static void doLogicalDetachFromHtmlPanel(Widget w) {
+ Widget parent = w.getParent();
- if (parent instanceof HTMLPanel) {
- complexPanelGetChildren((HTMLPanel) parent).remove(w);
- widgetSetParent(w, null);
- } else{
- throw new IllegalStateException(
- "You can only use this method to detach a child from an HTMLPanel");
- }
- }
+ if (parent instanceof HTMLPanel) {
+ complexPanelGetChildren((HTMLPanel) parent).remove(w);
+ widgetSetParent(w, null);
+ } else {
+ throw new IllegalStateException(
+ "You can only use this method to detach a child from an HTMLPanel");
+ }
+ }
- /**
- * Return children of the first widget's panel
- */
- public static Iterator<Widget> getChildren(Widget w){
- if(w instanceof Panel){
- return ((Panel)w).iterator();
- }
- if(w instanceof Composite){
- return getChildren(compositeGetWidget((Composite)w));
- }
- return null;
- }
+ /**
+ * Return children of the first widget's panel.
+ */
+ public static Iterator<Widget> getChildren(Widget w) {
+ if (w instanceof Panel) {
+ return ((Panel) w).iterator();
+ }
+ if (w instanceof Composite) {
+ return getChildren(compositeGetWidget((Composite) w));
+ }
+ return null;
+ }
- /**
- * Return the first widget parent of the element, or null if it is not
- * attached to any widget yet.
- */
- private static Widget getFirstParentWidgetElement(Element element) {
- return $(element).parents().widget();
- }
+ /**
+ * Return the first widget parent of the element, or null if it is not
+ * attached to any widget yet.
+ */
+ private static Widget getFirstParentWidgetElement(Element element) {
+ return $(element).parents().widget();
+ }
- private static native void widgetOnAttach(Widget w) /*-{
- w.@com.google.gwt.user.client.ui.Widget::onAttach()();
- }-*/;
+ private static native void widgetOnAttach(Widget w) /*-{
+ w.@com.google.gwt.user.client.ui.Widget::onAttach()();
+ }-*/;
- private static native void widgetSetParent(Widget w, Widget p) /*-{
- w.@com.google.gwt.user.client.ui.Widget::setParent(Lcom/google/gwt/user/client/ui/Widget;)(p);
- }-*/;
+ private static native void widgetSetParent(Widget w, Widget p) /*-{
+ w.@com.google.gwt.user.client.ui.Widget::setParent(Lcom/google/gwt/user/client/ui/Widget;)(p);
+ }-*/;
- private static native Widget compositeGetWidget(Composite w) /*-{
- return w.@com.google.gwt.user.client.ui.Composite::getWidget()();
- }-*/;
+ private static native Widget compositeGetWidget(Composite w) /*-{
+ return w.@com.google.gwt.user.client.ui.Composite::getWidget()();
+ }-*/;
- private static native WidgetCollection complexPanelGetChildren(ComplexPanel w) /*-{
- return w.@com.google.gwt.user.client.ui.ComplexPanel::getChildren()();
- }-*/;
+ private static native WidgetCollection complexPanelGetChildren(ComplexPanel w) /*-{
+ return w.@com.google.gwt.user.client.ui.ComplexPanel::getChildren()();
+ }-*/;
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/linker/IFrameWithDocTypeLinker.java b/gwtquery-core/src/main/java/com/google/gwt/query/linker/IFrameWithDocTypeLinker.java
index bc5ff169..0f36edff 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/linker/IFrameWithDocTypeLinker.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/linker/IFrameWithDocTypeLinker.java
@@ -36,8 +36,10 @@ public class IFrameWithDocTypeLinker extends IFrameLinker {
@Deprecated
protected String getModulePrefix(TreeLogger logger, LinkerContext context,
String strongName) throws UnableToCompleteException {
- logger.log(Type.WARN,
- "GQuery IFrameWithDocTypeLinker is deprecated, remove <add-linker name=\"stddoctype\"/> from your module file");
+ logger
+ .log(
+ Type.WARN,
+ "GQuery IFrameWithDocTypeLinker is deprecated, remove <add-linker name=\"stddoctype\"/> from your module file");
return DOCTYPE + super.getModulePrefix(logger, context, strongName);
}
@@ -45,11 +47,11 @@ public class IFrameWithDocTypeLinker extends IFrameLinker {
@Deprecated
protected String getModulePrefix(TreeLogger logger, LinkerContext context,
String strongName, int numFragments) throws UnableToCompleteException {
- logger.log(Type.WARN,
- "GQuery IFrameWithDocTypeLinker is deprecated, remove <add-linker name=\"stddoctype\"/> from your module file");
+ logger
+ .log(
+ Type.WARN,
+ "GQuery IFrameWithDocTypeLinker is deprecated, remove <add-linker name=\"stddoctype\"/> from your module file");
return DOCTYPE
+ super.getModulePrefix(logger, context, strongName, numFragments);
-
}
}
-
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/BrowserGenerator.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/BrowserGenerator.java
index 861f6c19..91dd539d 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/BrowserGenerator.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/BrowserGenerator.java
@@ -15,8 +15,6 @@
*/
package com.google.gwt.query.rebind;
-import java.io.PrintWriter;
-
import com.google.gwt.core.ext.BadPropertyValueException;
import com.google.gwt.core.ext.Generator;
import com.google.gwt.core.ext.GeneratorContext;
@@ -28,12 +26,15 @@ import com.google.gwt.core.ext.typeinfo.TypeOracle;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
+import java.io.PrintWriter;
+
/**
- * Creates an implementation for {@link Browser}
+ * Creates an implementation for {@link Browser}.
*/
public class BrowserGenerator extends Generator {
@Override
- public String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException {
+ public String generate(TreeLogger logger, GeneratorContext context, String typeName)
+ throws UnableToCompleteException {
TypeOracle oracle = context.getTypeOracle();
PropertyOracle propOracle = context.getPropertyOracle();
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsniBundleGenerator.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsniBundleGenerator.java
index 4231fd2e..cfd9893e 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsniBundleGenerator.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/JsniBundleGenerator.java
@@ -15,16 +15,6 @@
*/
package com.google.gwt.query.rebind;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.InflaterInputStream;
-
-import org.apache.commons.io.output.ByteArrayOutputStream;
-
import com.google.gwt.core.ext.Generator;
import com.google.gwt.core.ext.GeneratorContext;
import com.google.gwt.core.ext.TreeLogger;
@@ -32,12 +22,21 @@ import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JMethod;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
-import com.google.gwt.query.client.builders.JsniBundle;
import com.google.gwt.query.client.builders.JsniBundle.LibrarySource;
import com.google.gwt.query.client.builders.JsniBundle.MethodSource;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.InflaterInputStream;
+
/**
* Generates an implementation of a user-defined interface <code>T</code> that
* extends {@link JsniBundle}.
@@ -61,7 +60,8 @@ public class JsniBundleGenerator extends Generator {
PrintWriter pw = context.tryCreate(logger, packageName, className);
if (pw != null) {
- ClassSourceFileComposerFactory fact = new ClassSourceFileComposerFactory(packageName, className);
+ ClassSourceFileComposerFactory fact =
+ new ClassSourceFileComposerFactory(packageName, className);
if (clazz.isInterface() != null) {
fact.addImplementedInterface(requestedClass);
} else {
@@ -93,14 +93,14 @@ public class JsniBundleGenerator extends Generator {
}
try {
// Read the javascript content
- String content = getContent(logger, packageName.replace(".", "/") , value);
+ String content = getContent(logger, packageName.replace(".", "/"), value);
// Adjust javascript so as we can introduce it in a JSNI comment block without
// breaking java syntax.
String jsni = parseJavascriptSource(content);
for (int i = 0; i < replace.length - 1; i += 2) {
- jsni = jsni.replaceAll(replace[i], replace[i+1]);
+ jsni = jsni.replaceAll(replace[i], replace[i + 1]);
}
pw.println(method.toString().replace("abstract", "native") + "/*-{");
@@ -109,7 +109,8 @@ public class JsniBundleGenerator extends Generator {
pw.println(postpend);
pw.println("}-*/;");
} catch (Exception e) {
- logger.log(TreeLogger.ERROR, "Error parsing javascript source: " + value + " "+ e.getMessage());
+ logger.log(TreeLogger.ERROR, "Error parsing javascript source: " + value + " "
+ + e.getMessage());
throw new UnableToCompleteException();
}
}
@@ -123,20 +124,23 @@ public class JsniBundleGenerator extends Generator {
/**
* Get the content of a javascript source. It supports remote sources hosted in CDN's.
*/
- private String getContent(TreeLogger logger, String path, String src) throws UnableToCompleteException {
+ private String getContent(TreeLogger logger, String path, String src)
+ throws UnableToCompleteException {
HttpURLConnection connection = null;
InputStream in = null;
try {
if (!src.matches("(?i)https?://.*")) {
String file = path + "/" + src;
- logger.log(TreeLogger.INFO, getClass().getSimpleName() + " - importing external javascript: " + file);
+ logger.log(TreeLogger.INFO, getClass().getSimpleName()
+ + " - importing external javascript: " + file);
in = this.getClass().getClassLoader().getResourceAsStream(file);
if (in == null) {
logger.log(TreeLogger.ERROR, "Unable to read javascript file: " + file);
}
} else {
- logger.log(TreeLogger.INFO, getClass().getSimpleName() + " - downloading external javascript: " + src);
+ logger.log(TreeLogger.INFO, getClass().getSimpleName()
+ + " - downloading external javascript: " + src);
URL url = new URL(src);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Accept-Encoding", "gzip, deflate");
@@ -146,7 +150,8 @@ public class JsniBundleGenerator extends Generator {
int status = connection.getResponseCode();
if (status != HttpURLConnection.HTTP_OK) {
- logger.log(TreeLogger.ERROR, "Server Error: " + status + " " + connection.getResponseMessage());
+ logger.log(TreeLogger.ERROR, "Server Error: " + status + " "
+ + connection.getResponseMessage());
throw new UnableToCompleteException();
}
@@ -191,8 +196,8 @@ public class JsniBundleGenerator extends Generator {
boolean isSingQuot = false;
boolean isDblQuot = false;
boolean isSlash = false;
- boolean isCComment=false;
- boolean isCPPComment=false;
+ boolean isCComment = false;
+ boolean isCPPComment = false;
boolean isRegex = false;
boolean isOper = false;
@@ -201,32 +206,36 @@ public class JsniBundleGenerator extends Generator {
Character last = 0;
Character prev = 0;
- for (int i = 0, l = js.length(); i < l ; i++) {
+ for (int i = 0, l = js.length(); i < l; i++) {
Character c = js.charAt(i);
String out = c.toString();
if (isJS) {
isDblQuot = c == '"';
- isSingQuot = c == '\'';
- isSlash = c == '/';
- isJS = !isDblQuot && !isSingQuot && !isSlash;
+ isSingQuot = c == '\'';
+ isSlash = c == '/';
+ isJS = !isDblQuot && !isSingQuot && !isSlash;
if (!isJS) {
out = tmp = "";
isCPPComment = isCComment = isRegex = false;
}
} else if (isSingQuot) {
isJS = !(isSingQuot = last == '\\' || c != '\'');
- if (isJS) out = escapeQuotedString(tmp, c);
- else tmp += c;
+ if (isJS)
+ out = escapeQuotedString(tmp, c);
+ else
+ tmp += c;
} else if (isDblQuot) {
isJS = !(isDblQuot = last == '\\' || c != '"');
- if (isJS) out = escapeQuotedString(tmp, c);
- else tmp += c;
+ if (isJS)
+ out = escapeQuotedString(tmp, c);
+ else
+ tmp += c;
} else if (isSlash) {
if (!isCPPComment && !isCComment && !isRegex && !isOper) {
isCPPComment = c == '/';
- isCComment = c == '*';
- isOper = !isCPPComment && !isCComment && !"=(&|?:;},".contains(""+prev);
+ isCComment = c == '*';
+ isOper = !isCPPComment && !isCComment && !"=(&|?:;},".contains("" + prev);
isRegex = !isCPPComment && !isCComment && !isOper;
}
if (isOper) {
@@ -234,18 +243,22 @@ public class JsniBundleGenerator extends Generator {
out = "" + last + c;
} else if (isCPPComment) {
isJS = !(isSlash = isCPPComment = c != '\n');
- if (isJS) out = "\n";
+ if (isJS)
+ out = "\n";
} else if (isCComment) {
isSlash = isCComment = !(isJS = (last == '*' && c == '/'));
- if (isJS) out = "";
+ if (isJS)
+ out = "";
} else if (isRegex) {
isJS = !(isSlash = isRegex = (last == '\\' || c != '/'));
if (isJS) {
String mod = "";
while (++i < l) {
c = js.charAt(i);
- if ("igm".contains(""+c)) mod += c;
- else break;
+ if ("igm".contains("" + c))
+ mod += c;
+ else
+ break;
}
out = escapeInlineRegex(tmp, mod) + c;
} else {
@@ -273,7 +286,7 @@ public class JsniBundleGenerator extends Generator {
private String escapeInlineRegex(String s, String mod) {
if (s.endsWith("*")) {
- return "new RegExp('" + s.replace("\\", "\\\\") + "','" + mod + "')";
+ return "new RegExp('" + s.replace("\\", "\\\\") + "','" + mod + "')";
} else {
return '/' + s + '/' + mod;
}
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 7151ef41..08e40c24 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
@@ -15,14 +15,6 @@
*/
package com.google.gwt.query.rebind;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.ext.Generator;
import com.google.gwt.core.ext.GeneratorContext;
@@ -37,8 +29,8 @@ import com.google.gwt.core.ext.typeinfo.JParameterizedType;
import com.google.gwt.core.ext.typeinfo.JType;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
import com.google.gwt.query.client.Function;
-import com.google.gwt.query.client.Properties;
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.JsonBuilderBase;
import com.google.gwt.query.client.builders.JsonFactory;
@@ -47,6 +39,14 @@ import com.google.gwt.query.client.js.JsUtils;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
/**
*/
public class JsonBuilderGenerator extends Generator {
@@ -71,7 +71,7 @@ public class JsonBuilderGenerator extends Generator {
public static String deCapitalize(String s) {
return s == null || s.isEmpty() ? s :
- (s.substring(0, 1).toLowerCase() + (s.length() > 1 ? s.substring(1) : ""));
+ (s.substring(0, 1).toLowerCase() + (s.length() > 1 ? s.substring(1) : ""));
}
TypeOracle oracle;
@@ -81,7 +81,7 @@ public class JsonBuilderGenerator extends Generator {
throws UnableToCompleteException {
oracle = generatorContext.getTypeOracle();
- JClassType clazz = oracle.findType(requestedClass);
+ JClassType clazz = oracle.findType(requestedClass);
jsonBuilderType = oracle.findType(JsonBuilder.class.getName());
settingsType = oracle.findType(IsProperties.class.getName());
@@ -95,7 +95,8 @@ public class JsonBuilderGenerator extends Generator {
boolean isFactory = clazz.isAssignableTo(jsonFactoryType);
- SourceWriter sw = getSourceWriter(treeLogger, generatorContext, t[0], t[1], isFactory, requestedClass);
+ SourceWriter sw =
+ getSourceWriter(treeLogger, generatorContext, t[0], t[1], isFactory, requestedClass);
if (sw != null) {
if (isFactory) {
generateCreateMethod(sw, treeLogger);
@@ -103,16 +104,16 @@ public class JsonBuilderGenerator extends Generator {
Set<String> attrs = new HashSet<String>();
for (JMethod method : clazz.getInheritableMethods()) {
String methName = method.getName();
- //skip method from JsonBuilder
- if(jsonBuilderType.findMethod(method.getName(), method.getParameterTypes()) != null ||
- settingsType.findMethod(method.getName(), method.getParameterTypes()) != null ) {
+ // skip method from JsonBuilder
+ if (jsonBuilderType.findMethod(method.getName(), method.getParameterTypes()) != null ||
+ settingsType.findMethod(method.getName(), method.getParameterTypes()) != null) {
continue;
}
Name nameAnnotation = method.getAnnotation(Name.class);
String name = nameAnnotation != null
- ? nameAnnotation.value()
- : methName.replaceFirst("^(get|set)", "");
+ ? nameAnnotation.value()
+ : methName.replaceFirst("^(get|set)", "");
if (nameAnnotation == null) {
name = name.substring(0, 1).toLowerCase() + name.substring(1);
}
@@ -142,7 +143,7 @@ public class JsonBuilderGenerator extends Generator {
for (Iterator<String> 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)
@@ -220,8 +221,9 @@ public class JsonBuilderGenerator extends Generator {
} else {
sw.println("return Arrays.asList(" + ret + ");");
}
- } else if (method.getReturnType().isEnum() != null){
- sw.println("return "+ method.getReturnType().getQualifiedSourceName() + ".valueOf(p.getStr(\"" + name + "\"));");
+ } else if (method.getReturnType().isEnum() != null) {
+ sw.println("return " + method.getReturnType().getQualifiedSourceName()
+ + ".valueOf(p.getStr(\"" + name + "\"));");
} else {
sw.println("System.err.println(\"JsonBuilderGenerator WARN: unknown return type "
+ retType + " " + ifaceName + "." + name + "()\"); ");
@@ -247,15 +249,19 @@ public class JsonBuilderGenerator extends Generator {
sw.println("setArrayBase(\"" + name + "\", " + a + ");");
} else if (type.getParameterizedQualifiedSourceName().matches("java.util.Date")) {
sw.println("p.setNumber(\"" + name + "\", a.getTime());");
- } else if (type.getParameterizedQualifiedSourceName().matches("(java.lang.(Character|Long|Double|Integer|Float|Byte)|(char|long|double|int|float|byte))")) {
+ } else if (type
+ .getParameterizedQualifiedSourceName()
+ .matches(
+ "(java.lang.(Character|Long|Double|Integer|Float|Byte)|(char|long|double|int|float|byte))")) {
sw.println("p.setNumber(\"" + name + "\", a);");
} else if (type.getParameterizedQualifiedSourceName().matches("(java.lang.Boolean|boolean)")) {
sw.println("p.setBoolean(\"" + name + "\", a);");
- } else if (type.getParameterizedQualifiedSourceName().matches("com.google.gwt.query.client.Function")) {
+ } else if (type.getParameterizedQualifiedSourceName().matches(
+ "com.google.gwt.query.client.Function")) {
sw.println("p.setFunction(\"" + name + "\", a);");
- } else if (type.isEnum() != null){
+ } else if (type.isEnum() != null) {
sw.println("p.set(\"" + name + "\", a.name());");
- }else {
+ } else {
sw.println("set(\"" + name + "\", a);");
}
if (!"void".equals(retType)) {
@@ -310,9 +316,10 @@ public class JsonBuilderGenerator extends Generator {
sw.indent();
ArrayList<JClassType> types = new ArrayList<JClassType>();
for (JClassType t : oracle.getTypes()) {
- if (t.isInterface() != null && t.isAssignableTo(jsonBuilderType) ) {
+ if (t.isInterface() != null && t.isAssignableTo(jsonBuilderType)) {
if (t.isPublic()) {
- sw.println("if (clz == " + t.getQualifiedSourceName() + ".class) return GWT.<T>create(" + t.getQualifiedSourceName() + ".class);");
+ sw.println("if (clz == " + t.getQualifiedSourceName() + ".class) return GWT.<T>create("
+ + t.getQualifiedSourceName() + ".class);");
} else {
logger.log(Type.WARN, t.getQualifiedSourceName() + " is not public");
}
@@ -324,7 +331,8 @@ public class JsonBuilderGenerator extends Generator {
sw.println("}");
sw.println("public " + IsProperties.class.getName() + " create(String s) {");
sw.indent();
- sw.println("return (" + IsProperties.class.getName() + ")" + JsUtils.class.getName() + ".parseJSON(s);");
+ sw.println("return (" + IsProperties.class.getName() + ")" + JsUtils.class.getName()
+ + ".parseJSON(s);");
sw.outdent();
sw.println("}");
sw.println("public " + IsProperties.class.getName() + " create() {");
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/LazyGenerator.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/LazyGenerator.java
index 0e83962e..0a2cce56 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/LazyGenerator.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/LazyGenerator.java
@@ -64,7 +64,8 @@ public class LazyGenerator extends Generator {
}
}
- if (targetType == null) return null;
+ if (targetType == null)
+ return null;
assert targetType != null : "Parameter of Lazy<T> not found";
String genClass = targetType.getPackage().getName() + "."
@@ -173,8 +174,8 @@ public class LazyGenerator extends Generator {
if (printWriter == null) {
return null;
}
- ClassSourceFileComposerFactory composerFactory
- = new ClassSourceFileComposerFactory(packageName, className);
+ ClassSourceFileComposerFactory composerFactory =
+ new ClassSourceFileComposerFactory(packageName, className);
composerFactory.addImport("com.google.gwt.core.client.*");
composerFactory.addImport("com.google.gwt.query.client.*");
composerFactory.addImport("com.google.gwt.dom.client.Element");
@@ -207,7 +208,7 @@ public class LazyGenerator extends Generator {
sw.println(
"ctx = GQuery.$(getElement()).as(" + nonLazyType.getQualifiedSourceName() + "."
- + classID + ");");
+ + classID + ");");
sw.println("for (int i = 0; i < closures.length(); i++) {");
sw.indent();
sw.println("closures.get(i).invoke();");
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorBase.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorBase.java
index d2aff311..515f6444 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorBase.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorBase.java
@@ -193,9 +193,9 @@ public abstract class SelectorGeneratorBase extends Generator {
+ "\"; }");
sw
.println("public NodeList<Element> runSelector(Node ctx) { return " +
- (m.getName() + (m.getParameters().length == 0 ? "()" : "(ctx)")) +
- ("NodeList".equals(m.getReturnType().getSimpleSourceName()) ? "" : ".get()") + ";}"
- ) ;
+ (m.getName() + (m.getParameters().length == 0 ? "()" : "(ctx)")) +
+ ("NodeList".equals(m.getReturnType().getSimpleSourceName()) ? "" : ".get()") + ";}"
+ );
sw.outdent();
sw.println("},");
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorCssToXPath.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorCssToXPath.java
index 45b1a848..1590b2c0 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorCssToXPath.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorCssToXPath.java
@@ -15,15 +15,6 @@
*/
package com.google.gwt.query.rebind;
-import java.util.ArrayList;
-import java.util.regex.MatchResult;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.typeinfo.JMethod;
@@ -33,6 +24,15 @@ import com.google.gwt.query.client.impl.SelectorEngineCssToXPath.ReplaceCallback
import com.google.gwt.query.client.impl.SelectorEngineCssToXPath.Replacer;
import com.google.gwt.user.rebind.SourceWriter;
+import java.util.ArrayList;
+import java.util.regex.MatchResult;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
/**
* Compile time selector generator which translates selector into XPath at
* compile time. It Uses the SelectorEngineCssToXpath to produce the xpath
@@ -90,8 +90,9 @@ public class SelectorGeneratorCssToXPath extends SelectorGeneratorBase {
} catch (XPathExpressionException e1) {
System.err.println("Invalid XPath generated selector, please revise it: " + xselector);
if (!selector.equals(xselector)) {
- System.err.println("If your css2 selector syntax is correct, open an issue in the gwtquery project. cssselector:"
- + selector + " xpath:" + xselector);
+ System.err
+ .println("If your css2 selector syntax is correct, open an issue in the gwtquery project. cssselector:"
+ + selector + " xpath: " + xselector);
}
throw new UnableToCompleteException();
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorJSOptimal.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorJSOptimal.java
index 7cbdcf13..81dcc0a3 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorJSOptimal.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorJSOptimal.java
@@ -58,7 +58,7 @@ public class SelectorGeneratorJSOptimal extends SelectorGeneratorBase {
protected static Pattern nthRe2 = Pattern.compile("\\D");
- protected static RuleMatcher[] matchers = new RuleMatcher[]{
+ protected static RuleMatcher[] matchers = new RuleMatcher[] {
new RuleMatcher("^\\.([a-zA-Z_0-9-]+)",
"n = byClassName(n, null, \"{0}\");"),
new RuleMatcher("^\\:([a-zA-Z_0-9-]+)(?:\\(((?:[^ >]*|.*?))\\))?",
@@ -75,112 +75,112 @@ public class SelectorGeneratorJSOptimal extends SelectorGeneratorBase {
sw.println("return " + wrap(method,
"impl.select(\"" + selector + "\", root)") + ";");
-// sw.println("JSArray n = JSArray.create();");
-// if(!hasContext) {
-// sw.println("Node root = Document.get();");
-// }
-//
-// // add root node as context.
-// // TODO: support any context
-// sw.println("n.addNode(root);");
-// String q = selector, lq = null;
-// Matcher lmode = modeRe.matcher(q);
-// Matcher mm = null;
-// String mode = "";
-// if (lmode.lookingAt() && notNull(lmode.group(1))) {
-// mode = lmode.group(1).replaceAll(trimReStr, "").trim();
-// q = q.replaceFirst("\\Q" + lmode.group(1) + "\\E", "");
-// }
-//
-// while (notNull(q) && !q.equals(lq)) {
-// debug("Doing q=" + q);
-//
-// lq = q;
-// Matcher tm = tagTokenRe.matcher(q);
-// if (tm.lookingAt()) {
-// if ("#".equals(tm.group(1))) {
-// sw.println("n = quickId(n, \"" + mode + "\", root, \"" + tm.group(2)
-// + "\");");
-// } else {
-// String tagName = tm.group(2);
-// tagName = "".equals(tagName) ? "*" : tagName;
-// // sw.println("if (n.size() == 0) { n=JSArray.create(); }");
-// String func = "";
-// if ("".equals(mode)) {
-// func = "getDescendentNodes";
-// } else if (">".equals(mode)) {
-// func = "getChildNodes";
-// } else if ("+".equals(mode)) {
-// func = "getSiblingNodes";
-// } else if ("~".equals(mode)) {
-// func = "getGeneralSiblingNodes";
-// } else {
-// treeLogger.log(TreeLogger.ERROR, "Error parsing selector, combiner "
-// + mode + " not recognized in " + selector, null);
-// throw new UnableToCompleteException();
-// }
-// sw.println("n = " + func + "(n, \"" + tagName + "\");");
-// }
-// debug("replacing in q, the value " + tm.group(0));
-// q = q.replaceFirst("\\Q" + tm.group(0) + "\\E", "");
-// } else {
-// String func = "";
-// String tagName = "*";
-// if ("".equals(mode)) {
-// func = "getDescendentNodes";
-// } else if (">".equals(mode)) {
-// func = "getChildNodes";
-// } else if ("+".equals(mode)) {
-// func = "getSiblingNodes";
-// } else if ("~".equals(mode)) {
-// func = "getGeneralSiblingNodes";
-// } else {
-// treeLogger.log(TreeLogger.ERROR, "Error parsing selector, combiner "
-// + mode + " not recognized in " + selector, null);
-// throw new UnableToCompleteException();
-// }
-// sw.println("n = " + func + "(n, \"" + tagName + "\");");
-// }
-//
-// while (!(mm = modeRe.matcher(q)).lookingAt()) {
-// debug("Looking at " + q);
-// boolean matched = false;
-// for (RuleMatcher rm : matchers) {
-// Matcher rmm = rm.re.matcher(q);
-// if (rmm.lookingAt()) {
-// String res[] = new String[rmm.groupCount()];
-// for (int i = 1; i <= rmm.groupCount(); i++) {
-// res[i - 1] = rmm.group(i);
-// debug("added param " + res[i - 1]);
-// }
-// Object[] r = res;
-// // inline enum, perhaps type-tightening will allow inlined eval()
-// // call
-// if (rm.fnTemplate.indexOf("byPseudo") != -1) {
-// sw.println("n = Pseudo."+res[0].toUpperCase().replace("-", "_") +
-// ".eval(n, \""+res[1]+"\");");
-// } else {
-// sw.println(MessageFormat.format(rm.fnTemplate, r));
-// }
-// q = q.replaceFirst("\\Q" + rmm.group(0) + "\\E", "");
-// matched = true;
-// break;
-// }
-// }
-// if (!matched) {
-// treeLogger
-// .log(TreeLogger.ERROR, "Error parsing selector at " + q, null);
-// throw new UnableToCompleteException();
-// }
-// }
-//
-// if (notNull(mm.group(1))) {
-// mode = mm.group(1).replaceAll(trimReStr, "");
-// debug("replacing q=" + q + " this part:" + mm.group(1));
-// q = q.replaceFirst("\\Q" + mm.group(1) + "\\E", "");
-// }
-// }
-// sw.println("return "+wrap(method, "nodup(n)")+";");
+ // sw.println("JSArray n = JSArray.create();");
+ // if(!hasContext) {
+ // sw.println("Node root = Document.get();");
+ // }
+ //
+ // // add root node as context.
+ // // TODO: support any context
+ // sw.println("n.addNode(root);");
+ // String q = selector, lq = null;
+ // Matcher lmode = modeRe.matcher(q);
+ // Matcher mm = null;
+ // String mode = "";
+ // if (lmode.lookingAt() && notNull(lmode.group(1))) {
+ // mode = lmode.group(1).replaceAll(trimReStr, "").trim();
+ // q = q.replaceFirst("\\Q" + lmode.group(1) + "\\E", "");
+ // }
+ //
+ // while (notNull(q) && !q.equals(lq)) {
+ // debug("Doing q=" + q);
+ //
+ // lq = q;
+ // Matcher tm = tagTokenRe.matcher(q);
+ // if (tm.lookingAt()) {
+ // if ("#".equals(tm.group(1))) {
+ // sw.println("n = quickId(n, \"" + mode + "\", root, \"" + tm.group(2)
+ // + "\");");
+ // } else {
+ // String tagName = tm.group(2);
+ // tagName = "".equals(tagName) ? "*" : tagName;
+ // // sw.println("if (n.size() == 0) { n=JSArray.create(); }");
+ // String func = "";
+ // if ("".equals(mode)) {
+ // func = "getDescendentNodes";
+ // } else if (">".equals(mode)) {
+ // func = "getChildNodes";
+ // } else if ("+".equals(mode)) {
+ // func = "getSiblingNodes";
+ // } else if ("~".equals(mode)) {
+ // func = "getGeneralSiblingNodes";
+ // } else {
+ // treeLogger.log(TreeLogger.ERROR, "Error parsing selector, combiner "
+ // + mode + " not recognized in " + selector, null);
+ // throw new UnableToCompleteException();
+ // }
+ // sw.println("n = " + func + "(n, \"" + tagName + "\");");
+ // }
+ // debug("replacing in q, the value " + tm.group(0));
+ // q = q.replaceFirst("\\Q" + tm.group(0) + "\\E", "");
+ // } else {
+ // String func = "";
+ // String tagName = "*";
+ // if ("".equals(mode)) {
+ // func = "getDescendentNodes";
+ // } else if (">".equals(mode)) {
+ // func = "getChildNodes";
+ // } else if ("+".equals(mode)) {
+ // func = "getSiblingNodes";
+ // } else if ("~".equals(mode)) {
+ // func = "getGeneralSiblingNodes";
+ // } else {
+ // treeLogger.log(TreeLogger.ERROR, "Error parsing selector, combiner "
+ // + mode + " not recognized in " + selector, null);
+ // throw new UnableToCompleteException();
+ // }
+ // sw.println("n = " + func + "(n, \"" + tagName + "\");");
+ // }
+ //
+ // while (!(mm = modeRe.matcher(q)).lookingAt()) {
+ // debug("Looking at " + q);
+ // boolean matched = false;
+ // for (RuleMatcher rm : matchers) {
+ // Matcher rmm = rm.re.matcher(q);
+ // if (rmm.lookingAt()) {
+ // String res[] = new String[rmm.groupCount()];
+ // for (int i = 1; i <= rmm.groupCount(); i++) {
+ // res[i - 1] = rmm.group(i);
+ // debug("added param " + res[i - 1]);
+ // }
+ // Object[] r = res;
+ // // inline enum, perhaps type-tightening will allow inlined eval()
+ // // call
+ // if (rm.fnTemplate.indexOf("byPseudo") != -1) {
+ // sw.println("n = Pseudo."+res[0].toUpperCase().replace("-", "_") +
+ // ".eval(n, \""+res[1]+"\");");
+ // } else {
+ // sw.println(MessageFormat.format(rm.fnTemplate, r));
+ // }
+ // q = q.replaceFirst("\\Q" + rmm.group(0) + "\\E", "");
+ // matched = true;
+ // break;
+ // }
+ // }
+ // if (!matched) {
+ // treeLogger
+ // .log(TreeLogger.ERROR, "Error parsing selector at " + q, null);
+ // throw new UnableToCompleteException();
+ // }
+ // }
+ //
+ // if (notNull(mm.group(1))) {
+ // mode = mm.group(1).replaceAll(trimReStr, "");
+ // debug("replacing q=" + q + " this part: " + mm.group(1));
+ // q = q.replaceFirst("\\Q" + mm.group(1) + "\\E", "");
+ // }
+ // }
+ // sw.println("return "+wrap(method, "nodup(n)")+";");
}
protected String getImplSuffix() {
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorNative.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorNative.java
index e0cdb04a..5624a0b0 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorNative.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorNative.java
@@ -45,8 +45,8 @@ public class SelectorGeneratorNative extends SelectorGeneratorCssToXPath {
} else if (selector.contains("!=")) {
sw.println("return "
+ wrap(method, "querySelectorAll(\""
- + selector.replaceAll("(\\[\\w+)!(=[^\\]]+\\])", ":not($1$2)")
- + "\", root)") + ";");
+ + selector.replaceAll("(\\[\\w+)!(=[^\\]]+\\])", ":not($1$2)")
+ + "\", root)") + ";");
} else if (selector.matches(SelectorEngineNative.NATIVE_EXCEPTIONS_REGEXP)) {
super.generateMethodBody(sw, method, treeLogger, hasContext);
} else {
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorXPath.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorXPath.java
index fdc4838c..ad11c989 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorXPath.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/SelectorGeneratorXPath.java
@@ -57,8 +57,10 @@ public class SelectorGeneratorXPath extends SelectorGeneratorBase {
public String tagRelation;
}
- private static Pattern cssSelectorRegExp = Pattern.compile(
- "^(\\w+)?(#[a-zA-Z_0-9\u00C0-\uFFFF\\-\\_]+|(\\*))?((\\.[a-zA-Z_0-9\u00C0-\uFFFF\\-_]+)*)?((\\[\\w+(\\^|\\$|\\*|\\||~)?(=[a-zA-Z_0-9\u00C0-\uFFFF\\s\\-\\_\\.]+)?\\]+)*)?(((:\\w+[a-zA-Z_0-9\\-]*)(\\((odd|even|\\-?\\d*n?((\\+|\\-)\\d+)?|[a-zA-Z_0-9\u00C0-\uFFFF\\-_]+|((\\w*\\.[a-zA-Z_0-9\u00C0-\uFFFF\\-_]+)*)?|(\\[#?\\w+(\\^|\\$|\\*|\\||~)?=?[a-zA-Z_0-9\u00C0-\uFFFF\\s\\-\\_\\.]+\\]+)|(:\\w+[a-zA-Z_0-9\\-]*))\\))?)*)?(>|\\+|~)?");
+ private static Pattern cssSelectorRegExp =
+ Pattern
+ .compile(
+ "^(\\w+)?(#[a-zA-Z_0-9\u00C0-\uFFFF\\-\\_]+|(\\*))?((\\.[a-zA-Z_0-9\u00C0-\uFFFF\\-_]+)*)?((\\[\\w+(\\^|\\$|\\*|\\||~)?(=[a-zA-Z_0-9\u00C0-\uFFFF\\s\\-\\_\\.]+)?\\]+)*)?(((:\\w+[a-zA-Z_0-9\\-]*)(\\((odd|even|\\-?\\d*n?((\\+|\\-)\\d+)?|[a-zA-Z_0-9\u00C0-\uFFFF\\-_]+|((\\w*\\.[a-zA-Z_0-9\u00C0-\uFFFF\\-_]+)*)?|(\\[#?\\w+(\\^|\\$|\\*|\\||~)?=?[a-zA-Z_0-9\u00C0-\uFFFF\\s\\-\\_\\.]+\\]+)|(:\\w+[a-zA-Z_0-9\\-]*))\\))?)*)?(>|\\+|~)?");
private static Pattern selectorSplitRegExp = Pattern
.compile("(?:\\[[^\\[]*\\]|\\(.*\\)|[^\\s\\+>~\\[\\(])+|[\\+>~]");
@@ -227,20 +229,22 @@ public class SelectorGeneratorXPath extends SelectorGeneratorBase {
private Sequence getSequence(String expression) {
int start = 0, add = 2, max = -1, modVal = -1;
- Pattern expressionRegExp = Pattern.compile(
- "^((odd|even)|([1-9]\\d*)|((([1-9]\\d*)?)n([\\+\\-]\\d+)?)|(\\-(([1-9]\\d*)?)n\\+(\\d+)))$");
+ Pattern expressionRegExp =
+ Pattern
+ .compile(
+ "^((odd|even)|([1-9]\\d*)|((([1-9]\\d*)?)n([\\+\\-]\\d+)?)|(\\-(([1-9]\\d*)?)n\\+(\\d+)))$");
Matcher pseudoValue = expressionRegExp.matcher(expression);
if (!pseudoValue.matches()) {
return null;
} else {
- if (notNull(pseudoValue.group(2))) { // odd or even
+ if (notNull(pseudoValue.group(2))) { // odd or even
start = ("odd".equals(pseudoValue.group(2))) ? 1 : 2;
modVal = (start == 1) ? 1 : 0;
- } else if (notNull(pseudoValue.group(3))) { // single digit
+ } else if (notNull(pseudoValue.group(3))) { // single digit
start = Integer.parseInt(pseudoValue.group(3), 10);
add = 0;
max = start;
- } else if (notNull(pseudoValue.group(4))) { // an+b
+ } else if (notNull(pseudoValue.group(4))) { // an+b
add = notNull(pseudoValue.group(6)) ? getInt(pseudoValue.group(6), 1)
: 1;
start = notNull(pseudoValue.group(7)) ? getInt(pseudoValue.group(7), 0)
@@ -250,7 +254,7 @@ public class SelectorGeneratorXPath extends SelectorGeneratorBase {
}
modVal = (start > add) ? (start - add) % add
: ((start == add) ? 0 : start);
- } else if (notNull(pseudoValue.group(8))) { // -an+b
+ } else if (notNull(pseudoValue.group(8))) { // -an+b
add = notNull(pseudoValue.group(10)) ? Integer
.parseInt(pseudoValue.group(10), 10) : 1;
start = max = Integer.parseInt(pseudoValue.group(10), 10);
@@ -292,8 +296,8 @@ public class SelectorGeneratorXPath extends SelectorGeneratorBase {
} else {
xpath = position + " mod " + sequence.add + " = " + sequence.modVal
+ ((sequence.start > 1) ? " and " + position + " >= "
- + sequence.start : "") + ((sequence.max > 0) ? " and "
- + position + " <= " + sequence.max : "");
+ + sequence.start : "") + ((sequence.max > 0) ? " and "
+ + position + " <= " + sequence.max : "");
}
}
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/XmlBuilderGenerator.java b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/XmlBuilderGenerator.java
index e5d195b7..d68af817 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/rebind/XmlBuilderGenerator.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/rebind/XmlBuilderGenerator.java
@@ -15,8 +15,6 @@
*/
package com.google.gwt.query.rebind;
-import java.io.PrintWriter;
-
import com.google.gwt.core.ext.Generator;
import com.google.gwt.core.ext.GeneratorContext;
import com.google.gwt.core.ext.TreeLogger;
@@ -33,6 +31,8 @@ import com.google.gwt.query.client.builders.XmlBuilder;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
+import java.io.PrintWriter;
+
/**
*/
public class XmlBuilderGenerator extends Generator {
@@ -54,9 +54,9 @@ public class XmlBuilderGenerator extends Generator {
t[1], requestedClass);
if (sw != null) {
for (JMethod method : clazz.getInheritableMethods()) {
- //skip method from JsonBuilder
- if(xmlBuilderType.findMethod(method.getName(), method.getParameterTypes()) != null){
- continue;
+ // skip method from JsonBuilder
+ if (xmlBuilderType.findMethod(method.getName(), method.getParameterTypes()) != null) {
+ continue;
}
generateMethod(sw, method, treeLogger);
}
@@ -106,12 +106,13 @@ public class XmlBuilderGenerator extends Generator {
} else if (isTypeAssignableTo(method.getReturnType(), xmlBuilderType)) {
String q = method.getReturnType().getQualifiedSourceName();
sw.println("Element e = getElementBase(\"" + name + "\");");
- sw.println("return e == null ? null : (" + q + ")((" + q + ")GWT.create(" + q + ".class)).load(e);");
- } else if (retType.equals(Properties.class.getName())){
+ sw.println("return e == null ? null : (" + q + ")((" + q + ")GWT.create(" + q
+ + ".class)).load(e);");
+ } else if (retType.equals(Properties.class.getName())) {
sw.println("return getPropertiesBase(\"" + name + "\");");
} else if (arr != null) {
String q = arr.getComponentType().getQualifiedSourceName();
- sw.println("ArrayList<" + q + "> l = new ArrayList<" + q+ ">();");
+ sw.println("ArrayList<" + q + "> l = new ArrayList<" + q + ">();");
sw.println("for (Element e: getElementsBase(\"" + name + "\")) {");
sw.println(" " + q + " c = GWT.create(" + q + ".class);");
sw.println(" c.load(e);");
@@ -135,7 +136,7 @@ public class XmlBuilderGenerator extends Generator {
} else {
sw.println("setBase(\"" + name + "\", a);");
}
- if (!"void".equals(retType)){
+ if (!"void".equals(retType)) {
if (isTypeAssignableTo(method.getReturnType(), method.getEnclosingType())) {
sw.println("return this;");
} else {
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/AjaxTransportJre.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/AjaxTransportJre.java
index 9f496da3..fa756933 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/AjaxTransportJre.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/AjaxTransportJre.java
@@ -17,25 +17,25 @@ package com.google.gwt.query.vm;
// import org.apache.http.impl.client.HttpClientBuilder;
-import java.io.BufferedReader;
-import java.io.DataOutputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
import com.google.gwt.http.client.RequestException;
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.plugins.ajax.Ajax.AjaxTransport;
import com.google.gwt.query.client.plugins.ajax.Ajax.Settings;
import com.google.gwt.query.client.plugins.deferred.PromiseFunction;
import com.google.gwt.user.server.Base64Utils;
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
/**
*
*/
@@ -66,7 +66,8 @@ public class AjaxTransportJre implements AjaxTransport {
followRedirections = b;
}
- private final String USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:26.0) Gecko/20100101 Firefox/26.0";
+ private static final String USER_AGENT =
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:26.0) Gecko/20100101 Firefox/26.0";
private final String jsonpCbRexp = "(?ms)^.*jre_callback\\((.*)\\).*$";
public Promise getJsonP(final Settings settings) {
@@ -79,16 +80,16 @@ public class AjaxTransportJre implements AjaxTransport {
}
return getXhr(settings, false)
- .then(new Function() {
- public Object f(Object... args) {
- Response response = arguments(0);
- if (response.getText().matches(jsonpCbRexp)) {
- return GQ.create(response.getText().replaceFirst(jsonpCbRexp, "$1"));
- } else {
- return GQuery.Deferred().reject().promise();
+ .then(new Function() {
+ public Object f(Object... args) {
+ Response response = arguments(0);
+ if (response.getText().matches(jsonpCbRexp)) {
+ return GQ.create(response.getText().replaceFirst(jsonpCbRexp, "$1"));
+ } else {
+ return GQuery.Deferred().reject().promise();
+ }
}
- }
- });
+ });
}
public Promise getLoadScript(Settings settings) {
@@ -107,7 +108,8 @@ public class AjaxTransportJre implements AjaxTransport {
int status = response.getStatusCode();
if (status <= 0 || status >= 400) {
String statusText = status <= 0 ? "Bad CORS" : response.getStatusText();
- dfd.reject(new RequestException("HTTP ERROR: " + status + " " + statusText + "\n" + response.getText()), null);
+ dfd.reject(new RequestException("HTTP ERROR: " + status + " " + statusText + "\n"
+ + response.getText()), null);
} else {
dfd.resolve(response, null);
}
@@ -131,7 +133,8 @@ public class AjaxTransportJre implements AjaxTransport {
c.setRequestMethod(s.getType());
c.setRequestProperty("User-Agent", USER_AGENT);
if (s.getUsername() != null && s.getPassword() != null) {
- c.setRequestProperty ("Authorization", "Basic " + Base64Utils.toBase64((s.getUsername() + ":" + s.getPassword()).getBytes()));
+ c.setRequestProperty("Authorization", "Basic "
+ + Base64Utils.toBase64((s.getUsername() + ":" + s.getPassword()).getBytes()));
}
if (cookieManager != null) {
cookieManager.setCookies(c);
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/CookieManager.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/CookieManager.java
index baf6fabd..0075b708 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/CookieManager.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/CookieManager.java
@@ -27,12 +27,12 @@ import java.util.Map;
import java.util.StringTokenizer;
/**
- * @author Ian Brown spam@hccp.org
- * http://www.hccp.org/java-net-cookie-how-to.html
+ * http://www.hccp.org/java-net-cookie-how-to.html.
*/
public class CookieManager {
- private Map<String,Map<String,Map<String, String>>> store = new HashMap<String, Map<String,Map<String, String>>>();
+ private Map<String, Map<String, Map<String, String>>> store =
+ new HashMap<String, Map<String, Map<String, String>>>();
private static final String SET_COOKIE = "Set-Cookie";
private static final String COOKIE_VALUE_DELIMITER = ";";
@@ -62,9 +62,9 @@ public class CookieManager {
}
public void removeDomainCookie(String domain, String... cookies) {
- Map<String, Map<String, String>> domainStore = store.get(domain);
+ Map<String, Map<String, String>> domainStore = store.get(domain);
if (domainStore != null) {
- for (String cookie: cookies) {
+ for (String cookie : cookies) {
domainStore.remove(cookie);
}
}
@@ -76,9 +76,9 @@ public class CookieManager {
public void setDomcainCookieProperty(String host, String name, String prop, String value) {
String domain = getDomainFromHost(host);
- Map<String, Map<String, String>> domainStore = store.get(domain);
+ Map<String, Map<String, String>> domainStore = store.get(domain);
if (domainStore == null) {
- domainStore = new HashMap<String, Map<String,String>>();
+ domainStore = new HashMap<String, Map<String, String>>();
store.put(domain, domainStore);
}
Map<String, String> cookie = domainStore.get(name);
@@ -107,7 +107,7 @@ public class CookieManager {
// let's determine the domain from where these cookies are being sent
String domain = getDomainFromHost(conn.getURL().getHost());
- Map<String,Map<String, String>> domainStore; // this is where we will store cookies for this domain
+ Map<String, Map<String, String>> domainStore; // this is where we will store cookies for this domain
// now let's check the store to see if we have an entry for this domain
if (store.containsKey(domain)) {
@@ -115,7 +115,7 @@ public class CookieManager {
domainStore = store.get(domain);
} else {
// we don't, so let's create it and put it in the store
- domainStore = new HashMap<String, Map<String,String>>();
+ domainStore = new HashMap<String, Map<String, String>>();
store.put(domain, domainStore);
}
@@ -142,8 +142,9 @@ public class CookieManager {
while (st.hasMoreTokens()) {
String token = st.nextToken().toLowerCase();
int idx = token.indexOf(NAME_VALUE_SEPARATOR);
- if (idx > 0 && idx < token.length() -1) {
- cookie.put(token.substring(0, idx).toLowerCase(), token.substring(idx + 1, token.length()));
+ if (idx > 0 && idx < token.length() - 1) {
+ cookie.put(token.substring(0, idx).toLowerCase(), token.substring(idx + 1, token
+ .length()));
}
}
}
@@ -169,7 +170,7 @@ public class CookieManager {
}
String path = url.getPath();
- Map<String, Map<String, String>> domainStore = store.get(domain);
+ Map<String, Map<String, String>> domainStore = store.get(domain);
if (domainStore == null)
return;
StringBuffer cookieStringBuffer = new StringBuffer();
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..adbdd233
--- /dev/null
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonBuilderHandler.java
@@ -0,0 +1,346 @@
+/*
+ * Copyright 2014, The gwtquery team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+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;
+
+/**
+ * Reflection handler for JsonBuilder implementation in JVM.
+ */
+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 <T> Object jsonArrayToList(JsonArray j, Class<T> ctype, boolean isArray) {
+ List<T> l = new ArrayList<T>();
+ 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 <T> 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<? extends JsonBuilder> clz = (Class<? extends JsonBuilder>) 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;
+ }
+
+ /*
+ * 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) throws Throwable {
+ Class<?> type = proxy.getClass().getInterfaces()[0];
+
+ HashSet<String> validAttrs = getAttributeNames(type.getMethods());
+ Hashtable<String, Method> ispropertyGetters = getJsonBuilders(type.getMethods());
+
+ for (String key : jsonObject.keys()) {
+ String name = methodName2AttrName(key);
+ if (!validAttrs.contains(name)) {
+ jsonObject.remove(key);
+ continue;
+ }
+ Method ispropertyGetter = ispropertyGetters.get(name);
+ if (ispropertyGetter != null) {
+ ((IsProperties) invoke(proxy, ispropertyGetter, new Object[] {})).strip();
+ }
+ }
+ }
+
+ 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<String> getAttributeNames(Method[] methods) {
+ HashSet<String> valid = new HashSet<String>();
+
+ 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<String, Method> getJsonBuilders(Method[] methods) {
+ Hashtable<String, Method> ispropertyGetters = new Hashtable<String, Method>();
+
+ if (methods == null || methods.length == 0) {
+ return ispropertyGetters;
+ }
+
+ for (Method m : methods) {
+ Class<?>[] classes = m.getParameterTypes();
+ boolean isJsonBuilder =
+ classes.length == 0 && IsProperties.class.isAssignableFrom(m.getReturnType());
+ if (isJsonBuilder) {
+ String attr = methodName2AttrName(m.getName());
+ ispropertyGetters.put(attr, m);
+ }
+ }
+
+ return ispropertyGetters;
+ }
+} \ 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 0d9763c2..5a976f3f 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
@@ -17,30 +17,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 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.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;
/**
@@ -49,9 +32,7 @@ import elemental.json.impl.JreJsonNull;
* It uses java.util.reflect.Proxy to implement JsonBuilders
* and elemental light weight json to handle json data.
*/
-public class JsonFactoryJre implements JsonFactory {
-
- static JsonFactoryJre jsonFactory = new JsonFactoryJre();
+public class JsonFactoryJre implements JsonFactory {
/**
* Although functions cannot be serialized to json we use JsonBuilders
@@ -60,241 +41,22 @@ public class JsonFactoryJre implements JsonFactory {
* Functions in JVM.
*/
static class JreJsonFunction extends JreJsonNull {
- final private Function function;
+ private final Function function;
+
public JreJsonFunction(Function f) {
function = f;
}
+
@Override
public String toJson() {
return function.toString();
}
+
public Function getFunction() {
return function;
}
}
- 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 <T> Object jsonArrayToList(JsonArray j, Class<T> ctype, boolean isArray) {
- List<T> l = new ArrayList<T>();
- 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 <T> 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() : deCapitalize(mname.replaceFirst("^[gs]et", ""));
-
- if ("getFieldNames".equals(mname)) {
- return jsonObject.keys();
- } else if ("as".equals(mname)) {
- @SuppressWarnings("unchecked")
- Class<? extends JsonBuilder> clz = (Class<? extends JsonBuilder>)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 (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;
- }
-
- private String deCapitalize(String s) {
- return s != null && s.length() > 0 ? s.substring(0, 1).toLowerCase() + s.substring(1) : s;
- }
-
- 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> T create(Class<T> clz, JsonObject jso) {
InvocationHandler handler = new JsonBuilderHandler(jso);
@@ -309,12 +71,14 @@ public class JsonFactoryJre implements JsonFactory {
public IsProperties createBinder() {
InvocationHandler handler = new JsonBuilderHandler();
- return (IsProperties)Proxy.newProxyInstance(IsProperties.class.getClassLoader(), new Class[] {IsProperties.class}, handler);
+ return (IsProperties) Proxy.newProxyInstance(IsProperties.class.getClassLoader(),
+ new Class[] {IsProperties.class}, handler);
}
public IsProperties createBinder(JsonObject jso) {
InvocationHandler handler = new JsonBuilderHandler(jso);
- return (IsProperties)Proxy.newProxyInstance(IsProperties.class.getClassLoader(), new Class[] {IsProperties.class}, handler);
+ return (IsProperties) Proxy.newProxyInstance(IsProperties.class.getClassLoader(),
+ new Class[] {IsProperties.class}, handler);
}
@Override
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/ResponseJre.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/ResponseJre.java
index ea42a2d1..1aa8352c 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/ResponseJre.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/ResponseJre.java
@@ -15,22 +15,22 @@
*/
package com.google.gwt.query.vm;
-import java.util.List;
-import java.util.Map;
-
import com.google.gwt.http.client.Header;
import com.google.gwt.http.client.Response;
+import java.util.List;
+import java.util.Map;
+
/**
- * Implementation of `Response` in the JVM
+ * Implementation of `Response` in the JVM.
*/
public class ResponseJre extends Response {
private int status;
- private Map<String,List<String>> headers;
+ private Map<String, List<String>> headers;
private String responseText;
private String statusText;
- public ResponseJre(int status, String statusText, String text, Map<String,List<String>> headers) {
+ public ResponseJre(int status, String statusText, String text, Map<String, List<String>> headers) {
this.status = status;
this.headers = headers;
this.responseText = text;
@@ -58,6 +58,7 @@ public class ResponseJre extends Response {
public String getValue() {
return v;
}
+
public String getName() {
return s;
}
@@ -66,19 +67,23 @@ public class ResponseJre extends Response {
}
return ret;
}
+
public String getHeadersAsString() {
String ret = "";
for (Header h : getHeaders()) {
- ret += h.getName() + ":" + h.getValue() + "\n";
+ ret += h.getName() + ":" + h.getValue() + "\n";
}
return ret;
}
+
public int getStatusCode() {
return status;
}
+
public String getStatusText() {
return statusText;
}
+
public String getText() {
return responseText;
}
diff --git a/gwtquery-core/src/main/java/com/google/web/bindery/requestfactory/shared/gquery/PromiseRF.java b/gwtquery-core/src/main/java/com/google/web/bindery/requestfactory/shared/gquery/PromiseRF.java
index 6951b005..9166190a 100644
--- a/gwtquery-core/src/main/java/com/google/web/bindery/requestfactory/shared/gquery/PromiseRF.java
+++ b/gwtquery-core/src/main/java/com/google/web/bindery/requestfactory/shared/gquery/PromiseRF.java
@@ -13,19 +13,18 @@
*/
package com.google.web.bindery.requestfactory.shared.gquery;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javax.validation.ConstraintViolation;
-
-import com.google.gwt.query.client.plugins.deferred.Deferred;
import com.google.gwt.query.client.plugins.deferred.Deferred.DeferredPromiseImpl;
import com.google.web.bindery.requestfactory.shared.Receiver;
import com.google.web.bindery.requestfactory.shared.Request;
import com.google.web.bindery.requestfactory.shared.RequestContext;
import com.google.web.bindery.requestfactory.shared.ServerFailure;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.validation.ConstraintViolation;
+
/**
* Utility class used to create promises for RequestFactory services.
* <pre>
@@ -70,14 +69,16 @@ public class PromiseRF extends DeferredPromiseImpl {
*/
public PromiseRF(Request<?>[] requests) {
for (Request<?> request : requests) {
- total ++;
+ total++;
request.to(new Receiver<Object>() {
public void onConstraintViolation(Set<ConstraintViolation<?>> violations) {
dfd.reject(new ServerFailure("ConstraintViolation"), violations);
}
+
public void onFailure(ServerFailure error) {
dfd.reject(error);
}
+
public void onSuccess(Object response) {
responses.add(response);
// Resolve only when all requests have been received