diff options
author | Julien Dramaix <julien.dramaix@gmail.com> | 2011-03-14 21:39:00 +0000 |
---|---|---|
committer | Julien Dramaix <julien.dramaix@gmail.com> | 2011-03-14 21:39:00 +0000 |
commit | 8573fdc93952a1edff394605d8722f70470daf5d (patch) | |
tree | 53c9d5e1382957c840bfa0e26b561537be0861e1 | |
parent | 42817d883130a78f18e9ef29ccf087ccbe1fa78a (diff) | |
download | gwtquery-8573fdc93952a1edff394605d8722f70470daf5d.tar.gz gwtquery-8573fdc93952a1edff394605d8722f70470daf5d.zip |
add DecoratorPanel factory
5 files changed, 76 insertions, 1 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyWidgets.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyWidgets.java index d2e4857b..cbc1581e 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyWidgets.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyWidgets.java @@ -19,6 +19,7 @@ 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; @@ -39,6 +40,7 @@ import com.google.gwt.query.client.plugins.widgets.SuggestBoxWidgetFactory.Sugge 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; @@ -301,6 +303,19 @@ public interface LazyWidgets<T> extends LazyBase<T>{ LazyWidgets<T> textArea(WidgetInitializer<TextArea> initializers); /** + * Create a {@link DecoratorPanel} widget for each selected element. + */ + LazyWidgets<T> decoratorPanel(); + + /** + * 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. + * + */ + LazyWidgets<T> decoratorPanel(WidgetInitializer<DecoratorPanel> initializers); + + /** * Try to create a widget using the given factory and the given options for * each element of the query. Returns a new gquery set of elements with the * new widgets created. 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 2c001c0f..bc3f35e8 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 @@ -20,6 +20,7 @@ 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;
@@ -40,6 +41,7 @@ import com.google.gwt.query.client.plugins.widgets.SuggestBoxWidgetFactory.Sugge 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;
@@ -409,6 +411,24 @@ public class Widgets extends QueuePlugin<Widgets> { }
/**
+ * 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
* new widgets created.
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 new file mode 100644 index 00000000..9ca46cdd --- /dev/null +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/DecoratorPanelWidgetFactory.java @@ -0,0 +1,38 @@ +/* + * 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/WidgetsUtils.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java index d022f838..a4d35ed6 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java @@ -22,7 +22,7 @@ import com.google.gwt.user.client.ui.Widget; public class WidgetsUtils { - private static final String[] appendingTags = { + static final String[] appendingTags = { "td", "th", "li"}; diff --git a/samples/src/main/java/gwtquery/samples/client/GwtQueryWidgetModule.java b/samples/src/main/java/gwtquery/samples/client/GwtQueryWidgetModule.java index 83d0169d..8faa5cf9 100644 --- a/samples/src/main/java/gwtquery/samples/client/GwtQueryWidgetModule.java +++ b/samples/src/main/java/gwtquery/samples/client/GwtQueryWidgetModule.java @@ -84,6 +84,8 @@ public class GwtQueryWidgetModule implements EntryPoint { $(".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");
|