diff options
21 files changed, 28 insertions, 1829 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java index 4e452ff5..ebaaa733 100755 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java @@ -15,47 +15,15 @@ */
package com.google.gwt.query.client.plugins;
+import java.util.ArrayList;
+import java.util.List;
+
import com.google.gwt.dom.client.Element;
import com.google.gwt.query.client.GQuery;
-import com.google.gwt.query.client.plugins.widgets.ButtonWidgetFactory;
-import com.google.gwt.query.client.plugins.widgets.CheckBoxWidgetFactory;
-import com.google.gwt.query.client.plugins.widgets.DateBoxWidgetFactory;
-import com.google.gwt.query.client.plugins.widgets.DecoratorPanelWidgetFactory;
-import com.google.gwt.query.client.plugins.widgets.DisclosurePanelWidgetFactory;
-import com.google.gwt.query.client.plugins.widgets.ListBoxWidgetFactory;
-import com.google.gwt.query.client.plugins.widgets.PasswordTextBoxWidgetFactory;
-import com.google.gwt.query.client.plugins.widgets.RadioButtonWidgetFactory;
-import com.google.gwt.query.client.plugins.widgets.StackPanelWidgetFactory;
-import com.google.gwt.query.client.plugins.widgets.SuggestBoxWidgetFactory;
-import com.google.gwt.query.client.plugins.widgets.TabPanelWidgetFactory;
-import com.google.gwt.query.client.plugins.widgets.TextAreaWidgetFactory;
-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.WidgetsUtils;
-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.RadioButtonWidgetFactory.RadioButtonOption;
-import com.google.gwt.query.client.plugins.widgets.StackPanelWidgetFactory.StackPanelOptions;
-import com.google.gwt.query.client.plugins.widgets.SuggestBoxWidgetFactory.SuggestBoxOptions;
-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.CheckBox;
-import com.google.gwt.user.client.ui.DecoratorPanel;
-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.RadioButton;
-import com.google.gwt.user.client.ui.StackPanel;
-import com.google.gwt.user.client.ui.SuggestBox;
-import com.google.gwt.user.client.ui.TabPanel;
-import com.google.gwt.user.client.ui.TextArea;
-import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
-import com.google.gwt.user.datepicker.client.DateBox;
-
-import java.util.ArrayList;
-import java.util.List;
/**
* Widgets plugin for Gwt Query. Be careful, this plugin is still experimental.
@@ -83,351 +51,7 @@ public class Widgets extends QueuePlugin<Widgets> { super(gq);
}
- /**
- * Create a {@link Button} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link Button} created
- * by passing them in parameter.
- *
- */
- public Widgets button() {
- return widgets(new ButtonWidgetFactory(), null);
- }
-
- /**
- * Create a {@link Button} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link Button} created
- * by passing them in parameter.
- *
- */
- public Widgets button(WidgetInitializer<Button> initializers) {
- return widgets(new ButtonWidgetFactory(), initializers);
- }
-
- /**
- * Create a {@link DateBox} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link Button} created
- * by passing them in parameter.
- */
- public Widgets datebox() {
- return widgets(new DateBoxWidgetFactory(), null);
- }
-
- /**
- * Create a {@link DateBox} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link Button} created
- * by passing them in parameter.
- */
- public Widgets datebox(WidgetInitializer<DateBox> initializers) {
- return widgets(new DateBoxWidgetFactory(), initializers);
- }
-
- /**
- * Create a {@link DisclosurePanel} widget for each selected elements.
- */
- public Widgets disclosurePanel() {
- return disclosurePanel(new DisclosurePanelOptions(), null);
- }
-
- /**
- * Create a {@link DisclosurePanel} widget for each selected elements.
- */
- public Widgets disclosurePanel(DisclosurePanelOptions o,
- WidgetInitializer<DisclosurePanel> initializers) {
- return widgets(new DisclosurePanelWidgetFactory(o), initializers);
- }
-
- /**
- * Create a {@link DisclosurePanel} widget for each selected elements.
- */
- public Widgets disclosurePanel(DisclosurePanelOptions o) {
- return widgets(new DisclosurePanelWidgetFactory(o), null);
- }
-
- /**
- * Create {@link DisclosurePanel} widget for each selected elements.
- */
- public Widgets disclosurePanel(WidgetInitializer<DisclosurePanel> initializers) {
- return disclosurePanel(new DisclosurePanelOptions(), initializers);
- }
-
- /**
- * Create a {@link ListBox} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link ListBox}
- * created by passing them in parameter.
- *
- */
- public Widgets listBox(ListBoxOptions options,
- WidgetInitializer<ListBox> initializers) {
- return widgets(new ListBoxWidgetFactory(options), initializers);
- }
-
- /**
- * Create a {@link ListBox} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link ListBox}
- * created by passing them in parameter.
- *
- */
- public Widgets listBox(ListBoxOptions options) {
- return widgets(new ListBoxWidgetFactory(options), null);
- }
-
- /**
- * Create a {@link ListBox} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link ListBox}
- * created by passing them in parameter.
- */
- public Widgets listBox(WidgetInitializer<ListBox> initializers) {
- return listBox(new ListBoxOptions(), initializers);
- }
-
- /**
- * Create a {@link ListBox} widget for each selected element.
- */
- public Widgets listBox() {
- return listBox(new ListBoxOptions(), null);
- }
-
- /**
- * Create a {@link PasswordTextBox} widget for each selected element.
- */
- public Widgets passwordBox() {
- return widgets(new PasswordTextBoxWidgetFactory(), null);
- }
-
- /**
- * Create a {@link CheckBox} widget for each selected element.
- */
- public Widgets checkBox(WidgetInitializer<CheckBox> initializers) {
- return widgets(new CheckBoxWidgetFactory(), initializers);
- }
-
- /**
- * Create a {@link CheckBox} widget for each selected element.
- */
- public Widgets checkBox() {
- return widgets(new CheckBoxWidgetFactory(), null);
- }
-
- /**
- * Create a {@link PasswordTextBox} widget for each selected element. The
- * <code>initializers</code> will be called on each new
- * {@link PasswordTextBox} created by passing them in parameter.
- *
- */
- public Widgets passwordBox(WidgetInitializer<PasswordTextBox> initializers) {
- return widgets(new PasswordTextBoxWidgetFactory(), initializers);
- }
-
- /*
- * public Widgets richtext(WidgetInitializer initializers) { return
- * widgets(new RichTextWidgetFactory(), initializers); }
- */
-
- /**
- * Create a {@link StackPanel} 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
- */
- public Widgets stackPanel(StackPanelOptions o,
- WidgetInitializer<StackPanel> initializers) {
- return widgets(new StackPanelWidgetFactory(o), initializers);
- }
-
- /**
- * Create a {@link StackPanel} 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
- */
- public Widgets stackPanel(StackPanelOptions o) {
- return widgets(new StackPanelWidgetFactory(o), null);
- }
-
- /**
- * 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
- */
- public Widgets stackPanel(WidgetInitializer<StackPanel> initializers) {
- return stackPanel(new StackPanelOptions(), initializers);
- }
-
- /**
- * 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
- */
- public Widgets stackPanel() {
- return stackPanel(new StackPanelOptions(), null);
- }
-
- /**
- * Create {@link RadioButton} widget for each selected elements. All
- * {@link RadioButton} created will be group under the same name specified in
- * the {@link RadioButtonOption o}
- */
- public Widgets radioButton(RadioButtonOption o,
- WidgetInitializer<RadioButton> initializers) {
- return widgets(new RadioButtonWidgetFactory(o), initializers);
- }
-
- /**
- * Create {@link RadioButton} widget for each selected elements. All
- * {@link RadioButton} created will be group under the same name specified in
- * the {@link RadioButtonOption o}
- */
- public Widgets radioButton(RadioButtonOption o) {
- return widgets(new RadioButtonWidgetFactory(o), null);
- }
-
- /**
- * Create {@link RadioButton} widget for each selected elements. All
- * {@link RadioButton} created will be group under the same name
- */
- public Widgets radioButton(WidgetInitializer<RadioButton> initializers) {
- return radioButton(new RadioButtonOption(), initializers);
- }
-
- /**
- * Create {@link RadioButton} widget for each selected elements. All
- * {@link RadioButton} created will be group under the same name
- */
- public Widgets radioButton() {
- return radioButton(new RadioButtonOption(), null);
- }
-
- /**
- * Create a {@link SuggestBox} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link SuggestBox}
- * created by passing them in parameter.
- *
- */
- public Widgets suggestBox(SuggestBoxOptions options,
- WidgetInitializer<SuggestBox> initializers) {
- return widgets(new SuggestBoxWidgetFactory(options), initializers);
- }
-
- /**
- * Create a {@link SuggestBox} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link SuggestBox}
- * created by passing them in parameter.
- *
- */
- public Widgets suggestBox(SuggestBoxOptions options) {
- return widgets(new SuggestBoxWidgetFactory(options), null);
- }
-
- /**
- * Create a {@link SuggestBox} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link SuggestBox}
- * created by passing them in parameter.
- *
- */
- public Widgets suggestBox(WidgetInitializer<SuggestBox> initializers) {
- return suggestBox(new SuggestBoxOptions(), initializers);
- }
-
- /**
- * Create a {@link SuggestBox} widget for each selected element.
- */
- public Widgets suggestBox() {
- return suggestBox(new SuggestBoxOptions(), null);
- }
-
- /**
- * 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
- */
- public Widgets tabPanel(TabPanelOptions o,
- WidgetInitializer<TabPanel> initializers) {
- return widgets(new TabPanelWidgetFactory(o), 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
- */
- public Widgets tabPanel(TabPanelOptions o) {
- return widgets(new TabPanelWidgetFactory(o), null);
- }
-
- /**
- * 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
- */
- public Widgets tabPanel(WidgetInitializer<TabPanel> initializers) {
- return tabPanel(new TabPanelOptions(), initializers);
- }
-
- /**
- * 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
- */
- public Widgets tabPanel() {
- return tabPanel(new TabPanelOptions(), null);
- }
-
- /**
- * Create a {@link TextBox} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link TextBox}
- * created by passing them in parameter.
- *
- */
- public Widgets textBox() {
- return widgets(new TextBoxWidgetFactory(), null);
- }
-
- /**
- * Create a {@link TextBox} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link TextBox}
- * created by passing them in parameter.
- *
- */
- public Widgets textBox(WidgetInitializer<TextBox> initializers) {
- return widgets(new TextBoxWidgetFactory(), initializers);
- }
-
- /**
- * Create a {@link TextArea} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link TextBox}
- * created by passing them in parameter.
- *
- */
- public Widgets textArea() {
- return widgets(new TextAreaWidgetFactory(), null);
- }
-
- /**
- * Create a {@link TextArea} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link TextBox}
- * created by passing them in parameter.
- *
- */
- public Widgets textArea(WidgetInitializer<TextArea> initializers) {
- return widgets(new TextAreaWidgetFactory(), initializers);
- }
-
- /**
- * Create a {@link DecoratorPanel} widget for each selected element.
- */
- public Widgets decoratorPanel() {
- return widgets(new DecoratorPanelWidgetFactory(), null);
- }
-
- /**
- * Create a {@link DecoratorPanel} widget for each selected element. The
- * <code>initializers</code> will be called on each new {@link DecoratorPanel}
- * created by passing them in parameter.
- *
- */
- public Widgets decoratorPanel(WidgetInitializer<DecoratorPanel> initializers) {
- return widgets(new DecoratorPanelWidgetFactory(), 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
@@ -471,7 +95,6 @@ public class Widgets extends QueuePlugin<Widgets> { */
protected <W extends Widget> W widget(WidgetFactory<W> factory,
WidgetInitializer<W> initializers) {
-
return widget(get(0), factory, initializers);
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ButtonWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ButtonWidgetFactory.java deleted file mode 100644 index 90b8002c..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ButtonWidgetFactory.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/CheckBoxWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/CheckBoxWidgetFactory.java deleted file mode 100644 index 2debaae4..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/CheckBoxWidgetFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/DateBoxWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/DateBoxWidgetFactory.java deleted file mode 100644 index c7e574e0..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/DateBoxWidgetFactory.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/DecoratorPanelWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/DecoratorPanelWidgetFactory.java deleted file mode 100644 index 9ca46cdd..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/DecoratorPanelWidgetFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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; - } - -} diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/DisclosurePanelWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/DisclosurePanelWidgetFactory.java deleted file mode 100644 index e4e92f68..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/DisclosurePanelWidgetFactory.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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; - } - -} diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ListBoxWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ListBoxWidgetFactory.java deleted file mode 100644 index 75008816..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ListBoxWidgetFactory.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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 diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/PasswordTextBoxWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/PasswordTextBoxWidgetFactory.java deleted file mode 100644 index 2d98e941..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/PasswordTextBoxWidgetFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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(); - } -} diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/RadioButtonWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/RadioButtonWidgetFactory.java deleted file mode 100644 index d30d489e..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/RadioButtonWidgetFactory.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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 diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/RichTextWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/RichTextWidgetFactory.java deleted file mode 100644 index 8e4677b4..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/RichTextWidgetFactory.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/StackPanelWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/StackPanelWidgetFactory.java deleted file mode 100644 index 8172d2dc..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/StackPanelWidgetFactory.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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; - } - -} diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/SuggestBoxWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/SuggestBoxWidgetFactory.java deleted file mode 100644 index 006f4e90..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/SuggestBoxWidgetFactory.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TabPanelWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TabPanelWidgetFactory.java deleted file mode 100644 index 97009b2d..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TabPanelWidgetFactory.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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; - } -} diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextAreaWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextAreaWidgetFactory.java deleted file mode 100644 index 2fab94c9..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextAreaWidgetFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextBoxBaseWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextBoxBaseWidgetFactory.java deleted file mode 100644 index c0b03d35..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextBoxBaseWidgetFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextBoxWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextBoxWidgetFactory.java deleted file mode 100644 index 4cbe5c54..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/TextBoxWidgetFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTest.java index 25a811f4..33d0ee02 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTest.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTest.java @@ -18,11 +18,14 @@ package com.google.gwt.query.client; 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; @@ -104,6 +107,15 @@ public class GQueryWidgetsTest extends GWTTestCase { 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); @@ -111,8 +123,8 @@ public class GQueryWidgetsTest extends GWTTestCase { 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"); diff --git a/samples/src/main/java/gwtquery/samples/GwtQueryWidgets.gwt.xml b/samples/src/main/java/gwtquery/samples/GwtQueryWidgets.gwt.xml deleted file mode 100644 index 014b421b..00000000 --- a/samples/src/main/java/gwtquery/samples/GwtQueryWidgets.gwt.xml +++ /dev/null @@ -1,6 +0,0 @@ -<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> - diff --git a/samples/src/main/java/gwtquery/samples/client/GwtQueryWidgetModule.java b/samples/src/main/java/gwtquery/samples/client/GwtQueryWidgetModule.java deleted file mode 100644 index 8faa5cf9..00000000 --- a/samples/src/main/java/gwtquery/samples/client/GwtQueryWidgetModule.java +++ /dev/null @@ -1,122 +0,0 @@ -/*
- * 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 gwtquery.samples.client;
-
-import static com.google.gwt.query.client.GQuery.$;
-import static com.google.gwt.query.client.plugins.Widgets.Widgets;
-
-import com.google.gwt.core.client.EntryPoint;
-import com.google.gwt.core.client.GWT;
-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.query.client.plugins.widgets.WidgetInitializer;
-import com.google.gwt.query.client.plugins.widgets.ListBoxWidgetFactory.ListBoxOptions;
-import com.google.gwt.query.client.plugins.widgets.SuggestBoxWidgetFactory.SuggestBoxOptions;
-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.GqUi;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.PopupPanel;
-import com.google.gwt.user.client.ui.RootPanel;
-import com.google.gwt.user.client.ui.Tree;
-import com.google.gwt.user.client.ui.TreeItem;
-import com.google.gwt.user.client.ui.Widget;
-
-import java.util.Iterator;
-
-public class GwtQueryWidgetModule implements EntryPoint {
-
- public static class MyButtonInitializer implements WidgetInitializer<Button> {
-
- public void initialize(Button button, Element e) {
-
- final String tag = e.getTagName();
- button.addClickHandler(new ClickHandler() {
-
- public void onClick(ClickEvent event) {
- Label l = new Label("You click on a GWT Button create from a " + tag);
- PopupPanel panel = new PopupPanel(true, true);
- panel.setGlassEnabled(true);
- panel.add(l);
- panel.center();
-
- }
- });
-
- }
- }
-
- public void onModuleLoad() {
-
- $("#disclosure").as(Widgets).disclosurePanel();
-
- $(".inputText").as(Widgets).textBox();
- $(".inputPsw").as(Widgets).passwordBox();
- $(".textArea").as(Widgets).textArea();
-
- $(".btn").as(Widgets).button(new MyButtonInitializer());
-
- $("#tabs").as(Widgets).tabPanel(
- new TabPanelOptions("div.tab", "h3.tabTitle"));
- //$(".editable").as(Widgets).richtext().widget();
-
- $(".date").as(Widgets).datebox();
-
- $(".list").as(Widgets).listBox();
- $("#multiSelect").as(Widgets).listBox(new ListBoxOptions(".item", true));
- $("#suggestBox1").as(Widgets).suggestBox(new SuggestBoxOptions("div"));
- $("#suggestBox2").as(Widgets).suggestBox(new SuggestBoxOptions("li"));
- $(".stack").as(Widgets).stackPanel();
- $(".checkBox").as(Widgets).checkBox();
- $(".radio").as(Widgets).radioButton();
-
- $("body > div").as(Widgets).decoratorPanel();
-
- GWT.log("Found " + $(".btn").widgets().size() + " buttons widget");
-
- displayWidgetHierarchy();
- }
-
- private void displayWidgetHierarchy() {
- DisclosurePanel disclosurePanel = $("#disclosure").widget();
- Tree widgetHierarchy = new Tree();
- TreeItem rootItem = new TreeItem(disclosurePanel.getClass().getName());
- widgetHierarchy.addItem(rootItem);
- widgetHierarchy.setAnimationEnabled(true);
- addChildren(rootItem, disclosurePanel);
-
- RootPanel.get().add(new Label("Widgets hierarchy :"));
- RootPanel.get().add(widgetHierarchy);
- }
-
- private void addChildren(TreeItem item, Widget w) {
- Iterator<Widget> children = GqUi.getChildren(w);
- if (children != null) {
- while (children.hasNext()) {
- Widget child = children.next();
- TreeItem subItem = new TreeItem(child.getClass().getName());
- item.addItem(subItem);
-
- addChildren(subItem, child);
-
- }
- }
-
- }
-
-}
diff --git a/samples/src/main/java/gwtquery/samples/public/GwtQueryWidgets.html b/samples/src/main/java/gwtquery/samples/public/GwtQueryWidgets.html deleted file mode 100644 index 0a6eb9d5..00000000 --- a/samples/src/main/java/gwtquery/samples/public/GwtQueryWidgets.html +++ /dev/null @@ -1,199 +0,0 @@ -<html>
-<head>
-<title>GQuery Demo</title>
-<script language="javascript"
- src="gwtquery.samples.GwtQueryWidgets.nocache.js" ></script>
-<style type="text/css">
-.outer {
- margin: 5px;
-}
-</style>
-</head>
-<body>
-
-<div class="outer">
-<div id="disclosure">
-<h3>Show the widgets</h3>
-<div>
- <div id="tabs">
-
- <h3 class="tabTitle">Buttons</h3>
- <div class="tab">
- <div class="outer">
- <div class="btn">Make me a button 1!</div>
- <a class="btn">Make me a button 2!</a>
- <span class="btn">Make me a button 3!</span>
- <button class="btn">Make me a button 4!</button>
- <div class="btn">Make me a button 5!</div>
- <div class="btn">Make me a button 6!</div>
- </div>
- </div>
-
- <h3 class="tabTitle">Inputs</h3>
-
- <div class="tab">
- <input type="text" class="date"
- value="dd/MM/yyyy" />
-
- <div class="outer">
- <div class="inputText">I will be a text input</div>
- <span class="inputText">I will be a text input</span>
- <input
- class="inputText" type="text" value="I will be a text input"></input>
- </div>
-
- <div class="outer">
- <div class="inputPsw">I will be an password input</div>
- <span class="inputPsw">I will be an password input</span>
- <input
- class="inputPsw" type="password" value="I will be an password input"></input>
- </div>
- <input type="text" class="date" value="dd/MM/yyyy" />
-
- <div class="outer">
- <div class="textArea">I will be a text area</div>
- <span class="textArea">I will be a text area</span>
- <textarea class="textArea">I will be a text area</textarea>
- </div>
-
- <div class="outer">
- <div id="suggestBox1">
- <div>suggestion a</div>
- <div>suggestion b</div>
- <div>suggestion c</div>
- <div>suggestion d</div>
- <div>suggestion e</div>
- <div>suggestion f</div>
- <div>suggestion g</div>
- <div>suggestion h</div>
- <div>suggestion i</div>
- <div>suggestion j</div>
- <div>suggestion k</div>
- <div>suggestion l</div>
- <div>suggestion m</div>
- <div>suggestion n</div>
- <div>suggestion o</div>
- <div>suggestion p</div>
- <div>suggestion q</div>
- <div>suggestion r</div>
- <div>suggestion s</div>
- <div>suggestion t</div>
- <div>suggestion u</div>
- <div>suggestion v</div>
- <div>suggestion w</div>
- <div>suggestion x</div>
- <div>suggestion y</div>
- <div>suggestion z</div>
- </div>
-
- <ul id="suggestBox2">
- <li>suggestion a</li>
- <li>suggestion b</li>
- <li>suggestion c</li>
- <li>suggestion d</li>
- <li>suggestion e</li>
- <li>suggestion f</li>
- <li>suggestion g</li>
- <li>suggestion h</li>
- <li>suggestion i</li>
- <li>suggestion j</li>
- <li>suggestion k</li>
- <li>suggestion l</li>
- <li>suggestion m</li>
- <li>suggestion n</li>
- <li>suggestion o</li>
- <li>suggestion p</li>
- <li>suggestion q</li>
- <li>suggestion r</li>
- <li>suggestion s</li>
- <li>suggestion t</li>
- <li>suggestion u</li>
- <li>suggestion v</li>
- <li>suggestion w</li>
- <li>suggestion x</li>
- <li>suggestion y</li>
- <li>suggestion z</li>
- </ul>
-
- <div class="outer">
- <div class="checkBox">Checkbox</div>
- <div class="checkBox">created</div>
- <div class="checkBox">from div</div>
- </div>
-
- <div class="outer">
- <div class="radio">RadioButton</div>
- <div class="radio">created</div>
- <div class="radio">from div</div>
- </div>
- </div>
-
-
- </div>
-
- <h3 class="tabTitle">Normal Tab</h3>
- <div class="tab">Pellentesque habitant morbi tristique senectus et netus et
- malesuada fames ac turpis egestas. Duis feugiat dapibus nunc, sit amet
- sodales dolor bibendum eget. Pellentesque ac libero et nibh ultrices
- vehicula. Morbi convallis auctor ultricies. Class aptent taciti sociosqu
- ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean
- gravida eros at massa fringilla vestibulum. Sed justo dui, euismod et
- venenatis in, vehicula ut nisi. Sed sodales lorem vel est luctus vitae
- ornare erat pulvinar. Maecenas lacus sem, ultrices vitae tincidunt in,
- gravida eget quam. Vestibulum condimentum, augue nec consectetur
- egestas, mi sapien ullamcorper diam, sit amet molestie mauris odio at
- lacus.</div>
-
- <h3 class="tabTitle">SelectBoxes</h3>
- <div class="tab">
- <div class="outer">
- <select class="list">
- <option>option 11</option>
- <option>option 12</option>
- <option>option 13</option>
- <option>option 14</option>
- </select>
-
- <ul class="list">
- <li>option 21</li>
- <li>option 22</li>
- <li>option 23</li>
- <li>option 23</li>
- </ul>
-
- <div class="list">
- <div>div 1</div>
- <div>div 2</div>
- <span>span 1</span>
- <span>span 1</span>
- </div>
-
- <div id="multiSelect">
- <div>div 1</div>
- <div class="item">div 2</div>
- <span>span 1</span>
- <span class="item">span 1</span>
- </div>
- </div>
- </div>
-
- <h3 class="tabTitle">StackPanel</h3>
- <div class="tab">
- <div class="stack">
- <h3>header 1</h3>
- <div> content 1</div>
-
- <h3>header 2</h3>
- <div> content 2</div>
-
- <h3>header 3</h3>
- <div> content 3</div>
- </div>
- </div>
- </div>
- </div>
-</div>
-</div>
-
-</body>
-</html>
diff --git a/samples/src/main/webapp/index.html b/samples/src/main/webapp/index.html index 25cd7f3e..743cda7c 100644 --- a/samples/src/main/webapp/index.html +++ b/samples/src/main/webapp/index.html @@ -11,15 +11,16 @@ } </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> |