aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java20
-rw-r--r--src/com/itmill/toolkit/ui/PopupView.java55
2 files changed, 32 insertions, 43 deletions
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<Element> activeChildren;
+ private final Set<Element> 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<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();