aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/ui/PopupView.java
diff options
context:
space:
mode:
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>2008-09-24 11:52:22 +0000
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>2008-09-24 11:52:22 +0000
commitbc2b50c5bc7a76329cb1bbedf61d0056953f000d (patch)
tree2aaf6db22c3caf120073bea9a52af4df76ddd59b /src/com/itmill/toolkit/ui/PopupView.java
parent8ec7e3425d820b13439618315ef9a4527f14c726 (diff)
downloadvaadin-framework-bc2b50c5bc7a76329cb1bbedf61d0056953f000d.tar.gz
vaadin-framework-bc2b50c5bc7a76329cb1bbedf61d0056953f000d.zip
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
Diffstat (limited to 'src/com/itmill/toolkit/ui/PopupView.java')
-rw-r--r--src/com/itmill/toolkit/ui/PopupView.java55
1 files changed, 23 insertions, 32 deletions
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<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();