\r
import java.util.ArrayList;\r
import java.util.Arrays;\r
-import java.util.Collection;\r
import java.util.HashMap;\r
import java.util.List;\r
\r
return new GQuery(JSArray.create());\r
}\r
\r
- /**\r
- * Wrap a GQuery around a collection of existing widget.\r
- */\r
- public static GQuery $(Collection<Widget> widgetList){\r
- JSArray elements = JSArray.create();\r
- for (Widget w : widgetList){\r
- elements.addNode(w.getElement());\r
- }\r
- return $(elements);\r
- }\r
-\r
/**\r
* Wrap a GQuery around an existing element.\r
*/\r
}\r
\r
/**\r
- * Create a new GQuery given a list of objects. \r
- * Only node objects will be added;\r
+ * Create a new GQuery given a list of nodes, elements or widgets \r
*/\r
- public static GQuery $(@SuppressWarnings("rawtypes") ArrayList a) {\r
+ public static GQuery $(@SuppressWarnings("rawtypes")List nodesOrWidgets) {\r
JSArray elements = JSArray.create();\r
- if (a != null) {\r
- for (Object o : a ) {\r
+ if (nodesOrWidgets != null) {\r
+ for (Object o : nodesOrWidgets ) {\r
if (o instanceof Node) {\r
elements.addNode((Node)o);\r
} else if (o instanceof Widget) {\r
return $(Arrays.asList(widgets));\r
}\r
\r
- /**\r
- * Wrap a GQuery around a List of existing widget.\r
- */\r
- public static <T extends Widget> GQuery $(List<T> widgets){\r
- JSArray elements = JSArray.create();\r
- for (Widget w : widgets){\r
- elements.addNode(w.getElement());\r
- }\r
- return $(elements);\r
- }\r
-\r
/**\r
* Wrap a JSON object.\r
*/\r
* producing a new array containing the return values.\r
*/\r
@SuppressWarnings("unchecked")\r
- public <W> ArrayList<W> map(Function f) {\r
+ public <W> List<W> map(Function f) {\r
@SuppressWarnings("rawtypes")\r
ArrayList ret = new ArrayList();\r
for (int i = 0; i < elements().length; i++) {\r
import static com.google.gwt.query.client.plugins.Widgets.Widgets;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import com.google.gwt.core.client.GWT;
* Pass each element in the current matched set through a function,
* producing a new array containing the return values.
*/
- <W> ArrayList<W> map(Function f);
+ <W> List<W> map(Function f);
/**
* Bind a set of functions to the mousedown event of each matched element.
import static com.google.gwt.query.client.GQuery.$$;
import static com.google.gwt.query.client.GQuery.document;
-import java.util.ArrayList;
+import java.util.List;
import junit.framework.Assert;
assertEquals(true, isAttachedToTheDOM);
}
- @SuppressWarnings("unchecked")
public void testGQueryWidgets() {
final Button b1 = new Button("click-me");
RootPanel.get().add(b1);
String content = "<p id='1'/><p/><p id='2'/><p id='4'/>";
$(e).html(content);
- ArrayList<String> s = $("p", e).map(new Function() {
+ List<String> s = $("p", e).map(new Function() {
public Object f(Element e, int i) {
return null;
}
assertEquals("4", s.get(2));
- ArrayList<Element> a = $("p", e).map(new Function() {
+ List<Element> a = $("p", e).map(new Function() {
public Object f(Element e, int i) {
String id = $(e).attr("id");
return id.isEmpty() ? null: e;