]> source.dussan.org Git - gwtquery.git/commitdiff
add DecoratorPanel factory
authorJulien Dramaix <julien.dramaix@gmail.com>
Mon, 14 Mar 2011 21:39:00 +0000 (21:39 +0000)
committerJulien Dramaix <julien.dramaix@gmail.com>
Mon, 14 Mar 2011 21:39:00 +0000 (21:39 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyWidgets.java
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/DecoratorPanelWidgetFactory.java [new file with mode: 0644]
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java
samples/src/main/java/gwtquery/samples/client/GwtQueryWidgetModule.java

index d2e4857ba6e92b09865c31581d04e395ade230e0..cbc1581e0a6cceedcb51168267ae835d1d660986 100644 (file)
@@ -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;
@@ -300,6 +302,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
index 2c001c0fb2789de2a7cc468fe523f435134a2366..bc3f35e8ae38702b4824c034390ff8cc400c4f56 100755 (executable)
@@ -20,6 +20,7 @@ import com.google.gwt.query.client.GQuery;
 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
@@ -40,6 +41,7 @@ import com.google.gwt.query.client.plugins.widgets.SuggestBoxWidgetFactory.Sugge
 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
@@ -408,6 +410,24 @@ public class Widgets extends QueuePlugin<Widgets> {
     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
    * 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
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 (file)
index 0000000..9ca46cd
--- /dev/null
@@ -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;
+  }
+
+}
index d022f83897ef081d696be85e54fbf9f1c438b3c9..a4d35ed633677b015e488deb831765ff456aa0ae 100644 (file)
@@ -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"};
 
   
index 83d0169d4e609073d2652a3c81e61598ac8ccb4d..8faa5cf9416c159eb20fbe4eacfd9da6935345bb 100644 (file)
@@ -84,6 +84,8 @@ public class GwtQueryWidgetModule implements EntryPoint {
     $(".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