*/
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.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.WidgetOptions;
-import com.google.gwt.query.client.plugins.widgets.ButtonWidgetFactory.ButtonOptions;
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.TabPanel;
+import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import java.util.ArrayList;
import java.util.List;
/**
* Create an return a {@link TabPanel} widget with the first selected
* elements. Each div element will create a tab and the first h3 element
- * inside the div will be used as title
+ * inside the div will be used as title. The <code>initFunctions</code> will
+ * be called on the new {@link TabPanel} created by passing it in parameter.
+ *
*/
- TabPanel tabPanel();
+ TabPanel tabPanel(Function... initFunctions);
/**
* Create an return a {@link TabPanel} widget with the first selected elements
- * by using a {@link TabPanelOptions}
+ * by using a {@link TabPanelOptions}. The <code>initFunctions</code> will be
+ * called on each new {@link Button} created by passing them in parameter.
*/
- TabPanel tabPanel(TabPanelOptions o);
+ TabPanel tabPanel(TabPanelOptions o, Function... initFunctions);
/**
* Create {@link TabPanel} widget for each selected elements. Each div element
* will create a tab and the first h3 element inside the div will be used as
* title
*/
- LazyWidgets<T> tabPanels();
+ LazyWidgets<T> tabPanels(Function... initFunctions);
/**
* 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> tabPanels(TabPanelOptions o);
+ LazyWidgets<T> tabPanels(TabPanelOptions o, Function... initFunctions);
/**
* Create an return a {@link Button} widget with the first element of the
- * query
+ * query.The <code>initFunctions</code> will be called on the new
+ * {@link Button} created by passing it in parameter.
+ *
*/
- Button button();
+ Button button(Function... initFunctions);
/**
- * Create and return a {@link Button} widget with the first element of the
- * query by using a {@link ButtonOptions}
+ * Create a {@link Button} widget for each selected element. The
+ * <code>initFunctions</code> will be called on each new {@link Button}
+ * created by passing them in parameter.
+ *
*/
- Button button(ButtonOptions o);
+ LazyWidgets<T> buttons(Function... initFunctions);
/**
- * Create a {@link Button} widget for each selected element.
+ * Create an return a {@link TextBox} widget with the first element of the
+ * query.The <code>initFunctions</code> will be called on the new
+ * {@link TextBox} created by passing it 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> buttons();
+ TextBox textBox(Function... initFunctions);
/**
- * Create a {@link Button} widget for each selected element by using a
- * {@link ButtonOptions}
- *
+ * Create a {@link TextBox} widget for each selected element. The
+ * <code>initFunctions</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> buttons(ButtonOptions o);
+ LazyWidgets<T> textBoxes(Function... initFunctions);
/**
* Create and return a widget using the given factory and the given options
*/
- <W extends Widget, O extends WidgetOptions> W widget( WidgetFactory<W, O> factory, O options);
+ <W extends Widget> W widget(WidgetFactory<W> factory, Function... initFunctions);
/**
* 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, O extends WidgetOptions> LazyWidgets<T> widgets( WidgetFactory<W, O> factory, O options);
+ <W extends Widget> LazyWidgets<T> widgets(WidgetFactory<W> factory, Function... initFunctions);
}
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.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.WidgetOptions;\r
-import com.google.gwt.query.client.plugins.widgets.ButtonWidgetFactory.ButtonOptions;\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.TabPanel;\r
+import com.google.gwt.user.client.ui.TextBox;\r
import com.google.gwt.user.client.ui.Widget;\r
\r
import java.util.ArrayList;\r
import java.util.List;\r
\r
/**\r
- * Widgets plugin for Gwt Query.\r
- * Be careful, this plugin is still experimental. The api can change in next releases.\r
+ * Widgets plugin for Gwt Query. Be careful, this plugin is still experimental.\r
+ * The api can change in next releases.\r
*/\r
public class Widgets extends QueuePlugin<Widgets> {\r
\r
/**\r
* Create an return a {@link TabPanel} widget with the first selected\r
* elements. Each div element will create a tab and the first h3 element\r
- * inside the div will be used as title\r
+ * inside the div will be used as title. The <code>initFunctions</code> will\r
+ * be called on the new {@link TabPanel} created by passing it in parameter.\r
+ * \r
*/\r
- public TabPanel tabPanel() {\r
+ public TabPanel tabPanel(Function... initFunctions) {\r
return tabPanel(new TabPanelOptions());\r
}\r
\r
/**\r
* Create an return a {@link TabPanel} widget with the first selected elements\r
- * by using a {@link TabPanelOptions}\r
+ * by using a {@link TabPanelOptions}. The <code>initFunctions</code> will be\r
+ * called on each new {@link Button} created by passing them in parameter.\r
*/\r
- public TabPanel tabPanel(TabPanelOptions o) {\r
- return widget(new TabPanelWidgetFactory(), o);\r
+ public TabPanel tabPanel(TabPanelOptions o, Function... initFunctions) {\r
+ return widget(new TabPanelWidgetFactory(o), initFunctions);\r
}\r
\r
/**\r
* will create a tab and the first h3 element inside the div will be used as\r
* title\r
*/\r
- public Widgets tabPanels() {\r
- return tabPanels(new TabPanelOptions());\r
+ public Widgets tabPanels(Function... initFunctions) {\r
+ return tabPanels(new TabPanelOptions(), initFunctions);\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 tabPanels(TabPanelOptions o) {\r
- return widgets(new TabPanelWidgetFactory(), o);\r
+ public Widgets tabPanels(TabPanelOptions o, Function... initFunctions) {\r
+ return widgets(new TabPanelWidgetFactory(o), initFunctions);\r
}\r
\r
/**\r
* Create an return a {@link Button} widget with the first element of the\r
- * query\r
+ * query.The <code>initFunctions</code> will be called on the new\r
+ * {@link Button} created by passing it in parameter.\r
+ * \r
*/\r
- public Button button() {\r
- return button(new ButtonOptions());\r
+ public Button button(Function... initFunctions) {\r
+ return widget(new ButtonWidgetFactory(), initFunctions);\r
}\r
\r
/**\r
- * Create and return a {@link Button} widget with the first element of the\r
- * query by using a {@link ButtonOptions}\r
+ * Create a {@link Button} widget for each selected element. The\r
+ * <code>initFunctions</code> will be called on each new {@link Button}\r
+ * created by passing them in parameter.\r
+ * \r
*/\r
- public Button button(ButtonOptions o) {\r
- return widget(new ButtonWidgetFactory(), o);\r
+ public Widgets buttons(Function... initFunctions) {\r
+ return widgets(new ButtonWidgetFactory(), initFunctions);\r
}\r
\r
/**\r
- * Create a {@link Button} widget for each selected element.\r
+ * Create an return a {@link TextBox} widget with the first element of the\r
+ * query.The <code>initFunctions</code> will be called on the new\r
+ * {@link TextBox} created by passing it in parameter.\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 buttons() {\r
- return buttons(new ButtonOptions());\r
+ public TextBox textBox(Function... initFunctions) {\r
+ return widget(new TextBoxWidgetFactory(), initFunctions);\r
}\r
\r
/**\r
- * Create a {@link Button} widget for each selected element by using a\r
- * {@link ButtonOptions}\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
+ * created by passing them in parameter.\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 buttons(ButtonOptions o) {\r
- return widgets(new ButtonWidgetFactory(), o);\r
+ public Widgets textBoxes(Function... initFunctions) {\r
+ return widgets(new TextBoxWidgetFactory(), initFunctions);\r
}\r
\r
/**\r
* Create and return a widget using the given factory and the given options\r
*/\r
- public <W extends Widget, O extends WidgetOptions> W widget(\r
- WidgetFactory<W, O> factory, O options) {\r
- return widget(get(0), factory, options);\r
+ public <W extends Widget> W widget(WidgetFactory<W> factory,\r
+ Function... initFunctions) {\r
+\r
+ return widget(get(0), factory, initFunctions);\r
}\r
\r
/**\r
* each element of the query. Returns a new gquery set of elements with the\r
* new widgets created.\r
*/\r
- public <W extends Widget, O extends WidgetOptions> Widgets widgets(\r
- WidgetFactory<W, O> factory, O options) {\r
+ public <W extends Widget> Widgets widgets(WidgetFactory<W> factory,\r
+ Function... initFunctions) {\r
+\r
List<Element> result = new ArrayList<Element>();\r
+\r
for (Element e : elements()) {\r
- result.add(widget(e, factory, options).getElement());\r
+ result.add(widget(e, factory, initFunctions).getElement());\r
}\r
+\r
return $(result).as(Widgets);\r
}\r
\r
* Create and return a widget using the given factory and the given options\r
*/\r
protected <W extends Widget, O extends WidgetOptions> W widget(Element e,\r
- WidgetFactory<W, O> factory, O options) {\r
- return factory.create(e, options);\r
+ WidgetFactory<W> factory, Function... initFunctions) {\r
+\r
+ W widget = factory.create(e);\r
+\r
+ if (initFunctions != null) {\r
+ for (Function initFunction : initFunctions) {\r
+ initFunction.f(widget);\r
+ }\r
+ }\r
+\r
+ return widget;\r
+\r
}\r
\r
}\r
+++ /dev/null
-package com.google.gwt.query.client.plugins.widgets;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * Abstract factory containing useful methods for widget creation
- *
- */
-public abstract class AbstractWidgetFactory<W extends Widget, O extends WidgetOptions>
- implements WidgetFactory<W, O> {
-
- public W create(Element e, O options) {
- W w = createWidget(e);
-
- initialize(w, options, e);
-
- return w;
- }
-
- protected abstract void initialize(W widget, O options, Element e);
-
- protected abstract W createWidget(Element e);
-
- /**
- * Test if the tag name of the element is one of tag names given in parameter
- *
- * @param tagNames
- * @return
- */
- protected boolean matchesTags(Element e, String... tagNames) {
-
- assert e != null : "Element cannot be null";
-
- StringBuilder regExp = new StringBuilder("^(");
- int tagNameLenght = tagNames != null ? tagNames.length : 0;
- for (int i = 0; i < tagNameLenght; i++) {
- regExp.append(tagNames[i].toUpperCase());
- if (i < tagNameLenght - 1) {
- regExp.append("|");
- }
- }
- regExp.append(")$");
-
- return e.getTagName().toUpperCase().matches(regExp.toString());
-
- }
-
-}
\ No newline at end of file
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.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* Factory used to create a {@link Button} widget. A {@link Button} is created
* if the element is a <i>button</i>, <i>div></i>, <i>span</i> or <i>a</i>
* element (should be extends to other element).
*/
-public class ButtonWidgetFactory extends
- AbstractWidgetFactory<Button, ButtonWidgetFactory.ButtonOptions> {
-
- /**
- * Options used to initialize new {@link Button}
- *
- */
- public static class ButtonOptions implements WidgetOptions {
-
- private List<ClickHandler> clickHandlers;
-
- public ButtonOptions() {
- clickHandlers = new ArrayList<ClickHandler>();
- }
-
- public void addClickHandler(ClickHandler clickHandler) {
- clickHandlers.add(clickHandler);
- }
-
- public List<ClickHandler> getClickHandlers() {
- return clickHandlers;
- }
- }
-
- protected void initialize(Button button, ButtonOptions options, Element e) {
- if (button == null || options == null) {
- return;
- }
-
- for (ClickHandler handler : options.getClickHandlers()) {
- button.addClickHandler(handler);
- }
-
- }
+public class ButtonWidgetFactory implements WidgetFactory<Button> {
- protected Button createWidget(Element e) {
+ public Button create(Element e) {
if ("button".equalsIgnoreCase(e.getTagName())) {
return Button.wrap(e);
}
- if (matchesTags(e, "div", "span", "a")) {
+ if (WidgetsUtils.matchesTags(e, "div", "span", "a")) {
ButtonElement buttonElement = Document.get().createPushButtonElement();
- e.getParentElement().insertAfter(buttonElement, e);
- // detach the original element (can be maybe hidden instead of detach
- // it?)
- e.removeFromParent();
+
+ WidgetsUtils.replace(e, buttonElement);
Button b = Button.wrap(buttonElement);
b.setHTML(e.getInnerHTML()); // maybe use setText and getInnerText
--- /dev/null
+package com.google.gwt.query.client.plugins.widgets;
+
+import static com.google.gwt.query.client.GQuery.$;
+
+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.query.client.GQuery;
+import com.google.gwt.user.client.ui.PasswordTextBox;
+
+/**
+ * Factory used to create a {@link PasswordTextBox} widget. 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.
+ *
+ */
+public class PasswordTextBoxWidgetFactory implements WidgetFactory<PasswordTextBox> {
+
+ public PasswordTextBox create(Element e) {
+
+ GQuery input = $(e).filter("input[type='passowrd']");
+
+ if (input.get(0) != null) {
+ return PasswordTextBox.wrap(e);
+ }
+
+ if (WidgetsUtils.matchesTags(e, "div", "span")) {
+ InputElement inputElement = Document.get().createPasswordInputElement();
+
+ WidgetsUtils.replace(e, inputElement);
+
+
+ PasswordTextBox textBox = PasswordTextBox.wrap(inputElement);
+ textBox.setValue(e.getInnerText()); // maybe use setText and getInnerText
+
+ return textBox;
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TabPanel;
-
/**
* Factory used to create a {@link Button} widget. A {@link Button} is created
* if the element is a <i>button</i>, <i>div></i>, <i>span</i> or <i>a</i>
* element (should be extends to other element).
*/
-public class TabPanelWidgetFactory extends
- AbstractWidgetFactory<TabPanel, TabPanelWidgetFactory.TabPanelOptions> {
-
- public static class ExtendedTabPanel extends TabPanel{
-
-
- void attach(){
- onAttach();
- RootPanel.detachOnWindowClose(this);
- }
- }
+public class TabPanelWidgetFactory implements WidgetFactory<TabPanel> {
+
/**
* Options used to initialize new {@link Button}
titleSelector = "h3";
}
}
+
+ private static class ExtendedTabPanel extends TabPanel {
+
+ void attach() {
+ onAttach();
+ RootPanel.detachOnWindowClose(this);
+ }
+ }
+
+ private TabPanelOptions options;
+
+ public TabPanelWidgetFactory(TabPanelOptions o) {
+ this.options = o;
+ }
+
+ public TabPanel create(Element e) {
+ ExtendedTabPanel tabPanel = new ExtendedTabPanel();
+
+ initialize(tabPanel, options, e);
+
+ return tabPanel;
+ }
+
- protected void initialize(TabPanel tabPanel, TabPanelOptions options,
+ protected void initialize(ExtendedTabPanel tabPanel, TabPanelOptions options,
Element e) {
GQuery tabs = $(options.getTabSelector(), e);
tabPanel.add(new HTMLPanel(tab.getString()), title != null
? title.getInnerText() : "Tab " + (i + 1));
-
-
}
-
- if (tabs.length() > 0){
+
+ if (tabs.length() > 0) {
tabPanel.selectTab(0);
}
- // the tab panel is initialized, attach it to the dom ;
- e.getParentElement().insertBefore(tabPanel.getElement(), e);
- ((ExtendedTabPanel)tabPanel).attach();
-
- // detach the element as it is replaced by the tab panel !
- e.removeFromParent();
- }
+ WidgetsUtils.replace(e, tabPanel.getElement());
- protected TabPanel createWidget(Element e) {
- return new ExtendedTabPanel();
+ tabPanel.attach();
}
}
--- /dev/null
+package com.google.gwt.query.client.plugins.widgets;
+
+import static com.google.gwt.query.client.GQuery.$;
+
+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.query.client.GQuery;
+import com.google.gwt.user.client.ui.TextBox;
+
+/**
+ * Factory used to create a {@link TextBox} widget. 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.
+ *
+ */
+public class TextBoxWidgetFactory implements WidgetFactory<TextBox> {
+
+ public TextBox create(Element e) {
+
+ GQuery input = $(e).filter("input[type='text']");
+
+ if (input.get(0) != null) {
+ return TextBox.wrap(e);
+ }
+
+ if (WidgetsUtils.matchesTags(e, "div", "span")) {
+ InputElement inputElement = Document.get().createTextInputElement();
+
+ WidgetsUtils.replace(e, inputElement);
+
+ TextBox textBox = TextBox.wrap(inputElement);
+ textBox.setValue(e.getInnerText()); // maybe use setText and getInnerText
+
+ return textBox;
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
* @param <W>
* @param <O>
*/
- public interface WidgetFactory<W extends Widget, O extends WidgetOptions> {
- public W create(Element e, O options);
+ public interface WidgetFactory<W extends Widget> {
+ public W create(Element e);
}
\ No newline at end of file
--- /dev/null
+package com.google.gwt.query.client.plugins.widgets;
+
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.query.client.GQuery;
+
+public class WidgetsUtils {
+
+ /**
+ * Test if the tag name of the element is one of tag names given in parameter
+ *
+ * @param tagNames
+ * @return
+ */
+ static boolean matchesTags(Element e, String... tagNames) {
+
+ assert e != null : "Element cannot be null";
+
+ StringBuilder regExp = new StringBuilder("^(");
+ int tagNameLenght = tagNames != null ? tagNames.length : 0;
+ for (int i = 0; i < tagNameLenght; i++) {
+ regExp.append(tagNames[i].toUpperCase());
+ if (i < tagNameLenght - 1) {
+ regExp.append("|");
+ }
+ }
+ regExp.append(")$");
+
+ return e.getTagName().toUpperCase().matches(regExp.toString());
+
+ }
+
+ /**
+ * replace the <code>oldElement</code> by the <code>newElement</code>
+ *
+ * @param oldElement
+ * @param newElement
+ */
+ static void replace(Element oldElement, Element newElement) {
+ assert oldElement != null && newElement != null;
+
+ GQuery.$(oldElement).replaceWith(newElement);
+
+ }
+}
import com.google.gwt.event.dom.client.ClickEvent;\r
import com.google.gwt.event.dom.client.ClickHandler;\r
import com.google.gwt.query.client.Function;\r
-import com.google.gwt.query.client.GQuery;\r
-import com.google.gwt.query.client.css.CSS;\r
-import com.google.gwt.query.client.css.Length;\r
-import com.google.gwt.query.client.css.RGBColor;\r
-import com.google.gwt.query.client.css.UriValue;\r
-import com.google.gwt.query.client.css.BackgroundAttachmentProperty.BackgroundAttachment;\r
-import com.google.gwt.query.client.css.BackgroundPositionProperty.BackgroundPosition;\r
-import com.google.gwt.query.client.css.BackgroundRepeatProperty.BackgroundRepeat;\r
-import com.google.gwt.query.client.plugins.widgets.ButtonWidgetFactory.ButtonOptions;\r
-import com.google.gwt.user.client.Window;\r
import com.google.gwt.user.client.ui.Button;\r
import com.google.gwt.user.client.ui.Label;\r
import com.google.gwt.user.client.ui.PopupPanel;\r
+import com.google.gwt.user.client.ui.Widget;\r
\r
public class GwtQueryWidgetModule implements EntryPoint {\r
\r
-/* public void onModuleLoad() {\r
- $("<button>Enhance</button>").appendTo(".outer").one(Event.ONCLICK, null, new Function() {\r
- public boolean f(Event e) {\r
- $(".btn:nth-child(odd)").each(new Function(){\r
- public void f(Element el) {\r
- // Replace odd labels by a button\r
- GQuery g = $("<button/>");\r
- $(el).hide().after(g);\r
- \r
- // Use the Widgets plugin to convert the button element to a button.\r
- Button b = g.as(Widgets.Widgets).widget();\r
- b.setText("Foo");\r
- b.addClickHandler(new ClickHandler() {\r
- public void onClick(ClickEvent clickEvent) {\r
- Window.alert("You Clicked the Button");\r
- }\r
- });\r
- }\r
- });\r
- return true;\r
- }\r
- });\r
- }*/\r
- \r
public void onModuleLoad() {\r
+\r
+ $(".inputText").as(Widgets).textBoxes();\r
\r
- \r
- // Let gquery syntax to help gwt developers. \r
- GQuery buttons = $(".btn").as(Widgets).buttons().click(new Function() {\r
- public void f() {\r
- Label l = new Label("You click on a GWT Button !");\r
- PopupPanel panel = new PopupPanel(true, true);\r
- panel.setGlassEnabled(true);\r
- panel.add(l);\r
- panel.center();\r
- }\r
- });\r
- \r
- // The user use a widget in the traditional way\r
- buttons.eq(0).<Button>widget().addClickHandler(new ClickHandler() {\r
- public void onClick(ClickEvent event) {\r
- Window.alert("You clicked in the first button");\r
- }\r
- });\r
- \r
- $("#tabs").as(Widgets).tabPanel();\r
- \r
- // IDE suggestions are not available with this syntax. -> I agree\r
- // Also it implies that the css method in GQuery needs more overloads\r
- // $("#aaa").css(CSS.POSITION, Position.ABSOLUTE);\r
- // $("#aaa").css(CSS.TOP, Length.cm(15));\r
- // $("#aaa").css(CSS.BACKGROUND, RGBColor.RED, ImageValue.url(""), BackgroundRepeat.NO_REPEAT, BackgroundAttachment.FIXED, BackgroundPosition.CENTER);\r
- \r
- $("#aaa").css(CSS.TOP.with(Length.cm(15)));\r
- $("#aaa").css(CSS.BACKGROUND.with(RGBColor.SILVER, UriValue.url(""), BackgroundRepeat.NO_REPEAT, BackgroundAttachment.FIXED, BackgroundPosition.CENTER)); \r
- $("#aaa").css(CSS.BACKGROUND_ATTACHMENT.with(BackgroundAttachment.FIXED));\r
- }\r
- \r
- private ButtonOptions createButtonOptions(){\r
- ButtonOptions options = new ButtonOptions();\r
- options.addClickHandler(new ClickHandler() {\r
+ $(".btn").as(Widgets).buttons(new Function() {\r
\r
- public void onClick(ClickEvent event) {\r
- Label l = new Label("You click on a GWT Button !");\r
- PopupPanel panel = new PopupPanel(true, true);\r
- panel.setGlassEnabled(true);\r
- panel.add(l);\r
- panel.center();\r
+ public void f(Widget w) {\r
\r
+ Button button = (Button) w;\r
+ button.addClickHandler(new ClickHandler() {\r
+\r
+ public void onClick(ClickEvent event) {\r
+ Label l = new Label("You click on a GWT Button !");\r
+ PopupPanel panel = new PopupPanel(true, true);\r
+ panel.setGlassEnabled(true);\r
+ panel.add(l);\r
+ panel.center();\r
+\r
+ }\r
+ });\r
+\r
}\r
+ \r
});\r
+\r
+ $("#tabs").as(Widgets).tabPanel();\r
\r
- return options;\r
+ \r
+\r
}\r
+\r
}\r
src="gwtquery.samples.GwtQueryWidgets.nocache.js"></script>\r
</head>\r
<body>\r
-<div id='aaa'>aaa</div>\r
+\r
<div class="outer">\r
<div class="btn">Make me a button 1!</div>\r
<a class="btn">Make me a button 2!</a> <span class="btn">Make me\r
<div class="btn">Make me a button 6!</div>\r
</div>\r
\r
+<div class="inputText">I will be an Input</div>\r
+<span class="inputText">I will be an Input</span>\r
+<input class="inputText" type="text"></input>\r
+\r
<div id="tabs">\r
<h3>First tab</h3>\r
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut\r