From: Joonas Lehtinen Date: Wed, 24 Sep 2008 11:52:22 +0000 (+0000) Subject: Reviewed #1397 and did the following changes/corrections: X-Git-Tag: 6.7.0.beta1~4101 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bc2b50c5bc7a76329cb1bbedf61d0056953f000d;p=vaadin-framework.git Reviewed #1397 and did the following changes/corrections: - 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 --- diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java index efa6f38bdf..305f4a6b61 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java @@ -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 activeChildren; + private final Set activeChildren; public CustomPopup() { super(true, false, true); // autoHide, not modal, dropshadow diff --git a/src/com/itmill/toolkit/ui/PopupView.java b/src/com/itmill/toolkit/ui/PopupView.java index 4e8a18a3b2..252e137c21 100644 --- a/src/com/itmill/toolkit/ui/PopupView.java +++ b/src/com/itmill/toolkit/ui/PopupView.java @@ -20,8 +20,7 @@ public class PopupView extends AbstractComponentContainer { private Content content; private boolean popupVisible; - private ArrayList componentList; - private boolean animationEnabled; + private final ArrayList componentList; /* Constructors */ @@ -59,7 +58,6 @@ public class PopupView extends AbstractComponentContainer { super(); setContent(content); popupVisible = false; - animationEnabled = false; componentList = new ArrayList(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();