*/\r
package com.google.gwt.query.client.plugins;\r
\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
import com.google.gwt.dom.client.Element;\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.CheckBoxWidgetFactory;\r
-import com.google.gwt.query.client.plugins.widgets.DateBoxWidgetFactory;\r
-import com.google.gwt.query.client.plugins.widgets.DecoratorPanelWidgetFactory;\r
-import com.google.gwt.query.client.plugins.widgets.DisclosurePanelWidgetFactory;\r
-import com.google.gwt.query.client.plugins.widgets.ListBoxWidgetFactory;\r
-import com.google.gwt.query.client.plugins.widgets.PasswordTextBoxWidgetFactory;\r
-import com.google.gwt.query.client.plugins.widgets.RadioButtonWidgetFactory;\r
-import com.google.gwt.query.client.plugins.widgets.StackPanelWidgetFactory;\r
-import com.google.gwt.query.client.plugins.widgets.SuggestBoxWidgetFactory;\r
-import com.google.gwt.query.client.plugins.widgets.TabPanelWidgetFactory;\r
-import com.google.gwt.query.client.plugins.widgets.TextAreaWidgetFactory;\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.WidgetsUtils;\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.RadioButtonWidgetFactory.RadioButtonOption;\r
-import com.google.gwt.query.client.plugins.widgets.StackPanelWidgetFactory.StackPanelOptions;\r
-import com.google.gwt.query.client.plugins.widgets.SuggestBoxWidgetFactory.SuggestBoxOptions;\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.CheckBox;\r
-import com.google.gwt.user.client.ui.DecoratorPanel;\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.RadioButton;\r
-import com.google.gwt.user.client.ui.StackPanel;\r
-import com.google.gwt.user.client.ui.SuggestBox;\r
-import com.google.gwt.user.client.ui.TabPanel;\r
-import com.google.gwt.user.client.ui.TextArea;\r
-import com.google.gwt.user.client.ui.TextBox;\r
import com.google.gwt.user.client.ui.Widget;\r
-import com.google.gwt.user.datepicker.client.DateBox;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
\r
/**\r
* Widgets plugin for Gwt Query. Be careful, this plugin is still experimental.\r
super(gq);\r
}\r
\r
- /**\r
- * Create a {@link Button} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link Button} created\r
- * by passing them in parameter.\r
- * \r
- */\r
- public Widgets button() {\r
- return widgets(new ButtonWidgetFactory(), null);\r
- }\r
-\r
- /**\r
- * Create a {@link Button} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link Button} created\r
- * by passing them in parameter.\r
- * \r
- */\r
- public Widgets button(WidgetInitializer<Button> initializers) {\r
- return widgets(new ButtonWidgetFactory(), initializers);\r
- }\r
-\r
- /**\r
- * Create a {@link DateBox} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link Button} created\r
- * by passing them in parameter.\r
- */\r
- public Widgets datebox() {\r
- return widgets(new DateBoxWidgetFactory(), null);\r
- }\r
-\r
- /**\r
- * Create a {@link DateBox} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link Button} created\r
- * by passing them in parameter.\r
- */\r
- public Widgets datebox(WidgetInitializer<DateBox> initializers) {\r
- return widgets(new DateBoxWidgetFactory(), initializers);\r
- }\r
-\r
- /**\r
- * Create a {@link DisclosurePanel} widget for each selected elements.\r
- */\r
- public Widgets disclosurePanel() {\r
- return disclosurePanel(new DisclosurePanelOptions(), null);\r
- }\r
-\r
- /**\r
- * Create a {@link DisclosurePanel} widget for each selected elements.\r
- */\r
- public Widgets disclosurePanel(DisclosurePanelOptions o,\r
- WidgetInitializer<DisclosurePanel> initializers) {\r
- return widgets(new DisclosurePanelWidgetFactory(o), initializers);\r
- }\r
-\r
- /**\r
- * Create a {@link DisclosurePanel} widget for each selected elements.\r
- */\r
- public Widgets disclosurePanel(DisclosurePanelOptions o) {\r
- return widgets(new DisclosurePanelWidgetFactory(o), null);\r
- }\r
-\r
- /**\r
- * Create {@link DisclosurePanel} widget for each selected elements.\r
- */\r
- public Widgets disclosurePanel(WidgetInitializer<DisclosurePanel> initializers) {\r
- return disclosurePanel(new DisclosurePanelOptions(), initializers);\r
- }\r
-\r
- /**\r
- * Create a {@link ListBox} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link ListBox}\r
- * created by passing them in parameter.\r
- * \r
- */\r
- public Widgets listBox(ListBoxOptions options,\r
- WidgetInitializer<ListBox> initializers) {\r
- return widgets(new ListBoxWidgetFactory(options), initializers);\r
- }\r
-\r
- /**\r
- * Create a {@link ListBox} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link ListBox}\r
- * created by passing them in parameter.\r
- * \r
- */\r
- public Widgets listBox(ListBoxOptions options) {\r
- return widgets(new ListBoxWidgetFactory(options), null);\r
- }\r
-\r
- /**\r
- * Create a {@link ListBox} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link ListBox}\r
- * created by passing them in parameter.\r
- */\r
- public Widgets listBox(WidgetInitializer<ListBox> initializers) {\r
- return listBox(new ListBoxOptions(), initializers);\r
- }\r
-\r
- /**\r
- * Create a {@link ListBox} widget for each selected element.\r
- */\r
- public Widgets listBox() {\r
- return listBox(new ListBoxOptions(), null);\r
- }\r
-\r
- /**\r
- * Create a {@link PasswordTextBox} widget for each selected element.\r
- */\r
- public Widgets passwordBox() {\r
- return widgets(new PasswordTextBoxWidgetFactory(), null);\r
- }\r
-\r
- /**\r
- * Create a {@link CheckBox} widget for each selected element.\r
- */\r
- public Widgets checkBox(WidgetInitializer<CheckBox> initializers) {\r
- return widgets(new CheckBoxWidgetFactory(), initializers);\r
- }\r
-\r
- /**\r
- * Create a {@link CheckBox} widget for each selected element.\r
- */\r
- public Widgets checkBox() {\r
- return widgets(new CheckBoxWidgetFactory(), null);\r
- }\r
-\r
- /**\r
- * Create a {@link PasswordTextBox} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new\r
- * {@link PasswordTextBox} created by passing them in parameter.\r
- * \r
- */\r
- public Widgets passwordBox(WidgetInitializer<PasswordTextBox> initializers) {\r
- return widgets(new PasswordTextBoxWidgetFactory(), initializers);\r
- }\r
-\r
- /*\r
- * public Widgets richtext(WidgetInitializer initializers) { return\r
- * widgets(new RichTextWidgetFactory(), initializers); }\r
- */\r
-\r
- /**\r
- * Create a {@link StackPanel} widget for each selected elements. Each div\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 stackPanel(StackPanelOptions o,\r
- WidgetInitializer<StackPanel> initializers) {\r
- return widgets(new StackPanelWidgetFactory(o), initializers);\r
- }\r
-\r
- /**\r
- * Create a {@link StackPanel} widget for each selected elements. Each div\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 stackPanel(StackPanelOptions o) {\r
- return widgets(new StackPanelWidgetFactory(o), null);\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 stackPanel(WidgetInitializer<StackPanel> initializers) {\r
- return stackPanel(new StackPanelOptions(), initializers);\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 stackPanel() {\r
- return stackPanel(new StackPanelOptions(), null);\r
- }\r
-\r
- /**\r
- * Create {@link RadioButton} widget for each selected elements. All\r
- * {@link RadioButton} created will be group under the same name specified in\r
- * the {@link RadioButtonOption o}\r
- */\r
- public Widgets radioButton(RadioButtonOption o,\r
- WidgetInitializer<RadioButton> initializers) {\r
- return widgets(new RadioButtonWidgetFactory(o), initializers);\r
- }\r
-\r
- /**\r
- * Create {@link RadioButton} widget for each selected elements. All\r
- * {@link RadioButton} created will be group under the same name specified in\r
- * the {@link RadioButtonOption o}\r
- */\r
- public Widgets radioButton(RadioButtonOption o) {\r
- return widgets(new RadioButtonWidgetFactory(o), null);\r
- }\r
-\r
- /**\r
- * Create {@link RadioButton} widget for each selected elements. All\r
- * {@link RadioButton} created will be group under the same name\r
- */\r
- public Widgets radioButton(WidgetInitializer<RadioButton> initializers) {\r
- return radioButton(new RadioButtonOption(), initializers);\r
- }\r
-\r
- /**\r
- * Create {@link RadioButton} widget for each selected elements. All\r
- * {@link RadioButton} created will be group under the same name\r
- */\r
- public Widgets radioButton() {\r
- return radioButton(new RadioButtonOption(), null);\r
- }\r
-\r
- /**\r
- * Create a {@link SuggestBox} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link SuggestBox}\r
- * created by passing them in parameter.\r
- * \r
- */\r
- public Widgets suggestBox(SuggestBoxOptions options,\r
- WidgetInitializer<SuggestBox> initializers) {\r
- return widgets(new SuggestBoxWidgetFactory(options), initializers);\r
- }\r
-\r
- /**\r
- * Create a {@link SuggestBox} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link SuggestBox}\r
- * created by passing them in parameter.\r
- * \r
- */\r
- public Widgets suggestBox(SuggestBoxOptions options) {\r
- return widgets(new SuggestBoxWidgetFactory(options), null);\r
- }\r
-\r
- /**\r
- * Create a {@link SuggestBox} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link SuggestBox}\r
- * created by passing them in parameter.\r
- * \r
- */\r
- public Widgets suggestBox(WidgetInitializer<SuggestBox> initializers) {\r
- return suggestBox(new SuggestBoxOptions(), initializers);\r
- }\r
-\r
- /**\r
- * Create a {@link SuggestBox} widget for each selected element.\r
- */\r
- public Widgets suggestBox() {\r
- return suggestBox(new SuggestBoxOptions(), null);\r
- }\r
-\r
- /**\r
- * Create a {@link TabPanel} widget for each selected elements. Each div\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,\r
- WidgetInitializer<TabPanel> initializers) {\r
- return widgets(new TabPanelWidgetFactory(o), initializers);\r
- }\r
-\r
- /**\r
- * Create a {@link TabPanel} widget for each selected elements. Each div\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) {\r
- return widgets(new TabPanelWidgetFactory(o), null);\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(WidgetInitializer<TabPanel> initializers) {\r
- return tabPanel(new TabPanelOptions(), initializers);\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() {\r
- return tabPanel(new TabPanelOptions(), null);\r
- }\r
-\r
- /**\r
- * Create a {@link TextBox} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link TextBox}\r
- * created by passing them in parameter.\r
- * \r
- */\r
- public Widgets textBox() {\r
- return widgets(new TextBoxWidgetFactory(), null);\r
- }\r
-\r
- /**\r
- * Create a {@link TextBox} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link TextBox}\r
- * created by passing them in parameter.\r
- * \r
- */\r
- public Widgets textBox(WidgetInitializer<TextBox> initializers) {\r
- return widgets(new TextBoxWidgetFactory(), initializers);\r
- }\r
-\r
- /**\r
- * Create a {@link TextArea} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link TextBox}\r
- * created by passing them in parameter.\r
- * \r
- */\r
- public Widgets textArea() {\r
- return widgets(new TextAreaWidgetFactory(), null);\r
- }\r
-\r
- /**\r
- * Create a {@link TextArea} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link TextBox}\r
- * created by passing them in parameter.\r
- * \r
- */\r
- public Widgets textArea(WidgetInitializer<TextArea> initializers) {\r
- return widgets(new TextAreaWidgetFactory(), initializers);\r
- }\r
-\r
- /**\r
- * Create a {@link DecoratorPanel} widget for each selected element. \r
- */\r
- public Widgets decoratorPanel() {\r
- return widgets(new DecoratorPanelWidgetFactory(), null);\r
- }\r
-\r
- /**\r
- * Create a {@link DecoratorPanel} widget for each selected element. The\r
- * <code>initializers</code> will be called on each new {@link DecoratorPanel}\r
- * created by passing them in parameter.\r
- * \r
- */\r
- public Widgets decoratorPanel(WidgetInitializer<DecoratorPanel> initializers) {\r
- return widgets(new DecoratorPanelWidgetFactory(), initializers);\r
- }\r
-\r
- \r
+ \r
/**\r
* Try to create a widget using the given factory and the given options for\r
* each element of the query. Returns a new gquery set of elements with the\r
*/\r
protected <W extends Widget> W widget(WidgetFactory<W> factory,\r
WidgetInitializer<W> initializers) {\r
-\r
return widget(get(0), factory, initializers);\r
}\r
\r
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-
-import com.google.gwt.dom.client.ButtonElement;
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.user.client.ui.Button;
-
-/**
- * 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 implements WidgetFactory<Button> {
-
- public Button create(Element e) {
-
- //TODO manage button tag in an other way that wrapping it
- /*if ("button".equalsIgnoreCase(e.getTagName())) {
- return Button.wrap(e);
- }*/
-
-
-
- Button button = new Button();
- button.getElement().setInnerText(e.getInnerText());
-
- 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) {
- destination.setAccessKey(source.getAccessKey());
- destination.setDisabled(source.isDisabled());
- destination.setName(source.getName());
- destination.setValue(source.getValue());
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.InputElement;
-import com.google.gwt.user.client.ui.CheckBox;
-
-/**
- *
- *
- */
-public class CheckBoxWidgetFactory implements WidgetFactory<CheckBox> {
-
- public CheckBox create(Element e) {
-
- CheckBox checkBox = new CheckBox(e.getInnerText());
- if ("input".equalsIgnoreCase(e.getTagName())){
- copyAttributes((InputElement) e.cast(), (InputElement) checkBox.getElement().cast());
- }
- WidgetsUtils.replaceOrAppend(e, checkBox);
- return checkBox;
-
- }
-
- protected String getEquivalentTagName(){
- return "input";
- }
-
- protected void copyAttributes(InputElement source, InputElement destination) {
-
- destination.setAccessKey(source.getAccessKey());
- destination.setDisabled(source.isDisabled());
- destination.setSize(source.getSize());
- destination.setName(source.getName());
- destination.setValue(source.getValue());
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-import static com.google.gwt.query.client.GQuery.$;
-
-import java.util.Date;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.query.client.GQuery;
-import com.google.gwt.user.datepicker.client.DateBox;
-import com.google.gwt.user.datepicker.client.DateBox.DefaultFormat;
-
-/**
- * Factory used to create a {@link DateBox} widget.
- *
- * The content of the element has to be empty, a valid date or a valid date-format string.
- */
-public class DateBoxWidgetFactory implements WidgetFactory<DateBox> {
-
- public DateBox create(Element e) {
- String v = null;
- if ($(e).filter("input[type='text']").size() == 1) {
- v = GQuery.$(e).val();
- } else {
- v = GQuery.$(e).text();
- }
- if (v!=null) {
- DateBox w = create(v);
- WidgetsUtils.replaceOrAppend(e, w);
- return w;
- }
- return null;
- }
-
- @SuppressWarnings("deprecation")
- private DateBox create(String v) {
- Date d = new Date();
- DateTimeFormat f = null;
- if (v != null) {
- try {
- d = new Date(v);
- } catch (Exception e) {
- try {
- f = DateTimeFormat.getFormat(v);
- } catch (Exception e2) {
- }
- }
- }
- DateBox b = new DateBox();
- b.setValue(d);
- if (f != null) {
- b.setFormat(new DefaultFormat(f));
- }
- return b;
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.user.client.ui.DecoratorPanel;
-
-public class DecoratorPanelWidgetFactory implements
- WidgetFactory<DecoratorPanel> {
-
- public DecoratorPanelWidgetFactory() {
- }
-
- public DecoratorPanel create(Element e) {
-
- DecoratorPanel decoratorPanel = new DecoratorPanel();
-
- WidgetsUtils.replaceOrAppend(e, decoratorPanel);
-
- decoratorPanel.add(new WidgetsHtmlPanel(e));
-
- return decoratorPanel;
- }
-
-}
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-import static com.google.gwt.query.client.GQuery.$;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DisclosurePanel;
-import com.google.gwt.user.client.ui.Label;
-
-public class DisclosurePanelWidgetFactory implements
- WidgetFactory<DisclosurePanel> {
-
- /**
- * Options used to initialize new {@link Button}
- *
- */
- public static class DisclosurePanelOptions {
-
- private String headerSelector;
- //private String headerTitle;
-
- public DisclosurePanelOptions() {
- initDefault();
- }
-
- public DisclosurePanelOptions(String headerSelector) {
- this.headerSelector = headerSelector;
-
- }
-
- public String getHeaderSelector() {
- return headerSelector;
- }
-
- /* public String getHeaderTitle() {
- return headerTitle;
- }*/
-
- public void setHeaderSelector(String headerSelector) {
- this.headerSelector = headerSelector;
- }
-
- /* public void setHeaderTitle(String headerTitle) {
- this.headerTitle = headerTitle;
- }*/
-
- private void initDefault() {
- //headerTitle = null;
- headerSelector = "h3";
- }
- }
-
- private DisclosurePanelOptions options;
-
- public DisclosurePanelWidgetFactory(DisclosurePanelOptions options) {
- this.options = options;
- }
-
- public DisclosurePanel create(Element e) {
-
- String headerValue = "";
- /*if (options.getHeaderTitle() != null){
- headerValue = options.getHeaderTitle();
- }else{*/
- headerValue = $(options.getHeaderSelector(), e).first().remove().text();
- //}
-
- DisclosurePanel disclosurePanel = new DisclosurePanel();
- disclosurePanel.setHeader(new Label(headerValue));
-
- WidgetsUtils.replaceOrAppend(e, disclosurePanel);
-
- disclosurePanel.add(new WidgetsHtmlPanel(e));
-
-
- return disclosurePanel;
- }
-
-}
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-import static com.google.gwt.query.client.GQuery.$;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.SelectElement;
-import com.google.gwt.query.client.GQuery;
-import com.google.gwt.user.client.ui.ListBox;
-
-/**
- * Factory used to create a {@link ListBox} widget.
- *
- */
-public class ListBoxWidgetFactory implements WidgetFactory<ListBox> {
-
- /**
- * Options used to create a {@link ListBox}
- *
- */
- public static class ListBoxOptions {
-
- private String optionsSelector;
- private boolean multipleSelect;
-
- public ListBoxOptions() {
- initDefault();
- }
-
- public ListBoxOptions(String optionsSelector, boolean multipleSelect) {
- this.optionsSelector = optionsSelector;
- this.multipleSelect = multipleSelect;
- }
-
- public String getOptionsSelector() {
- return optionsSelector;
- }
-
- public boolean isMultipleSelect() {
- return multipleSelect;
- }
-
- /**
- * Set the css selector to use for selecting elements playing roles of the
- * list items. The value of the items will be the inner texts of the
- * selected elements
- *
- * If this options is null, the inner text of the direct children of the
- * element will be used as items list.
- *
- * This options is used if the element is not a <i>select</i> element.
- *
- * @param optionsSelector
- */
- public void setOptionsSelector(String optionsSelector) {
- this.optionsSelector = optionsSelector;
- }
-
- public void setMultipleSelect(boolean multipleSelect) {
- this.multipleSelect = multipleSelect;
- }
-
- private void initDefault() {
- optionsSelector = null;
- multipleSelect = false;
- }
- }
-
- private ListBoxOptions options;
-
- public ListBoxWidgetFactory(ListBoxOptions options) {
- this.options = options;
- }
-
- public ListBox create(Element e) {
-
- ListBox listBox = new ListBox(options.isMultipleSelect());
- if (WidgetsUtils.matchesTags(e, "select")) {
- copyAttributes((SelectElement)e.cast(),(SelectElement)listBox.getElement().cast());
- }
-
- GQuery itemsList = getItemsList(e);
- for (Element item : itemsList.elements()) {
- listBox.addItem(item.getInnerText());
- }
-
- WidgetsUtils.replaceOrAppend(e, listBox);
- return listBox;
- }
-
- protected void copyAttributes(SelectElement source, SelectElement destination) {
- destination.setDisabled(source.isDisabled());
- destination.setName(source.getName());
- destination.setSelectedIndex(source.getSelectedIndex());
- destination.setSize(source.getSize());
-
- }
-
- protected GQuery getItemsList(Element e) {
- if ("select".equalsIgnoreCase(e.getTagName())){
- return $("option", e);
- }
- if (options.getOptionsSelector() != null) {
- return $(options.getOptionsSelector(), e);
- }
- return $(e).children();
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-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 extends
- TextBoxBaseWidgetFactory<PasswordTextBox> {
-
- protected PasswordTextBox createWidget() {
- return new PasswordTextBox();
- }
-}
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.InputElement;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.ui.RadioButton;
-
-/**
- *
- *
- */
-public class RadioButtonWidgetFactory implements WidgetFactory<RadioButton> {
-
- public static class RadioButtonOption{
-
- private String name;
-
- public RadioButtonOption() {
- }
-
- public RadioButtonOption(String name){
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- }
-
- private RadioButtonOption option;
- private String radioName;
-
- public RadioButtonWidgetFactory(RadioButtonOption option) {
- this.option = option;
- }
-
-
- public RadioButton create(Element e) {
- resolveName(e);
-
- RadioButton radioButton = new RadioButton(radioName);
- if ("input".equalsIgnoreCase(e.getTagName())){
- copyAttributes((InputElement) e, (InputElement) radioButton.getElement().cast());
- }else{
- radioButton.setText(e.getInnerText());
- }
-
- WidgetsUtils.replaceOrAppend(e, radioButton);
-
- return radioButton;
-
- }
-
- protected void resolveName(Element e) {
- if (radioName != null){
- return;
- }
- if (option.getName() != null){
- radioName = option.getName();
- }else if ("input".equals(e.getTagName()) && "radio".equals(((InputElement)e).getType())){
- radioName = ((InputElement)e).getName();
- }else{
- //create an unique string via DOM.createUniqueId...
- radioName = DOM.createUniqueId();
- }
- }
-
-
- protected String getEquivalentTagName(){
- return "input";
- }
-
- protected void copyAttributes(InputElement source, InputElement destination) {
-
- destination.setAccessKey(source.getAccessKey());
- destination.setDisabled(source.isDisabled());
- destination.setSize(source.getSize());
- destination.setValue(source.getValue());
- }
-
-
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-import static com.google.gwt.query.client.GQuery.$;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.RichTextArea;
-
-/**
- * Factory used to create a {@link RichTextArea} widget.
- * A {@link Button} is created if the element is a <i>textarea</i>, <i>div></i> or <i>span</i>.
- * The content of the element will be copied to the rich text area.
- */
-public class RichTextWidgetFactory implements WidgetFactory<RichTextArea> {
-
-
- public RichTextArea create(Element e) {
- String v = null;
- if ("textarea".equalsIgnoreCase(e.getTagName())) {
- v = $(e).val();
- } else if (WidgetsUtils.matchesTags(e, "div", "span")) {
- v = $(e).html();
- }
- if (v != null) {
- RichTextArea w = create(v);
- WidgetsUtils.replaceOrAppend(e, w);
- return w;
- }
- return null;
- }
-
- private RichTextArea create(String v) {
- RichTextArea b = new RichTextArea();
- b.setHTML(v);
- return b;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-import static com.google.gwt.query.client.GQuery.$;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.query.client.GQuery;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DecoratedStackPanel;
-import com.google.gwt.user.client.ui.StackPanel;
-import com.google.gwt.user.client.ui.Widget;
-
-public class StackPanelWidgetFactory implements WidgetFactory<StackPanel> {
-
- /**
- * Options used to initialize new {@link Button}
- *
- */
- public static class StackPanelOptions {
-
- private String headerSelector;
- private String contentSelector;
- private boolean decorated;
-
- public StackPanelOptions() {
- initDefault();
- }
-
- public StackPanelOptions(String headerSelector, String contentSelector, boolean decorated){
- this.headerSelector = headerSelector;
- this.contentSelector = contentSelector;
- this.decorated = decorated;
- }
-
- public String getHeaderSelector() {
- return headerSelector;
- }
-
- public String getContentSelector() {
- return contentSelector;
- }
-
- public boolean isDecorated() {
- return decorated;
- }
-
- public void setHeaderSelector(String headerSelector) {
- this.headerSelector = headerSelector;
- }
-
- public void setContentSelector(String contentSelector) {
- this.contentSelector = contentSelector;
- }
-
- public void setDecorated(boolean decorated) {
- this.decorated = decorated;
- }
-
- private void initDefault() {
- contentSelector = "div";
- headerSelector = "h3";
- decorated = true;
- }
- }
-
- private StackPanelOptions options;
-
- public StackPanelWidgetFactory(StackPanelOptions o) {
- this.options = o;
- }
-
- public StackPanel create(Element e) {
- StackPanel stackPanel = options.isDecorated() ? new DecoratedStackPanel() : new StackPanel();
-
- WidgetsUtils.replaceOrAppend(e, stackPanel);
-
- GQuery contents = $(options.getContentSelector(), e);
- GQuery headers = $(options.getHeaderSelector(), e);
-
- for (int i = 0; i < contents.length(); i++) {
- Element content = contents.get(i);
- Element header = headers.get(i);
-
- Widget contentWidget = $(content).widget();
- if (contentWidget == null){
- contentWidget = new WidgetsHtmlPanel(content);
- }
-
- stackPanel.add(contentWidget, header != null ? header.getInnerText() : "Undefined" );
-
- }
-
-
-
- return stackPanel;
- }
-
-}
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-import static com.google.gwt.query.client.GQuery.$;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.query.client.GQuery;
-import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
-import com.google.gwt.user.client.ui.SuggestBox;
-import com.google.gwt.user.client.ui.SuggestOracle;
-
-/**
- * Factory used to create a {@link SuggestBox} widget.
- *
- */
-public class SuggestBoxWidgetFactory implements WidgetFactory<SuggestBox> {
-
- /**
- * Options used to create a {@link SuggestBox}
- *
- */
- public static class SuggestBoxOptions {
-
- private String suggestionsSelector;
- private SuggestOracle suggestOracle;
-
- public SuggestBoxOptions() {
- initDefault();
- }
-
- public SuggestBoxOptions(String suggestionsSelector) {
- this.suggestionsSelector = suggestionsSelector;
- }
-
- public SuggestBoxOptions(SuggestOracle suggestOracle) {
- this.suggestOracle = suggestOracle;
- }
-
- public SuggestOracle getSuggestOracle() {
- return suggestOracle;
- }
-
- public String getSuggestionsSelector() {
- return suggestionsSelector;
- }
-
- /**
- * Set the css selector to use for selecting elements playing roles of the
- * list items. The value of the items will be the inner texts of the
- * selected elements
- *
- * If this options is null, the inner text of the direct children of the
- * element will be used as suggestions list.
- *
- * This options is used if the element is not a <i>select</i> element.
- *
- * @param optionsSelector
- */
- public void setSuggestionsSelector(String suggestionsSelector) {
- this.suggestionsSelector = suggestionsSelector;
- }
-
- public void setSuggestOracle(SuggestOracle suggestOracle) {
- this.suggestOracle = suggestOracle;
- }
-
- private void initDefault() {
- suggestionsSelector = null;
- suggestOracle = null;
- }
- }
-
- private SuggestBoxOptions options;
-
- public SuggestBoxWidgetFactory(SuggestBoxOptions options) {
- this.options = options;
- }
-
- public SuggestBox create(Element e) {
-
- SuggestOracle suggestOracle = createOracle(e);
-
- if ($(e).filter("input[type='text']").length() > 0) {
- return SuggestBox.wrap(suggestOracle, e);
- }
-
- SuggestBox sbox = new SuggestBox(suggestOracle);
- WidgetsUtils.replaceOrAppend(e, sbox);
-
- return sbox;
- }
-
- private SuggestOracle createOracle(Element e) {
- if (options.getSuggestOracle() != null) {
- return options.getSuggestOracle();
- }
-
- MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
-
- if (options.getSuggestionsSelector() != null) {
- GQuery suggestions = $(options.getSuggestionsSelector(), e);
- for (Element suggestion : suggestions.elements()) {
- oracle.add(suggestion.getInnerText());
- }
- }
-
- return oracle;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-import static com.google.gwt.query.client.GQuery.$;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.query.client.GQuery;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.TabPanel;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * 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 implements WidgetFactory<TabPanel> {
-
-
- /**
- * Options used to initialize new {@link Button}
- *
- */
- public static class TabPanelOptions {
-
- private String tabSelector;
- private String titleSelector;
-
- public TabPanelOptions() {
- initDefault();
- }
-
- public TabPanelOptions(String tabSelector, String titleSelector) {
- this.tabSelector = tabSelector;
- this.titleSelector = titleSelector;
-
- }
-
- public String getTabSelector() {
- return tabSelector;
- }
-
- public String getTitleSelector() {
- return titleSelector;
- }
-
- public void setTabSelector(String contentSelector) {
- this.tabSelector = contentSelector;
- }
-
- public void setTitleSelector(String titleSelector) {
- this.titleSelector = titleSelector;
- }
-
- private void initDefault() {
- tabSelector = "div";
- titleSelector = "h3";
- }
- }
-
- private TabPanelOptions options;
-
- public TabPanelWidgetFactory(TabPanelOptions o) {
- this.options = o;
- }
-
- public TabPanel create(Element e) {
- TabPanel tabPanel = new TabPanel();
-
- GQuery tabs = $(options.getTabSelector(), e);
- GQuery titles = $(options.getTitleSelector(), e);
-
- for (int i = 0; i < tabs.length(); i++) {
- GQuery tab = tabs.eq(i);
- GQuery title = titles.eq(i);
-
- Widget tabWidget = tab.widget();
- if (tabWidget == null){
- tabWidget = new WidgetsHtmlPanel(tab.get(0));
- }
-
- tabPanel.add(tabWidget, title.get(0) != null
- ? title.text() : "Tab " + (i + 1));
-
- }
- if (tabs.length() > 0) {
- tabPanel.selectTab(0);
- }
-
- WidgetsUtils.replaceOrAppend(e, tabPanel);
- return tabPanel;
- }
-}
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.TextAreaElement;
-import com.google.gwt.user.client.ui.TextArea;
-
-/**
- * Factory used to create a {@link TextArea} widget.
- *
- */
-public class TextAreaWidgetFactory extends TextBoxBaseWidgetFactory<TextArea> {
-
- @Override
- protected void copyAttributes(Element src, Element dest) {
- TextAreaElement source= src.cast();
- TextAreaElement destination = dest.cast();
-
- destination.setAccessKey(source.getAccessKey());
- destination.setCols(source.getCols());
- destination.setDefaultValue(source.getDefaultValue());
- destination.setDisabled(source.isDisabled());
- destination.setName(source.getName());
- destination.setReadOnly(source.isReadOnly());
- destination.setRows(source.getRows());
- destination.setValue(source.getValue());
- }
-
- @Override
- protected String getEquivalentTagName() {
- return "textarea";
- }
-
-
- protected TextArea createWidget() {
- return new TextArea();
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.InputElement;
-import com.google.gwt.user.client.ui.TextBoxBase;
-
-/**
- *
- *
- */
-public abstract class TextBoxBaseWidgetFactory<T extends TextBoxBase>
- implements WidgetFactory<T> {
-
- public T create(Element e) {
- T textBox = createWidget();
-
- if (getEquivalentTagName().equalsIgnoreCase(e.getTagName())) {
- copyAttributes((InputElement) e.cast(),
- (InputElement) textBox.getElement().cast());
- } else {
- textBox.setValue(e.getInnerText());
- }
- WidgetsUtils.replaceOrAppend(e, textBox);
-
- return (T) textBox;
- }
-
- protected String getEquivalentTagName(){
- return "input";
- }
-
- protected void copyAttributes(Element src, Element dest) {
- InputElement source = src.cast();
- InputElement destination = dest.cast();
-
- destination.setAccessKey(source.getAccessKey());
- destination.setDefaultValue(source.getDefaultValue());
- destination.setDisabled(source.isDisabled());
- destination.setMaxLength(source.getMaxLength());
- destination.setReadOnly(source.isReadOnly());
- destination.setSize(source.getSize());
- destination.setName(source.getName());
- destination.setValue(source.getValue());
-
- }
-
- protected abstract T createWidget();
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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
- * 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.client.plugins.widgets;
-
-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 extends TextBoxBaseWidgetFactory<TextBox> {
-
- protected TextBox createWidget() {
- return new TextBox();
- }
-}
\ No newline at end of file
import static com.google.gwt.query.client.GQuery.$;
import static com.google.gwt.query.client.GQuery.document;
+import com.google.gwt.dom.client.ButtonElement;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.query.client.plugins.Widgets;
+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;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
b.removeFromParent();
}
+ class TestButtonWidgetFactory implements WidgetFactory<Button> {
+ public Button create(Element e) {
+ Button button = new Button();
+ button.getElement().setInnerText(e.getInnerText());
+ WidgetsUtils.replaceOrAppend(e, button);
+ return button;
+ }
+ }
+
public void testGQueryWidgets() {
final Button b1 = new Button("click-me");
RootPanel.get().add(b1);
Button b2 = (Button) g.as(Widgets.Widgets).widget();
assertEquals(b1, b2);
-
- b2 = $("<button>Click-me</button>").appendTo(document).as(Widgets.Widgets).button().widget();
+ b2 = $("<button>Click-me</button>").appendTo(document)
+ .as(Widgets.Widgets).widgets(new TestButtonWidgetFactory(), null).widget();
b2.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
$(b1).css("color", "red");
+++ /dev/null
-<module>
- <inherits name='com.google.gwt.query.Query'/>
- <inherits name='com.google.gwt.user.theme.chrome.Chrome' />
- <entry-point class='gwtquery.samples.client.GwtQueryWidgetModule'/>
-</module>
-
+++ /dev/null
-/*\r
- * Copyright 2011, The gwtquery team.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
- * use this file except in compliance with the License. You may obtain a copy of\r
- * the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
- * License for the specific language governing permissions and limitations under\r
- * the License.\r
- */\r
-package gwtquery.samples.client;\r
-\r
-import static com.google.gwt.query.client.GQuery.$;\r
-import static com.google.gwt.query.client.plugins.Widgets.Widgets;\r
-\r
-import com.google.gwt.core.client.EntryPoint;\r
-import com.google.gwt.core.client.GWT;\r
-import com.google.gwt.dom.client.Element;\r
-import com.google.gwt.event.dom.client.ClickEvent;\r
-import com.google.gwt.event.dom.client.ClickHandler;\r
-import com.google.gwt.query.client.plugins.widgets.WidgetInitializer;\r
-import com.google.gwt.query.client.plugins.widgets.ListBoxWidgetFactory.ListBoxOptions;\r
-import com.google.gwt.query.client.plugins.widgets.SuggestBoxWidgetFactory.SuggestBoxOptions;\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.GqUi;\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.RootPanel;\r
-import com.google.gwt.user.client.ui.Tree;\r
-import com.google.gwt.user.client.ui.TreeItem;\r
-import com.google.gwt.user.client.ui.Widget;\r
-\r
-import java.util.Iterator;\r
-\r
-public class GwtQueryWidgetModule implements EntryPoint {\r
-\r
- public static class MyButtonInitializer implements WidgetInitializer<Button> {\r
-\r
- public void initialize(Button button, Element e) {\r
-\r
- final String tag = e.getTagName();\r
- button.addClickHandler(new ClickHandler() {\r
-\r
- public void onClick(ClickEvent event) {\r
- Label l = new Label("You click on a GWT Button create from a " + tag);\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
- public void onModuleLoad() {\r
-\r
- $("#disclosure").as(Widgets).disclosurePanel();\r
-\r
- $(".inputText").as(Widgets).textBox();\r
- $(".inputPsw").as(Widgets).passwordBox();\r
- $(".textArea").as(Widgets).textArea();\r
-\r
- $(".btn").as(Widgets).button(new MyButtonInitializer());\r
-\r
- $("#tabs").as(Widgets).tabPanel(\r
- new TabPanelOptions("div.tab", "h3.tabTitle"));\r
- //$(".editable").as(Widgets).richtext().widget();\r
-\r
- $(".date").as(Widgets).datebox();\r
-\r
- $(".list").as(Widgets).listBox();\r
- $("#multiSelect").as(Widgets).listBox(new ListBoxOptions(".item", true));\r
- $("#suggestBox1").as(Widgets).suggestBox(new SuggestBoxOptions("div"));\r
- $("#suggestBox2").as(Widgets).suggestBox(new SuggestBoxOptions("li"));\r
- $(".stack").as(Widgets).stackPanel();\r
- $(".checkBox").as(Widgets).checkBox();\r
- $(".radio").as(Widgets).radioButton();\r
- \r
- $("body > div").as(Widgets).decoratorPanel();\r
-\r
- GWT.log("Found " + $(".btn").widgets().size() + " buttons widget");\r
-\r
- displayWidgetHierarchy();\r
- }\r
-\r
- private void displayWidgetHierarchy() {\r
- DisclosurePanel disclosurePanel = $("#disclosure").widget();\r
- Tree widgetHierarchy = new Tree();\r
- TreeItem rootItem = new TreeItem(disclosurePanel.getClass().getName());\r
- widgetHierarchy.addItem(rootItem);\r
- widgetHierarchy.setAnimationEnabled(true);\r
- addChildren(rootItem, disclosurePanel);\r
-\r
- RootPanel.get().add(new Label("Widgets hierarchy :"));\r
- RootPanel.get().add(widgetHierarchy);\r
- }\r
-\r
- private void addChildren(TreeItem item, Widget w) {\r
- Iterator<Widget> children = GqUi.getChildren(w);\r
- if (children != null) {\r
- while (children.hasNext()) {\r
- Widget child = children.next();\r
- TreeItem subItem = new TreeItem(child.getClass().getName());\r
- item.addItem(subItem);\r
-\r
- addChildren(subItem, child);\r
-\r
- }\r
- }\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-<html>\r
-<head>\r
-<title>GQuery Demo</title>\r
-<script language="javascript"\r
- src="gwtquery.samples.GwtQueryWidgets.nocache.js" ></script>\r
-<style type="text/css">\r
-.outer {\r
- margin: 5px;\r
-}\r
-</style>\r
-</head>\r
-<body>\r
-\r
-<div class="outer">\r
-<div id="disclosure">\r
-<h3>Show the widgets</h3>\r
-<div>\r
- <div id="tabs">\r
- \r
- <h3 class="tabTitle">Buttons</h3>\r
- <div class="tab">\r
- <div class="outer">\r
- <div class="btn">Make me a button 1!</div>\r
- <a class="btn">Make me a button 2!</a> \r
- <span class="btn">Make me a button 3!</span>\r
- <button class="btn">Make me a button 4!</button>\r
- <div class="btn">Make me a button 5!</div>\r
- <div class="btn">Make me a button 6!</div>\r
- </div>\r
- </div>\r
- \r
- <h3 class="tabTitle">Inputs</h3>\r
- \r
- <div class="tab">\r
- <input type="text" class="date"\r
- value="dd/MM/yyyy" />\r
- \r
- <div class="outer">\r
- <div class="inputText">I will be a text input</div>\r
- <span class="inputText">I will be a text input</span> \r
- <input\r
- class="inputText" type="text" value="I will be a text input"></input>\r
- </div>\r
- \r
- <div class="outer">\r
- <div class="inputPsw">I will be an password input</div>\r
- <span class="inputPsw">I will be an password input</span> \r
- <input\r
- class="inputPsw" type="password" value="I will be an password input"></input>\r
- </div>\r
- <input type="text" class="date" value="dd/MM/yyyy" />\r
- \r
- <div class="outer">\r
- <div class="textArea">I will be a text area</div>\r
- <span class="textArea">I will be a text area</span> \r
- <textarea class="textArea">I will be a text area</textarea>\r
- </div>\r
- \r
- <div class="outer">\r
- <div id="suggestBox1">\r
- <div>suggestion a</div>\r
- <div>suggestion b</div>\r
- <div>suggestion c</div>\r
- <div>suggestion d</div>\r
- <div>suggestion e</div>\r
- <div>suggestion f</div>\r
- <div>suggestion g</div>\r
- <div>suggestion h</div>\r
- <div>suggestion i</div>\r
- <div>suggestion j</div>\r
- <div>suggestion k</div>\r
- <div>suggestion l</div>\r
- <div>suggestion m</div>\r
- <div>suggestion n</div>\r
- <div>suggestion o</div>\r
- <div>suggestion p</div>\r
- <div>suggestion q</div>\r
- <div>suggestion r</div>\r
- <div>suggestion s</div>\r
- <div>suggestion t</div>\r
- <div>suggestion u</div>\r
- <div>suggestion v</div>\r
- <div>suggestion w</div>\r
- <div>suggestion x</div>\r
- <div>suggestion y</div>\r
- <div>suggestion z</div>\r
- </div>\r
-\r
- <ul id="suggestBox2">\r
- <li>suggestion a</li>\r
- <li>suggestion b</li>\r
- <li>suggestion c</li>\r
- <li>suggestion d</li>\r
- <li>suggestion e</li>\r
- <li>suggestion f</li>\r
- <li>suggestion g</li>\r
- <li>suggestion h</li>\r
- <li>suggestion i</li>\r
- <li>suggestion j</li>\r
- <li>suggestion k</li>\r
- <li>suggestion l</li>\r
- <li>suggestion m</li>\r
- <li>suggestion n</li>\r
- <li>suggestion o</li>\r
- <li>suggestion p</li>\r
- <li>suggestion q</li>\r
- <li>suggestion r</li>\r
- <li>suggestion s</li>\r
- <li>suggestion t</li>\r
- <li>suggestion u</li>\r
- <li>suggestion v</li>\r
- <li>suggestion w</li>\r
- <li>suggestion x</li>\r
- <li>suggestion y</li>\r
- <li>suggestion z</li>\r
- </ul>\r
- \r
- <div class="outer">\r
- <div class="checkBox">Checkbox</div>\r
- <div class="checkBox">created</div> \r
- <div class="checkBox">from div</div>\r
- </div>\r
- \r
- <div class="outer">\r
- <div class="radio">RadioButton</div>\r
- <div class="radio">created</div> \r
- <div class="radio">from div</div>\r
- </div>\r
- </div>\r
- \r
- \r
- </div>\r
- \r
- <h3 class="tabTitle">Normal Tab</h3>\r
- <div class="tab">Pellentesque habitant morbi tristique senectus et netus et\r
- malesuada fames ac turpis egestas. Duis feugiat dapibus nunc, sit amet\r
- sodales dolor bibendum eget. Pellentesque ac libero et nibh ultrices\r
- vehicula. Morbi convallis auctor ultricies. Class aptent taciti sociosqu\r
- ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean\r
- gravida eros at massa fringilla vestibulum. Sed justo dui, euismod et\r
- venenatis in, vehicula ut nisi. Sed sodales lorem vel est luctus vitae\r
- ornare erat pulvinar. Maecenas lacus sem, ultrices vitae tincidunt in,\r
- gravida eget quam. Vestibulum condimentum, augue nec consectetur\r
- egestas, mi sapien ullamcorper diam, sit amet molestie mauris odio at\r
- lacus.</div>\r
- \r
- <h3 class="tabTitle">SelectBoxes</h3>\r
- <div class="tab">\r
- <div class="outer">\r
- <select class="list">\r
- <option>option 11</option>\r
- <option>option 12</option>\r
- <option>option 13</option>\r
- <option>option 14</option>\r
- </select>\r
- \r
- <ul class="list">\r
- <li>option 21</li>\r
- <li>option 22</li>\r
- <li>option 23</li>\r
- <li>option 23</li>\r
- </ul>\r
- \r
- <div class="list">\r
- <div>div 1</div>\r
- <div>div 2</div>\r
- <span>span 1</span> \r
- <span>span 1</span>\r
- </div>\r
- \r
- <div id="multiSelect">\r
- <div>div 1</div>\r
- <div class="item">div 2</div>\r
- <span>span 1</span> \r
- <span class="item">span 1</span>\r
- </div>\r
- </div>\r
- </div>\r
- \r
- <h3 class="tabTitle">StackPanel</h3>\r
- <div class="tab">\r
- <div class="stack">\r
- <h3>header 1</h3>\r
- <div> content 1</div>\r
- \r
- <h3>header 2</h3>\r
- <div> content 2</div>\r
- \r
- <h3>header 3</h3>\r
- <div> content 3</div>\r
- </div>\r
- </div>\r
- </div> \r
- </div>\r
-</div>\r
-</div>\r
-\r
-</body>\r
-</html>\r
}
</script>
<ul>
-<li><a href="javascript:goTo('gwtquery.samples.GwtQuerySample/GwtQuerySample.html')">gwtquery.samples.GwtQuerySample/GwtQuerySample.html</a></li>
-<li><a href="javascript:goTo('gwtquery.samples.GwtQueryDemo/GwtQueryDemo.html')">gwtquery.samples.GwtQueryDemo/GwtQueryDemo.html</a></li>
-<li><a href="javascript:goTo('gwtquery.samples.GwtQueryEffects/GwtQueryEffects.html')">gwtquery.samples.GwtQueryEffects/GwtQueryEffects.html</a></li>
-<li><a href="javascript:goTo('gwtquery.samples.GwtQueryEffectsMin/GwtQueryEffectsMin.html')">gwtquery.samples.GwtQueryEffects/GwtQueryEffectsMin.html</a></li>
-<li><a href="javascript:goTo('gwtquery.samples.GwtQueryWidgets/GwtQueryWidgets.html')">gwtquery.samples.GwtQueryWidgets/GwtQueryWidgets.html</a></li>
-<li><a href="javascript:goTo('gwtquery.samples.GwtQueryBench/GwtQueryBench.html')">gwtquery.samples.GwtQueryBench/GwtQueryBench.html</a></li>
-<li><a href="javascript:goTo('gwtquery.samples.GwtQueryImageZoom/GwtQueryImageZoom.html')">gwtquery.samples.GwtQueryImageZomm/GwtQueryImageZoom.html</a></li>
-<li><a href="javascript:goTo('FadeEffectsSample/FadeEffectsSample.html')">FadeEffectsSample/FadeEffectsSample.html</a></li>
-<li><a href="javascript:goTo('SlideEffectsSample/SlideEffectsSample.html')">SlideEffectsSample/SlideEffectsSample.html</a></li>
+<li><a href="javascript:goTo('gwtquery.samples.GwtQuerySample/GwtQuerySample.html')">GwtQuerySample.html</a></li>
+<li><a href="javascript:goTo('gwtquery.samples.GwtQueryDemo/GwtQueryDemo.html')">GwtQueryDemo.html</a></li>
+<li><a href="javascript:goTo('gwtquery.samples.GwtQueryEffects/GwtQueryEffects.html')">GwtQueryEffects.html</a></li>
+<li><a href="javascript:goTo('gwtquery.samples.GwtQueryEffectsMin/GwtQueryEffectsMin.html')">GwtQueryEffectsMin.html</a></li>
+<li><a href="javascript:goTo('gwtquery.samples.GwtQueryBench/GwtQueryBench.html')">GwtQueryBench.html</a></li>
+<li><a href="javascript:goTo('gwtquery.samples.GwtQueryImageZoom/GwtQueryImageZoom.html')">GwtQueryImageZoom.html</a></li>
+<li><a href="javascript:goTo('FadeEffectsSample/FadeEffectsSample.html')">FadeEffectsSample.html</a></li>
+<li><a href="javascript:goTo('SlideEffectsSample/SlideEffectsSample.html')">SlideEffectsSample.html</a></li>
+<li><a href="javascript:goTo('AnimationsSample/AnimationsSample.html')">AnimationsSample.html</a></li>
+
</ul>
</body>
</html>