]> source.dussan.org Git - vaadin-framework.git/commitdiff
Reviewed #1397 and did the following changes/corrections:
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Wed, 24 Sep 2008 11:52:22 +0000 (11:52 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Wed, 24 Sep 2008 11:52:22 +0000 (11:52 +0000)
- paintContent() does not trigged creation of new editors anymore (if not needed)
- existing editors are used, if assigned to component
- popupVisibility is changed to be variable (not attribute)
- removed setAnimation(). Now allways animates

svn changeset:5501/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java
src/com/itmill/toolkit/ui/PopupView.java

index efa6f38bdf0e18d0d8d76dfe491ebbe26ad54453..305f4a6b61a990e2a9424bad461997485c90bee3 100644 (file)
@@ -36,7 +36,7 @@ public class IPopupView extends HTML implements Paintable {
     /** This variable helps to communicate popup visibility to the server */
     private boolean hostPopupVisible;
 
-    private CustomPopup popup;
+    private final CustomPopup popup;
     private final Label loading = new Label("Loading...");
 
     // Browser window sizes
@@ -72,6 +72,7 @@ public class IPopupView extends HTML implements Paintable {
             }
         });
 
+        popup.setAnimationEnabled(true);
     }
 
     /**
@@ -92,17 +93,14 @@ public class IPopupView extends HTML implements Paintable {
 
         updateWindowSize();
 
-        hostPopupVisible = uidl.getBooleanAttribute("popupVisible");
+        hostPopupVisible = uidl.getBooleanVariable("popupVisibility");
+
         setHTML(uidl.getStringAttribute("html"));
 
         if (uidl.hasAttribute("description")) {
             setTitle(uidl.getStringAttribute("description"));
         }
 
-        if (uidl.hasAttribute("animation")) {
-            popup.setAnimationEnabled(uidl.getBooleanAttribute("animation"));
-        }
-
         // Render the popup if visible and show it.
         if (hostPopupVisible) {
             UIDL popupUIDL = uidl.getChildUIDL(0);
@@ -171,10 +169,10 @@ public class IPopupView extends HTML implements Paintable {
     }
 
     public static native void nativeBlur(Element e) /*-{ 
-                                        if(e.focus) {
-                                        e.blur();
-                                        }
-                                        }-*/;
+                                              if(e.focus) {
+                                              e.blur();
+                                              }
+                                              }-*/;
 
     private class CustomPopup extends IToolkitOverlay implements Container {
 
@@ -183,7 +181,7 @@ public class IPopupView extends HTML implements Paintable {
         private ICaptionWrapper captionWrapper = null;
 
         private boolean hasHadMouseOver = false;
-        private Set<Element> activeChildren;
+        private final Set<Element> activeChildren;
 
         public CustomPopup() {
             super(true, false, true); // autoHide, not modal, dropshadow
index 4e8a18a3b25c316a647db44caffbb60c9a98c6d9..252e137c21486ef6b510c344ab51d2689c4535ad 100644 (file)
@@ -20,8 +20,7 @@ public class PopupView extends AbstractComponentContainer {
 
     private Content content;
     private boolean popupVisible;
-    private ArrayList<Component> componentList;
-    private boolean animationEnabled;
+    private final ArrayList<Component> componentList;
 
     /* Constructors */
 
@@ -59,7 +58,6 @@ public class PopupView extends AbstractComponentContainer {
         super();
         setContent(content);
         popupVisible = false;
-        animationEnabled = false;
         componentList = new ArrayList<Component>(1);
     }
 
@@ -81,7 +79,7 @@ public class PopupView extends AbstractComponentContainer {
                     "Content object is or contains null");
         }
 
-        this.content = newContent;
+        content = newContent;
         requestRepaint();
     }
 
@@ -103,24 +101,6 @@ public class PopupView extends AbstractComponentContainer {
         return popupVisible;
     }
 
-    /**
-     * Enable / disable popup viewing animation
-     * 
-     * @param enabled
-     */
-    public void setAnimation(boolean enabled) {
-        animationEnabled = enabled;
-    }
-
-    /**
-     * Query if the viewing animation is enabled.
-     * 
-     * @return true if the animation is enabled
-     */
-    public boolean isAnimationEnabled() {
-        return animationEnabled;
-    }
-
     /*
      * Methods inherited from AbstractComponentContainer. These are unnecessary
      * (but mandatory). Most of them are not supported in this implementation.
@@ -219,11 +199,18 @@ public class PopupView extends AbstractComponentContainer {
                     "Recieved null when trying to paint minimized value.");
         }
         target.addAttribute("html", content.getMinimizedValueAsHTML());
-        target.addAttribute("popupVisible", popupVisible);
-        target.addAttribute("animation", animationEnabled);
+
         // Only paint component to client if we know that the popup is showing
         if (popupVisible) {
-            Component c = content.getPopupComponent();
+            Component c = componentList.get(0);
+
+            if (c == null) {
+                c = content.getPopupComponent();
+                if (c != null) {
+                    componentList.add(c);
+                    super.addComponent(c);
+                }
+            }
 
             if (c == null) {
                 throw new PaintException(
@@ -235,6 +222,7 @@ public class PopupView extends AbstractComponentContainer {
             target.endTag("popupComponent");
         }
 
+        target.addVariable(this, "popupVisibility", popupVisible);
     }
 
     /**
@@ -246,18 +234,21 @@ public class PopupView extends AbstractComponentContainer {
     public void changeVariables(Object source, Map variables) {
         if (variables.containsKey("popupVisibility")) {
 
-            // TODO we could use server-side boolean allowPopup here to prevent
-            // popups from showing
-
             popupVisible = ((Boolean) variables.get("popupVisibility"))
                     .booleanValue();
 
             if (popupVisible) {
-                Component c = content.getPopupComponent();
-                componentList.add(c);
-                super.addComponent(c);
+                if (componentList.isEmpty()) {
+                    Component c = content.getPopupComponent();
+                    if (c != null) {
+                        componentList.add(c);
+                        super.addComponent(c);
+                    } else {
+                        popupVisible = false;
+                    }
+                }
             } else if (!componentList.isEmpty()) {
-                super.removeComponent((Component) componentList.get(0));
+                super.removeComponent(componentList.get(0));
                 componentList.clear();
             }
             requestRepaint();