*/
package com.google.gwt.query.client.plugins;
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.plugins.widgets.ButtonWidgetFactory;
import com.google.gwt.query.client.plugins.widgets.DateBoxWidgetFactory;
import com.google.gwt.query.client.plugins.widgets.TabPanelWidgetFactory;
import com.google.gwt.query.client.plugins.widgets.TextBoxWidgetFactory;
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.DisclosurePanelWidgetFactory.DisclosurePanelOptions;
import com.google.gwt.query.client.plugins.widgets.ListBoxWidgetFactory.ListBoxOptions;
import com.google.gwt.query.client.plugins.widgets.TabPanelWidgetFactory.TabPanelOptions;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DisclosurePanel;
+import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.TextBox;
* will create a tab and the first h3 element inside the div will be used as
* title
*/
- LazyWidgets<T> tabPanel(Function... initFunctions);
+ LazyWidgets<T> tabPanel(WidgetInitializer... initializers);
/**
- * Create a {@link DisclosurePanel} widget for each selected elements.
+ * Create a {@link DisclosurePanel} widget for each selected elements.
*/
- LazyWidgets<T> disclosurePanel(DisclosurePanelOptions o, Function... initFunctions);
+ LazyWidgets<T> disclosurePanel(DisclosurePanelOptions o, WidgetInitializer... initializers);
/**
- * Create {@link DisclosurePanel} widget for each selected elements.
+ * Create {@link DisclosurePanel} widget for each selected elements.
*/
- LazyWidgets<T> disclosurePanel(Function... initFunctions);
+ LazyWidgets<T> disclosurePanel(WidgetInitializer... initializers);
/**
* Create a {@link TabPanel} widget for each selected elements. Each div
* element inside a selected element will create a tab and the first h3
* element inside the div will be used as title
*/
- LazyWidgets<T> tabPanel(TabPanelOptions o, Function... initFunctions);
+ LazyWidgets<T> tabPanel(TabPanelOptions o, WidgetInitializer... initializers);
/**
* Create a {@link Button} widget for each selected element. The
- * <code>initFunctions</code> will be called on each new {@link Button}
+ * <code>initializers</code> will be called on each new {@link Button}
* created by passing them in parameter.
*
*/
- LazyWidgets<T> button(Function... initFunctions);
+ LazyWidgets<T> button(WidgetInitializer... initializers);
/**
* Create a {@link DateBox} widget for each selected element. The
- * <code>initFunctions</code> will be called on each new {@link Button}
+ * <code>initializers</code> will be called on each new {@link Button}
* created by passing them in parameter.
*/
- LazyWidgets<T> datebox(Function... initFunctions);
+ LazyWidgets<T> datebox(WidgetInitializer... initializers);
- LazyWidgets<T> richtext(Function... initFunctions);
+ LazyWidgets<T> richtext(WidgetInitializer... initializers);
/**
* Create a {@link TextBox} widget for each selected element. The
- * <code>initFunctions</code> will be called on each new {@link TextBox}
+ * <code>initializers</code> will be called on each new {@link TextBox}
* created by passing them in parameter.
- *
+ *
* A {@link TextBox} is created if the element is a <i>input</i> with type
* text, a <i>div</i> or a<i>span</i> element.
*/
- LazyWidgets<T> textBox(Function... initFunctions);
+ LazyWidgets<T> textBox(WidgetInitializer... initializers);
/**
* Create a {@link PasswordTextBox} widget for each selected element. The
- * <code>initFunctions</code> will be called on each new {@link PasswordTextBox}
- * created by passing them in parameter.
- *
- * A {@link PasswordTextBox} is created if the element is a <i>input</i> with type
- * <i>password</i>, a <i>div</i> or a<i>span</i> element.
+ * <code>initializers</code> will be called on each new
+ * {@link PasswordTextBox} created by passing them in parameter.
+ *
+ * A {@link PasswordTextBox} is created if the element is a <i>input</i> with
+ * type <i>password</i>, a <i>div</i> or a<i>span</i> element.
*/
- LazyWidgets<T> passwordBox(Function... initFunctions);
+ LazyWidgets<T> passwordBox(WidgetInitializer... initializers);
/**
* Create a {@link ListBox} widget for each selected element. The
- * <code>initFunctions</code> will be called on each new {@link ListBox}
+ * <code>initializers</code> will be called on each new {@link ListBox}
* created by passing them in parameter.
- *
+ *
* A {@link ListBox} is created if the element is a <i>input</i> with type
* <i>password</i>, a <i>div</i> or a<i>span</i> element.
*/
- LazyWidgets<T> listBox(Function... initFunctions);
+ LazyWidgets<T> listBox(WidgetInitializer... initializers);
/**
* Create a {@link ListBox} widget for each selected element. The
- * <code>initFunctions</code> will be called on each new {@link ListBox}
+ * <code>initializers</code> will be called on each new {@link ListBox}
* created by passing them in parameter.
- *
+ *
* A {@link ListBox} is created if the element is a <i>input</i> with type
* <i>password</i>, a <i>div</i> or a<i>span</i> element.
*/
- LazyWidgets<T> listBox(ListBoxOptions options, Function... initFunctions);
+ LazyWidgets<T> listBox(ListBoxOptions options, WidgetInitializer... initializers);
/**
* 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, Function... initFunctions);
+ <W extends Widget> LazyWidgets<T> widgets(WidgetFactory<W> factory, WidgetInitializer... initializers);
}
package com.google.gwt.query.client.plugins;\r
\r
import com.google.gwt.dom.client.Element;\r
-import com.google.gwt.query.client.Function;\r
import com.google.gwt.query.client.GQuery;\r
import com.google.gwt.query.client.plugins.widgets.ButtonWidgetFactory;\r
import com.google.gwt.query.client.plugins.widgets.DateBoxWidgetFactory;\r
import com.google.gwt.query.client.plugins.widgets.TabPanelWidgetFactory;\r
import com.google.gwt.query.client.plugins.widgets.TextBoxWidgetFactory;\r
import com.google.gwt.query.client.plugins.widgets.WidgetFactory;\r
+import com.google.gwt.query.client.plugins.widgets.WidgetInitializer;\r
import com.google.gwt.query.client.plugins.widgets.DisclosurePanelWidgetFactory.DisclosurePanelOptions;\r
import com.google.gwt.query.client.plugins.widgets.ListBoxWidgetFactory.ListBoxOptions;\r
import com.google.gwt.query.client.plugins.widgets.TabPanelWidgetFactory.TabPanelOptions;\r
import com.google.gwt.user.client.ui.Button;\r
import com.google.gwt.user.client.ui.DisclosurePanel;\r
+import com.google.gwt.user.client.ui.ListBox;\r
import com.google.gwt.user.client.ui.PasswordTextBox;\r
import com.google.gwt.user.client.ui.TabPanel;\r
import com.google.gwt.user.client.ui.TextBox;\r
*/\r
public class Widgets extends QueuePlugin<Widgets> {\r
\r
+ \r
public static final Class<Widgets> Widgets = Widgets.class;\r
\r
static {\r
super(gq);\r
}\r
\r
-\r
/**\r
* Create {@link TabPanel} widget for each selected elements. Each div element\r
* will create a tab and the first h3 element inside the div will be used as\r
* title\r
*/\r
- public Widgets tabPanel(Function... initFunctions) {\r
- return tabPanel(new TabPanelOptions(), initFunctions);\r
+ public Widgets tabPanel(WidgetInitializer... initializers) {\r
+ return tabPanel(new TabPanelOptions(), initializers);\r
}\r
\r
/**\r
- * Create a {@link DisclosurePanel} widget for each selected elements. \r
+ * Create a {@link DisclosurePanel} widget for each selected elements.\r
*/\r
- public Widgets disclosurePanel(DisclosurePanelOptions o, Function... initFunctions) {\r
- return widgets(new DisclosurePanelWidgetFactory(o), initFunctions);\r
+ public Widgets disclosurePanel(DisclosurePanelOptions o,\r
+ WidgetInitializer... initializers) {\r
+ return widgets(new DisclosurePanelWidgetFactory(o), initializers);\r
}\r
- \r
+\r
/**\r
- * Create {@link DisclosurePanel} widget for each selected elements. \r
+ * Create {@link DisclosurePanel} widget for each selected elements.\r
*/\r
- public Widgets disclosurePanel(Function... initFunctions) {\r
- return disclosurePanel(new DisclosurePanelOptions(), initFunctions);\r
+ public Widgets disclosurePanel(WidgetInitializer... initializers) {\r
+ return disclosurePanel(new DisclosurePanelOptions(), initializers);\r
}\r
\r
/**\r
* element inside a selected element will create a tab and the first h3\r
* element inside the div will be used as title\r
*/\r
- public Widgets tabPanel(TabPanelOptions o, Function... initFunctions) {\r
- return widgets(new TabPanelWidgetFactory(o), initFunctions);\r
+ public Widgets tabPanel(TabPanelOptions o, WidgetInitializer... initializers) {\r
+ return widgets(new TabPanelWidgetFactory(o), initializers);\r
}\r
\r
-\r
/**\r
* Create a {@link Button} widget for each selected element. The\r
- * <code>initFunctions</code> will be called on each new {@link Button}\r
+ * <code>initializers</code> will be called on each new {@link Button}\r
* created by passing them in parameter.\r
* \r
*/\r
- public Widgets button(Function... initFunctions) {\r
- return widgets(new ButtonWidgetFactory(), initFunctions);\r
+ public Widgets button(WidgetInitializer... initializers) {\r
+ return widgets(new ButtonWidgetFactory(), initializers);\r
}\r
\r
/**\r
* Create a {@link DateBox} widget for each selected element. The\r
- * <code>initFunctions</code> will be called on each new {@link Button}\r
+ * <code>initializers</code> will be called on each new {@link Button}\r
* created by passing them in parameter.\r
*/\r
- public Widgets datebox(Function... initFunctions) {\r
- return widgets(new DateBoxWidgetFactory(), initFunctions);\r
+ public Widgets datebox(WidgetInitializer... initializers) {\r
+ return widgets(new DateBoxWidgetFactory(), initializers);\r
}\r
- \r
- public Widgets richtext(Function... initFunctions) {\r
- return widgets(new RichTextWidgetFactory(), initFunctions);\r
+\r
+ public Widgets richtext(WidgetInitializer... initializers) {\r
+ return widgets(new RichTextWidgetFactory(), initializers);\r
}\r
- \r
+\r
/**\r
* Create a {@link TextBox} widget for each selected element. The\r
- * <code>initFunctions</code> will be called on each new {@link TextBox}\r
+ * <code>initializers</code> will be called on each new {@link TextBox}\r
* created by passing them in parameter.\r
- *\r
+ * \r
* A {@link TextBox} is created if the element is a <i>input</i> with type\r
* text, a <i>div</i> or a<i>span</i> element.\r
*/\r
- public Widgets textBox(Function... initFunctions) {\r
- return widgets(new TextBoxWidgetFactory(), initFunctions);\r
+ public Widgets textBox(WidgetInitializer... initializers) {\r
+ return widgets(new TextBoxWidgetFactory(), initializers);\r
}\r
\r
/**\r
* Create a {@link PasswordTextBox} widget for each selected element. The\r
- * <code>initFunctions</code> will be called on each new {@link PasswordTextBox}\r
- * created by passing them in parameter.\r
- *\r
- * A {@link PasswordTextBox} is created if the element is a <i>input</i> with type\r
- * <i>password</i>, a <i>div</i> or a<i>span</i> element.\r
+ * <code>initializers</code> will be called on each new\r
+ * {@link PasswordTextBox} created by passing them in parameter.\r
+ * \r
+ * A {@link PasswordTextBox} is created if the element is a <i>input</i> with\r
+ * type <i>password</i>, a <i>div</i> or a<i>span</i> element.\r
*/\r
- public Widgets passwordBox(Function... initFunctions) {\r
- return widgets(new PasswordTextBoxWidgetFactory(), initFunctions);\r
+ public Widgets passwordBox(WidgetInitializer... initializers) {\r
+ return widgets(new PasswordTextBoxWidgetFactory(), initializers);\r
}\r
- \r
+\r
/**\r
* Create a {@link ListBox} widget for each selected element. The\r
- * <code>initFunctions</code> will be called on each new {@link ListBox}\r
+ * <code>initializers</code> will be called on each new {@link ListBox}\r
* created by passing them in parameter.\r
- *\r
+ * \r
* A {@link ListBox} is created if the element is a <i>input</i> with type\r
* <i>password</i>, a <i>div</i> or a<i>span</i> element.\r
*/\r
- public Widgets listBox(Function... initFunctions) {\r
- return listBox(new ListBoxOptions(), initFunctions);\r
+ public Widgets listBox(WidgetInitializer... initializers) {\r
+ return listBox(new ListBoxOptions(), initializers);\r
}\r
- \r
+\r
/**\r
* Create a {@link ListBox} widget for each selected element. The\r
- * <code>initFunctions</code> will be called on each new {@link ListBox}\r
+ * <code>initializers</code> will be called on each new {@link ListBox}\r
* created by passing them in parameter.\r
- *\r
+ * \r
* A {@link ListBox} is created if the element is a <i>input</i> with type\r
* <i>password</i>, a <i>div</i> or a<i>span</i> element.\r
*/\r
- public Widgets listBox(ListBoxOptions options, Function... initFunctions) {\r
- return widgets(new ListBoxWidgetFactory(options), initFunctions);\r
+ public Widgets listBox(ListBoxOptions options, WidgetInitializer... initializers) {\r
+ return widgets(new ListBoxWidgetFactory(options), initializers);\r
}\r
\r
- \r
/**\r
* Create and return a widget using the given factory and the given options\r
*/\r
protected <W extends Widget> W widget(WidgetFactory<W> factory,\r
- Function... initFunctions) {\r
+ WidgetInitializer... initializers) {\r
\r
- return widget(get(0), factory, initFunctions);\r
+ return widget(get(0), factory, initializers);\r
}\r
\r
/**\r
* new widgets created.\r
*/\r
public <W extends Widget> Widgets widgets(WidgetFactory<W> factory,\r
- Function... initFunctions) {\r
+ WidgetInitializer... initializers) {\r
List<Element> result = new ArrayList<Element>();\r
for (Element e : elements()) {\r
- W w = widget(e, factory, initFunctions);\r
+ W w = widget(e, factory, initializers);\r
if (w != null) {\r
result.add(w.getElement());\r
}\r
/**\r
* Create and return a widget using the given factory and the given options\r
*/\r
- protected <W extends Widget> W widget(Element e,\r
- WidgetFactory<W> factory, Function... initFunctions) {\r
- \r
- if ($(e).widget() != null){\r
- //a widget is already attached on this element !!\r
+ protected <W extends Widget> W widget(Element e, WidgetFactory<W> factory,\r
+ WidgetInitializer... initializers) {\r
+\r
+ if ($(e).widget() != null) {\r
+ // a widget is already attached on this element !!\r
return null;\r
}\r
- \r
+\r
W widget = factory.create(e);\r
\r
- if (initFunctions != null) {\r
- for (Function initFunction : initFunctions) {\r
- initFunction.f(widget);\r
+ if (initializers != null) {\r
+ for (WidgetInitializer initializer : initializers) {\r
+ initializer.initialize(widget, e);\r
}\r
}\r
\r
\r
}\r
\r
-\r
}\r