]> source.dussan.org Git - vaadin-framework.git/commitdiff
#8324 Split PopupView into widget and paintable
authorArtur Signell <artur@vaadin.com>
Tue, 31 Jan 2012 11:59:15 +0000 (13:59 +0200)
committerArtur Signell <artur@vaadin.com>
Tue, 31 Jan 2012 13:08:41 +0000 (15:08 +0200)
src/com/vaadin/terminal/gwt/client/ui/VPopupView.java
src/com/vaadin/terminal/gwt/client/ui/VPopupViewPaintable.java [new file with mode: 0644]
src/com/vaadin/ui/PopupView.java

index e667489dda47ad9cabbd91c8000cb22dd7e32038..34bf0ca619c2e9f66050af01b262c3cb701dd25b 100644 (file)
@@ -29,7 +29,6 @@ import com.vaadin.terminal.gwt.client.RenderInformation.Size;
 import com.vaadin.terminal.gwt.client.RenderSpace;
 import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.Util;
-import com.vaadin.terminal.gwt.client.VCaption;
 import com.vaadin.terminal.gwt.client.VCaptionWrapper;
 import com.vaadin.terminal.gwt.client.VPaintableWidget;
 import com.vaadin.terminal.gwt.client.VTooltip;
@@ -40,13 +39,13 @@ public class VPopupView extends HTML implements Container, Iterable<Widget> {
     public static final String CLASSNAME = "v-popupview";
 
     /** For server-client communication */
-    private String uidlId;
-    private ApplicationConnection client;
+    String uidlId;
+    ApplicationConnection client;
 
     /** This variable helps to communicate popup visibility to the server */
-    private boolean hostPopupVisible;
+    boolean hostPopupVisible;
 
-    private final CustomPopup popup;
+    final CustomPopup popup;
     private final Label loading = new Label();
 
     /**
@@ -81,61 +80,6 @@ public class VPopupView extends HTML implements Container, Iterable<Widget> {
         sinkEvents(VTooltip.TOOLTIP_EVENTS);
     }
 
-    /**
-     * 
-     * 
-     * @see com.vaadin.terminal.gwt.client.VPaintableWidget#updateFromUIDL(com.vaadin.terminal.gwt.client.UIDL,
-     *      com.vaadin.terminal.gwt.client.ApplicationConnection)
-     */
-    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-        // This call should be made first. Ensure correct implementation,
-        // and don't let the containing layout manage caption.
-        if (client.updateComponent(this, uidl, false)) {
-            return;
-        }
-        // These are for future server connections
-        this.client = client;
-        uidlId = uidl.getId();
-
-        hostPopupVisible = uidl.getBooleanVariable("popupVisibility");
-
-        setHTML(uidl.getStringAttribute("html"));
-
-        if (uidl.hasAttribute("hideOnMouseOut")) {
-            popup.setHideOnMouseOut(uidl.getBooleanAttribute("hideOnMouseOut"));
-        }
-
-        // Render the popup if visible and show it.
-        if (hostPopupVisible) {
-            UIDL popupUIDL = uidl.getChildUIDL(0);
-
-            // showPopupOnTop(popup, hostReference);
-            preparePopup(popup);
-            popup.updateFromUIDL(popupUIDL, client);
-            if (uidl.hasAttribute("style")) {
-                final String[] styles = uidl.getStringAttribute("style").split(
-                        " ");
-                final StringBuffer styleBuf = new StringBuffer();
-                final String primaryName = popup.getStylePrimaryName();
-                styleBuf.append(primaryName);
-                for (int i = 0; i < styles.length; i++) {
-                    styleBuf.append(" ");
-                    styleBuf.append(primaryName);
-                    styleBuf.append("-");
-                    styleBuf.append(styles[i]);
-                }
-                popup.setStyleName(styleBuf.toString());
-            } else {
-                popup.setStyleName(popup.getStylePrimaryName());
-            }
-            showPopup(popup);
-
-            // The popup shouldn't be visible, try to hide it.
-        } else {
-            popup.hide();
-        }
-    }// updateFromUIDL
-
     /**
      * Update popup visibility to server
      * 
@@ -149,7 +93,7 @@ public class VPopupView extends HTML implements Container, Iterable<Widget> {
         }
     }
 
-    private void preparePopup(final CustomPopup popup) {
+    void preparePopup(final CustomPopup popup) {
         popup.setVisible(false);
         popup.show();
     }
@@ -231,8 +175,8 @@ public class VPopupView extends HTML implements Container, Iterable<Widget> {
     protected class CustomPopup extends VOverlay {
 
         private VPaintableWidget popupComponentPaintable = null;
-        private Widget popupComponentWidget = null;
-        private VCaptionWrapper captionWrapper = null;
+        Widget popupComponentWidget = null;
+        VCaptionWrapper captionWrapper = null;
 
         private boolean hasHadMouseOver = false;
         private boolean hideOnMouseOut = true;
@@ -446,27 +390,11 @@ public class VPopupView extends HTML implements Container, Iterable<Widget> {
         return true;
     }
 
-    public void updateCaption(VPaintableWidget component, UIDL uidl) {
-        if (VCaption.isNeeded(uidl)) {
-            if (popup.captionWrapper != null) {
-                popup.captionWrapper.updateCaption(uidl);
-            } else {
-                popup.captionWrapper = new VCaptionWrapper(component, client);
-                popup.setWidget(popup.captionWrapper);
-                popup.captionWrapper.updateCaption(uidl);
-            }
-        } else {
-            if (popup.captionWrapper != null) {
-                popup.setWidget(popup.popupComponentWidget);
-            }
-        }
-    }
-
     @Override
     public void onBrowserEvent(Event event) {
         super.onBrowserEvent(event);
         if (client != null) {
-            client.handleTooltipEvent(event, this);
+            client.handleWidgetTooltipEvent(event, this);
         }
     }
 
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPopupViewPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VPopupViewPaintable.java
new file mode 100644 (file)
index 0000000..627f925
--- /dev/null
@@ -0,0 +1,104 @@
+package com.vaadin.terminal.gwt.client.ui;\r
+\r
+import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.user.client.ui.Widget;\r
+import com.vaadin.terminal.gwt.client.ApplicationConnection;\r
+import com.vaadin.terminal.gwt.client.UIDL;\r
+import com.vaadin.terminal.gwt.client.VCaption;\r
+import com.vaadin.terminal.gwt.client.VCaptionWrapper;\r
+import com.vaadin.terminal.gwt.client.VPaintableWidget;\r
+\r
+public class VPopupViewPaintable extends VAbstractPaintableWidgetContainer {\r
+\r
+    /**\r
+     * \r
+     * \r
+     * @see com.vaadin.terminal.gwt.client.VPaintableWidget#updateFromUIDL(com.vaadin.terminal.gwt.client.UIDL,\r
+     *      com.vaadin.terminal.gwt.client.ApplicationConnection)\r
+     */\r
+    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+        // This call should be made first. Ensure correct implementation,\r
+        // and don't let the containing layout manage caption.\r
+        if (client.updateComponent(this, uidl, false)) {\r
+            return;\r
+        }\r
+        // These are for future server connections\r
+        getWidgetForPaintable().client = client;\r
+        getWidgetForPaintable().uidlId = uidl.getId();\r
+\r
+        getWidgetForPaintable().hostPopupVisible = uidl\r
+                .getBooleanVariable("popupVisibility");\r
+\r
+        getWidgetForPaintable().setHTML(uidl.getStringAttribute("html"));\r
+\r
+        if (uidl.hasAttribute("hideOnMouseOut")) {\r
+            getWidgetForPaintable().popup.setHideOnMouseOut(uidl\r
+                    .getBooleanAttribute("hideOnMouseOut"));\r
+        }\r
+\r
+        // Render the popup if visible and show it.\r
+        if (getWidgetForPaintable().hostPopupVisible) {\r
+            UIDL popupUIDL = uidl.getChildUIDL(0);\r
+\r
+            // showPopupOnTop(popup, hostReference);\r
+            getWidgetForPaintable().preparePopup(getWidgetForPaintable().popup);\r
+            getWidgetForPaintable().popup.updateFromUIDL(popupUIDL, client);\r
+            if (uidl.hasAttribute("style")) {\r
+                final String[] styles = uidl.getStringAttribute("style").split(\r
+                        " ");\r
+                final StringBuffer styleBuf = new StringBuffer();\r
+                final String primaryName = getWidgetForPaintable().popup\r
+                        .getStylePrimaryName();\r
+                styleBuf.append(primaryName);\r
+                for (int i = 0; i < styles.length; i++) {\r
+                    styleBuf.append(" ");\r
+                    styleBuf.append(primaryName);\r
+                    styleBuf.append("-");\r
+                    styleBuf.append(styles[i]);\r
+                }\r
+                getWidgetForPaintable().popup.setStyleName(styleBuf.toString());\r
+            } else {\r
+                getWidgetForPaintable().popup\r
+                        .setStyleName(getWidgetForPaintable().popup\r
+                                .getStylePrimaryName());\r
+            }\r
+            getWidgetForPaintable().showPopup(getWidgetForPaintable().popup);\r
+\r
+            // The popup shouldn't be visible, try to hide it.\r
+        } else {\r
+            getWidgetForPaintable().popup.hide();\r
+        }\r
+    }// updateFromUIDL\r
+\r
+    public void updateCaption(VPaintableWidget component, UIDL uidl) {\r
+        if (VCaption.isNeeded(uidl)) {\r
+            if (getWidgetForPaintable().popup.captionWrapper != null) {\r
+                getWidgetForPaintable().popup.captionWrapper\r
+                        .updateCaption(uidl);\r
+            } else {\r
+                getWidgetForPaintable().popup.captionWrapper = new VCaptionWrapper(\r
+                        component, getConnection());\r
+                getWidgetForPaintable().popup\r
+                        .setWidget(getWidgetForPaintable().popup.captionWrapper);\r
+                getWidgetForPaintable().popup.captionWrapper\r
+                        .updateCaption(uidl);\r
+            }\r
+        } else {\r
+            if (getWidgetForPaintable().popup.captionWrapper != null) {\r
+                getWidgetForPaintable().popup\r
+                        .setWidget(getWidgetForPaintable().popup.popupComponentWidget);\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public VPopupView getWidgetForPaintable() {\r
+        return (VPopupView) super.getWidgetForPaintable();\r
+    }\r
+\r
+    @Override\r
+    protected Widget createWidget() {\r
+        return GWT.create(VPopupView.class);\r
+    }\r
+\r
+}\r
index fcad7275108733ef171374f9a7ea076ed347a861..5637ef69d7c4020e525749b72d5a53c20fd389ba 100644 (file)
@@ -10,7 +10,7 @@ import java.util.Map;
 
 import com.vaadin.terminal.PaintException;
 import com.vaadin.terminal.PaintTarget;
-import com.vaadin.terminal.gwt.client.ui.VPopupView;
+import com.vaadin.terminal.gwt.client.ui.VPopupViewPaintable;
 
 /**
  * 
@@ -22,7 +22,7 @@ import com.vaadin.terminal.gwt.client.ui.VPopupView;
  * @author Vaadin Ltd.
  */
 @SuppressWarnings("serial")
-@ClientWidget(VPopupView.class)
+@ClientWidget(VPopupViewPaintable.class)
 public class PopupView extends AbstractComponentContainer {
 
     private Content content;