]> source.dussan.org Git - vaadin-framework.git/commitdiff
#2904 renamed VToolkitOverlay -> VOverlay
authorHenri Sara <henri.sara@itmill.com>
Mon, 18 May 2009 11:35:51 +0000 (11:35 +0000)
committerHenri Sara <henri.sara@itmill.com>
Mon, 18 May 2009 11:35:51 +0000 (11:35 +0000)
svn changeset:7855/svn branch:6.0

15 files changed:
src/com/vaadin/terminal/gwt/client/VDebugConsole.java
src/com/vaadin/terminal/gwt/client/VErrorMessage.java
src/com/vaadin/terminal/gwt/client/VTooltip.java
src/com/vaadin/terminal/gwt/client/ui/MenuBar.java
src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java
src/com/vaadin/terminal/gwt/client/ui/VContextMenu.java
src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
src/com/vaadin/terminal/gwt/client/ui/VNotification.java
src/com/vaadin/terminal/gwt/client/ui/VOverlay.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java
src/com/vaadin/terminal/gwt/client/ui/VPopupView.java
src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
src/com/vaadin/terminal/gwt/client/ui/VToolkitOverlay.java [deleted file]
src/com/vaadin/terminal/gwt/client/ui/VWindow.java

index 38ba0329959590e0bcc4cf77c7ad1017ec4089f0..fe77602daf7ce5494af5998660f0fd5b8e49cf75 100755 (executable)
@@ -28,9 +28,9 @@ import com.google.gwt.user.client.ui.Tree;
 import com.google.gwt.user.client.ui.TreeItem;
 import com.google.gwt.user.client.ui.VerticalPanel;
 import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.terminal.gwt.client.ui.VToolkitOverlay;
+import com.vaadin.terminal.gwt.client.ui.VOverlay;
 
-public final class VDebugConsole extends VToolkitOverlay implements Console {
+public final class VDebugConsole extends VOverlay implements Console {
 
     /**
      * Builds number. For example 0-custom_tag in 5.0.0-custom_tag.
index f32bd80b095241abe2fbed0a008c7bf98c194547..ba25dd23dba933ea3bcd0471af3722a5001a970b 100644 (file)
@@ -10,7 +10,7 @@ import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.HTML;
-import com.vaadin.terminal.gwt.client.ui.VToolkitOverlay;
+import com.vaadin.terminal.gwt.client.ui.VOverlay;
 
 public class VErrorMessage extends FlowPanel {
     public static final String CLASSNAME = "v-errormessage";
@@ -48,9 +48,9 @@ public class VErrorMessage extends FlowPanel {
      * @param indicatorElement
      */
     public void showAt(Element indicatorElement) {
-        VToolkitOverlay errorContainer = (VToolkitOverlay) getParent();
+        VOverlay errorContainer = (VOverlay) getParent();
         if (errorContainer == null) {
-            errorContainer = new VToolkitOverlay();
+            errorContainer = new VOverlay();
             errorContainer.setWidget(this);
         }
         errorContainer.setPopupPosition(DOM.getAbsoluteLeft(indicatorElement)
@@ -65,7 +65,7 @@ public class VErrorMessage extends FlowPanel {
     }
 
     public void hide() {
-        final VToolkitOverlay errorContainer = (VToolkitOverlay) getParent();
+        final VOverlay errorContainer = (VOverlay) getParent();
         if (errorContainer != null) {
             errorContainer.hide();
         }
index ff64896d2787e2852720766424e6d79125c2a8af..77059bd21ea6660e1e062eeb099ae31b45646131 100644 (file)
@@ -9,12 +9,12 @@ import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.Timer;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.ui.FlowPanel;
-import com.vaadin.terminal.gwt.client.ui.VToolkitOverlay;
+import com.vaadin.terminal.gwt.client.ui.VOverlay;
 
 /**
  * TODO open for extension
  */
-public class VTooltip extends VToolkitOverlay {
+public class VTooltip extends VOverlay {
     private static final String CLASSNAME = "v-tooltip";
     private static final int MARGIN = 4;
     public static final int TOOLTIP_EVENTS = Event.ONKEYDOWN
index 88de95cb3853719b50779606fd3545f3bf0bdce8..f950014ad7212f4e4a15f7c2a134780bedf13911 100644 (file)
@@ -376,7 +376,7 @@ public class MenuBar extends Widget implements PopupListener {
         // Create a new popup for this item, and position it next to
         // the item (below if this is a horizontal menu bar, to the
         // right if it's a vertical bar).
-        popup = new VToolkitOverlay(true) {
+        popup = new VOverlay(true) {
             {
                 setWidget(item.getSubMenu());
                 item.getSubMenu().onShow();
index 85c4124dd4a1beb823e2a4f83742d83d3c961ee6..8d688c2ed907610a5cd6da0a785ffc558d54d579 100644 (file)
@@ -487,7 +487,7 @@ public class VCalendarPanel extends FlexTable implements MouseListener {
 \r
                 if (datefield instanceof VTextualDate\r
                         && resolution < VDateField.RESOLUTION_HOUR) {\r
-                    ((VToolkitOverlay) getParent()).hide();\r
+                    ((VOverlay) getParent()).hide();\r
                 } else {\r
                     updateCalendar();\r
                 }\r
index 30c717418a7bd689b8f39d26a34de99cfb254302..b83006bf2307d5efae6907b8e161620fd16548a5 100644 (file)
@@ -13,7 +13,7 @@ import com.google.gwt.user.client.ui.MenuBar;
 import com.google.gwt.user.client.ui.MenuItem;
 import com.google.gwt.user.client.ui.PopupPanel;
 
-public class VContextMenu extends VToolkitOverlay implements SubPartAware {
+public class VContextMenu extends VOverlay implements SubPartAware {
 
     private ActionOwner actionOwner;
 
index d333f6537a3b8f36aafe89b68f4e349ca062fe21..7c9e4dadd11f229221de4967bf2831bb4037b577 100644 (file)
@@ -87,7 +87,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
         }
     }
 
-    public class SuggestionPopup extends VToolkitOverlay implements
+    public class SuggestionPopup extends VOverlay implements
             PositionCallback, PopupListener {
 
         private static final String Z_INDEX = "30000";
index ce3f34313c5094fa7cbacb68ce9237e7f158d61a..ef70cae60693f610925a52d173809a6fad5d5d42 100644 (file)
@@ -41,7 +41,7 @@ public class VMenuBar extends Widget implements Paintable, PopupListener {
     protected boolean subMenu;
     protected ArrayList<CustomMenuItem> items;
     protected Element containerElement;
-    protected VToolkitOverlay popup;
+    protected VOverlay popup;
     protected VMenuBar visibleChildMenu;
     protected VMenuBar parentMenu;
     protected CustomMenuItem selected;
@@ -435,7 +435,7 @@ public class VMenuBar extends Widget implements Paintable, PopupListener {
      * @param item
      */
     public void showChildMenu(CustomMenuItem item) {
-        popup = new VToolkitOverlay(true, false, true);
+        popup = new VOverlay(true, false, true);
         popup.setWidget(item.getSubMenu());
         popup.addPopupListener(this);
 
index 23e48437a35a22ec550a19bed0acae5bbdd0f1f0..a7accae95db049779b5f9f61cf235a343aa89f89 100644 (file)
@@ -17,7 +17,7 @@ import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.Widget;\r
 import com.vaadin.terminal.gwt.client.BrowserInfo;\r
 \r
-public class VNotification extends VToolkitOverlay {\r
+public class VNotification extends VOverlay {\r
 \r
     public static final int CENTERED = 1;\r
     public static final int CENTERED_TOP = 2;\r
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java b/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java
new file mode 100644 (file)
index 0000000..858132b
--- /dev/null
@@ -0,0 +1,313 @@
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.ui;
+
+import com.google.gwt.animation.client.Animation;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.ui.PopupListener;
+import com.google.gwt.user.client.ui.PopupPanel;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.vaadin.terminal.gwt.client.BrowserInfo;
+
+/**
+ * In Vaadin UI this Overlay should always be used for all elements that
+ * temporary float over other components like context menus etc. This is to deal
+ * stacking order correctly with VWindow objects.
+ */
+public class VOverlay extends PopupPanel {
+
+    /*
+     * The z-index value from where all overlays live. This can be overridden in
+     * any extending class.
+     */
+    protected static int Z_INDEX = 20000;
+
+    /*
+     * Shadow element style. If an extending class wishes to use a different
+     * style of shadow, it can use setShadowStyle(String) to give the shadow
+     * element a new style name.
+     */
+    public static final String CLASSNAME_SHADOW = "v-shadow";
+
+    /*
+     * The shadow element for this overlay.
+     */
+    private Element shadow;
+
+    /**
+     * The HTML snippet that is used to render the actual shadow. In consists of
+     * nine different DIV-elements with the following class names:
+     * 
+     * <pre>
+     *   .v-shadow[-stylename]
+     *   ----------------------------------------------
+     *   | .top-left     |   .top    |     .top-right |
+     *   |---------------|-----------|----------------|
+     *   |               |           |                |
+     *   | .left         |  .center  |         .right |
+     *   |               |           |                |
+     *   |---------------|-----------|----------------|
+     *   | .bottom-left  |  .bottom  |  .bottom-right |
+     *   ----------------------------------------------
+     * </pre>
+     * 
+     * See default theme 'shadow.css' for implementation example.
+     */
+    private static final String SHADOW_HTML = "<div class=\"top-left\"></div><div class=\"top\"></div><div class=\"top-right\"></div><div class=\"left\"></div><div class=\"center\"></div><div class=\"right\"></div><div class=\"bottom-left\"></div><div class=\"bottom\"></div><div class=\"bottom-right\"></div>";
+
+    public VOverlay() {
+        super();
+        adjustZIndex();
+    }
+
+    public VOverlay(boolean autoHide) {
+        super(autoHide);
+        adjustZIndex();
+    }
+
+    public VOverlay(boolean autoHide, boolean modal) {
+        super(autoHide, modal);
+        adjustZIndex();
+    }
+
+    public VOverlay(boolean autoHide, boolean modal, boolean showShadow) {
+        super(autoHide, modal);
+        if (showShadow) {
+            shadow = DOM.createDiv();
+            shadow.setClassName(CLASSNAME_SHADOW);
+            shadow.setInnerHTML(SHADOW_HTML);
+            DOM.setStyleAttribute(shadow, "position", "absolute");
+
+            addPopupListener(new PopupListener() {
+                public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
+                    if (shadow.getParentElement() != null) {
+                        shadow.getParentElement().removeChild(shadow);
+                    }
+                }
+            });
+        }
+        adjustZIndex();
+    }
+
+    private void adjustZIndex() {
+        setZIndex(Z_INDEX);
+    }
+
+    /**
+     * Set the z-index (visual stack position) for this overlay.
+     * 
+     * @param zIndex
+     *            The new z-index
+     */
+    protected void setZIndex(int zIndex) {
+        DOM.setStyleAttribute(getElement(), "zIndex", "" + zIndex);
+        if (shadow != null) {
+            DOM.setStyleAttribute(shadow, "zIndex", "" + zIndex);
+        }
+        if (BrowserInfo.get().isIE6()) {
+            adjustIE6Frame(getElement(), zIndex - 1);
+        }
+    }
+
+    /**
+     * Get the z-index (visual stack position) of this overlay.
+     * 
+     * @return The z-index for this overlay.
+     */
+    private int getZIndex() {
+        return Integer.parseInt(DOM.getStyleAttribute(getElement(), "zIndex"));
+    }
+
+    @Override
+    public void setPopupPosition(int left, int top) {
+        super.setPopupPosition(left, top);
+        if (shadow != null) {
+            updateShadowSizeAndPosition(isAnimationEnabled() ? 0 : 1);
+        }
+    }
+
+    @Override
+    public void show() {
+        super.show();
+        if (shadow != null) {
+            if (isAnimationEnabled()) {
+                ShadowAnimation sa = new ShadowAnimation();
+                sa.run(200);
+            } else {
+                updateShadowSizeAndPosition(1.0);
+            }
+        }
+        if (BrowserInfo.get().isIE6()) {
+            adjustIE6Frame(getElement(), getZIndex());
+        }
+    }
+
+    @Override
+    public void setVisible(boolean visible) {
+        super.setVisible(visible);
+        if (shadow != null) {
+            shadow.getStyle().setProperty("visibility",
+                    visible ? "visible" : "hidden");
+        }
+    }
+
+    /*
+     * Needed to position overlays on top of native SELECT elements in IE6. See
+     * bug #2004
+     */
+    private native void adjustIE6Frame(Element popup, int zindex)
+    /*-{
+        // relies on PopupImplIE6
+        if(popup.__frame) 
+            popup.__frame.style.zIndex = zindex;
+    }-*/;
+
+    @Override
+    public void setWidth(String width) {
+        super.setWidth(width);
+        if (shadow != null) {
+            updateShadowSizeAndPosition(1.0);
+        }
+    }
+
+    @Override
+    public void setHeight(String height) {
+        super.setHeight(height);
+        if (shadow != null) {
+            updateShadowSizeAndPosition(1.0);
+        }
+    }
+
+    /**
+     * Sets the shadow style for this overlay. Will override any previous style
+     * for the shadow. The default style name is defined by CLASSNAME_SHADOW.
+     * The given style will be prefixed with CLASSNAME_SHADOW.
+     * 
+     * @param style
+     *            The new style name for the shadow element. Will be prefixed by
+     *            CLASSNAME_SHADOW, e.g. style=='foobar' -> actual style
+     *            name=='v-shadow-foobar'.
+     */
+    protected void setShadowStyle(String style) {
+        if (shadow != null) {
+            shadow.setClassName(CLASSNAME_SHADOW + "-" + style);
+        }
+    }
+
+    /*
+     * Extending classes should always call this method after they change the
+     * size of overlay without using normal 'setWidth(String)' and
+     * 'setHeight(String)' methods (if not calling super.setWidth/Height).
+     */
+    protected void updateShadowSizeAndPosition() {
+        updateShadowSizeAndPosition(1.0);
+    }
+
+    /**
+     * Recalculates proper position and dimensions for the shadow element. Can
+     * be used to animate the shadow, using the 'progress' parameter (used to
+     * animate the shadow in sync with GWT PopupPanel's default animation
+     * 'PopupPanel.AnimationType.CENTER').
+     * 
+     * @param progress
+     *            A value between 0.0 and 1.0, indicating the progress of the
+     *            animation (0=start, 1=end).
+     */
+    private void updateShadowSizeAndPosition(final double progress) {
+        // Don't do anything if overlay element is not attached
+        if (!isAttached()) {
+            return;
+        }
+        // Calculate proper z-index
+        String zIndex = null;
+        try {
+            // Odd behaviour with Windows Hosted Mode forces us to use
+            // this redundant try/catch block (See dev.vaadin.com #2011)
+            zIndex = DOM.getStyleAttribute(getElement(), "zIndex");
+        } catch (Exception ignore) {
+            // Ignored, will cause no harm
+        }
+        if (zIndex == null) {
+            zIndex = "" + Z_INDEX;
+        }
+        // Calculate position and size
+        if (BrowserInfo.get().isIE()) {
+            // Shake IE
+            getOffsetHeight();
+            getOffsetWidth();
+        }
+
+        int x = getAbsoluteLeft();
+        int y = getAbsoluteTop();
+
+        /* This is needed for IE7 at least */
+        // Account for the difference between absolute position and the
+        // body's positioning context.
+        x -= Document.get().getBodyOffsetLeft();
+        y -= Document.get().getBodyOffsetTop();
+
+        int width = getOffsetWidth();
+        int height = getOffsetHeight();
+
+        if (width < 0) {
+            width = 0;
+        }
+        if (height < 0) {
+            height = 0;
+        }
+
+        // Animate the shadow size
+        x += (int) (width * (1.0 - progress) / 2.0);
+        y += (int) (height * (1.0 - progress) / 2.0);
+        width = (int) (width * progress);
+        height = (int) (height * progress);
+
+        // Opera needs some shaking to get parts of the shadow showing
+        // properly
+        // (ticket #2704)
+        if (BrowserInfo.get().isOpera()) {
+            // Clear the height of all middle elements
+            DOM.getChild(shadow, 3).getStyle().setProperty("height", "auto");
+            DOM.getChild(shadow, 4).getStyle().setProperty("height", "auto");
+            DOM.getChild(shadow, 5).getStyle().setProperty("height", "auto");
+        }
+
+        // Update correct values
+        DOM.setStyleAttribute(shadow, "zIndex", zIndex);
+        DOM.setStyleAttribute(shadow, "width", width + "px");
+        DOM.setStyleAttribute(shadow, "height", height + "px");
+        DOM.setStyleAttribute(shadow, "top", y + "px");
+        DOM.setStyleAttribute(shadow, "left", x + "px");
+        DOM.setStyleAttribute(shadow, "display", progress < 0.9 ? "none" : "");
+
+        // Opera fix, part 2 (ticket #2704)
+        if (BrowserInfo.get().isOpera()) {
+            // We'll fix the height of all the middle elements
+            DOM.getChild(shadow, 3).getStyle().setPropertyPx("height",
+                    DOM.getChild(shadow, 3).getOffsetHeight());
+            DOM.getChild(shadow, 4).getStyle().setPropertyPx("height",
+                    DOM.getChild(shadow, 4).getOffsetHeight());
+            DOM.getChild(shadow, 5).getStyle().setPropertyPx("height",
+                    DOM.getChild(shadow, 5).getOffsetHeight());
+        }
+
+        // Attach to dom if not there already
+        if (shadow.getParentElement() == null) {
+            RootPanel.get().getElement().insertBefore(shadow, getElement());
+        }
+
+    }
+
+    protected class ShadowAnimation extends Animation {
+        @Override
+        protected void onUpdate(double progress) {
+            if (shadow != null) {
+                updateShadowSizeAndPosition(progress);
+            }
+        }
+    }
+}
index 983b1fb71e7bbc313f92da2dce101bce766e9dfa..c0c032d276b0a900b730e0aad273ef7c14e6b175 100644 (file)
@@ -24,7 +24,7 @@ public class VPopupCalendar extends VTextualDate implements Paintable, Field,
 \r
     private final VCalendarPanel calendar;\r
 \r
-    private final VToolkitOverlay popup;\r
+    private final VOverlay popup;\r
     private boolean open = false;\r
 \r
     public VPopupCalendar() {\r
@@ -37,7 +37,7 @@ public class VPopupCalendar extends VTextualDate implements Paintable, Field,
         add(calendarToggle);\r
 \r
         calendar = new VCalendarPanel(this);\r
-        popup = new VToolkitOverlay(true, true, true);\r
+        popup = new VOverlay(true, true, true);\r
         popup.setStyleName(VDateField.CLASSNAME + "-popup");\r
         popup.setWidget(calendar);\r
         popup.addPopupListener(this);\r
index ce1fa343f393502e66d0dfd8835a51f758282460..c6041d71d103c7e352966d3a97e9efd6087bfdbd 100644 (file)
@@ -192,7 +192,7 @@ public class VPopupView extends HTML implements Container {
         }
     }-*/;
 
-    private class CustomPopup extends VToolkitOverlay {
+    private class CustomPopup extends VOverlay {
 
         private Paintable popupComponentPaintable = null;
         private Widget popupComponentWidget = null;
index a1f14af24273c063d68d03df47d375f7b6188303..59015a9606e37a040c6288c7d825862d64b1509d 100644 (file)
@@ -435,7 +435,7 @@ public class VSplitPanel extends ComplexPanel implements Container,
             DOM.setStyleAttribute(draggingCurtain, "width", "100%");
             DOM.setStyleAttribute(draggingCurtain, "height", "100%");
             DOM.setStyleAttribute(draggingCurtain, "zIndex", ""
-                    + VToolkitOverlay.Z_INDEX);
+                    + VOverlay.Z_INDEX);
             DOM.appendChild(RootPanel.getBodyElement(), draggingCurtain);
         }
     }
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VToolkitOverlay.java b/src/com/vaadin/terminal/gwt/client/ui/VToolkitOverlay.java
deleted file mode 100644 (file)
index 84b3c78..0000000
+++ /dev/null
@@ -1,313 +0,0 @@
-/* 
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.terminal.gwt.client.ui;
-
-import com.google.gwt.animation.client.Animation;
-import com.google.gwt.dom.client.Document;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.ui.PopupListener;
-import com.google.gwt.user.client.ui.PopupPanel;
-import com.google.gwt.user.client.ui.RootPanel;
-import com.vaadin.terminal.gwt.client.BrowserInfo;
-
-/**
- * In Vaadin UI this Overlay should always be used for all elements that
- * temporary float over other components like context menus etc. This is to deal
- * stacking order correctly with VWindow objects.
- */
-public class VToolkitOverlay extends PopupPanel {
-
-    /*
-     * The z-index value from where all overlays live. This can be overridden in
-     * any extending class.
-     */
-    protected static int Z_INDEX = 20000;
-
-    /*
-     * Shadow element style. If an extending class wishes to use a different
-     * style of shadow, it can use setShadowStyle(String) to give the shadow
-     * element a new style name.
-     */
-    public static final String CLASSNAME_SHADOW = "v-shadow";
-
-    /*
-     * The shadow element for this overlay.
-     */
-    private Element shadow;
-
-    /**
-     * The HTML snippet that is used to render the actual shadow. In consists of
-     * nine different DIV-elements with the following class names:
-     * 
-     * <pre>
-     *   .v-shadow[-stylename]
-     *   ----------------------------------------------
-     *   | .top-left     |   .top    |     .top-right |
-     *   |---------------|-----------|----------------|
-     *   |               |           |                |
-     *   | .left         |  .center  |         .right |
-     *   |               |           |                |
-     *   |---------------|-----------|----------------|
-     *   | .bottom-left  |  .bottom  |  .bottom-right |
-     *   ----------------------------------------------
-     * </pre>
-     * 
-     * See default theme 'shadow.css' for implementation example.
-     */
-    private static final String SHADOW_HTML = "<div class=\"top-left\"></div><div class=\"top\"></div><div class=\"top-right\"></div><div class=\"left\"></div><div class=\"center\"></div><div class=\"right\"></div><div class=\"bottom-left\"></div><div class=\"bottom\"></div><div class=\"bottom-right\"></div>";
-
-    public VToolkitOverlay() {
-        super();
-        adjustZIndex();
-    }
-
-    public VToolkitOverlay(boolean autoHide) {
-        super(autoHide);
-        adjustZIndex();
-    }
-
-    public VToolkitOverlay(boolean autoHide, boolean modal) {
-        super(autoHide, modal);
-        adjustZIndex();
-    }
-
-    public VToolkitOverlay(boolean autoHide, boolean modal, boolean showShadow) {
-        super(autoHide, modal);
-        if (showShadow) {
-            shadow = DOM.createDiv();
-            shadow.setClassName(CLASSNAME_SHADOW);
-            shadow.setInnerHTML(SHADOW_HTML);
-            DOM.setStyleAttribute(shadow, "position", "absolute");
-
-            addPopupListener(new PopupListener() {
-                public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
-                    if (shadow.getParentElement() != null) {
-                        shadow.getParentElement().removeChild(shadow);
-                    }
-                }
-            });
-        }
-        adjustZIndex();
-    }
-
-    private void adjustZIndex() {
-        setZIndex(Z_INDEX);
-    }
-
-    /**
-     * Set the z-index (visual stack position) for this overlay.
-     * 
-     * @param zIndex
-     *            The new z-index
-     */
-    protected void setZIndex(int zIndex) {
-        DOM.setStyleAttribute(getElement(), "zIndex", "" + zIndex);
-        if (shadow != null) {
-            DOM.setStyleAttribute(shadow, "zIndex", "" + zIndex);
-        }
-        if (BrowserInfo.get().isIE6()) {
-            adjustIE6Frame(getElement(), zIndex - 1);
-        }
-    }
-
-    /**
-     * Get the z-index (visual stack position) of this overlay.
-     * 
-     * @return The z-index for this overlay.
-     */
-    private int getZIndex() {
-        return Integer.parseInt(DOM.getStyleAttribute(getElement(), "zIndex"));
-    }
-
-    @Override
-    public void setPopupPosition(int left, int top) {
-        super.setPopupPosition(left, top);
-        if (shadow != null) {
-            updateShadowSizeAndPosition(isAnimationEnabled() ? 0 : 1);
-        }
-    }
-
-    @Override
-    public void show() {
-        super.show();
-        if (shadow != null) {
-            if (isAnimationEnabled()) {
-                ShadowAnimation sa = new ShadowAnimation();
-                sa.run(200);
-            } else {
-                updateShadowSizeAndPosition(1.0);
-            }
-        }
-        if (BrowserInfo.get().isIE6()) {
-            adjustIE6Frame(getElement(), getZIndex());
-        }
-    }
-
-    @Override
-    public void setVisible(boolean visible) {
-        super.setVisible(visible);
-        if (shadow != null) {
-            shadow.getStyle().setProperty("visibility",
-                    visible ? "visible" : "hidden");
-        }
-    }
-
-    /*
-     * Needed to position overlays on top of native SELECT elements in IE6. See
-     * bug #2004
-     */
-    private native void adjustIE6Frame(Element popup, int zindex)
-    /*-{
-        // relies on PopupImplIE6
-        if(popup.__frame) 
-            popup.__frame.style.zIndex = zindex;
-    }-*/;
-
-    @Override
-    public void setWidth(String width) {
-        super.setWidth(width);
-        if (shadow != null) {
-            updateShadowSizeAndPosition(1.0);
-        }
-    }
-
-    @Override
-    public void setHeight(String height) {
-        super.setHeight(height);
-        if (shadow != null) {
-            updateShadowSizeAndPosition(1.0);
-        }
-    }
-
-    /**
-     * Sets the shadow style for this overlay. Will override any previous style
-     * for the shadow. The default style name is defined by CLASSNAME_SHADOW.
-     * The given style will be prefixed with CLASSNAME_SHADOW.
-     * 
-     * @param style
-     *            The new style name for the shadow element. Will be prefixed by
-     *            CLASSNAME_SHADOW, e.g. style=='foobar' -> actual style
-     *            name=='v-shadow-foobar'.
-     */
-    protected void setShadowStyle(String style) {
-        if (shadow != null) {
-            shadow.setClassName(CLASSNAME_SHADOW + "-" + style);
-        }
-    }
-
-    /*
-     * Extending classes should always call this method after they change the
-     * size of overlay without using normal 'setWidth(String)' and
-     * 'setHeight(String)' methods (if not calling super.setWidth/Height).
-     */
-    protected void updateShadowSizeAndPosition() {
-        updateShadowSizeAndPosition(1.0);
-    }
-
-    /**
-     * Recalculates proper position and dimensions for the shadow element. Can
-     * be used to animate the shadow, using the 'progress' parameter (used to
-     * animate the shadow in sync with GWT PopupPanel's default animation
-     * 'PopupPanel.AnimationType.CENTER').
-     * 
-     * @param progress
-     *            A value between 0.0 and 1.0, indicating the progress of the
-     *            animation (0=start, 1=end).
-     */
-    private void updateShadowSizeAndPosition(final double progress) {
-        // Don't do anything if overlay element is not attached
-        if (!isAttached()) {
-            return;
-        }
-        // Calculate proper z-index
-        String zIndex = null;
-        try {
-            // Odd behaviour with Windows Hosted Mode forces us to use
-            // this redundant try/catch block (See dev.vaadin.com #2011)
-            zIndex = DOM.getStyleAttribute(getElement(), "zIndex");
-        } catch (Exception ignore) {
-            // Ignored, will cause no harm
-        }
-        if (zIndex == null) {
-            zIndex = "" + Z_INDEX;
-        }
-        // Calculate position and size
-        if (BrowserInfo.get().isIE()) {
-            // Shake IE
-            getOffsetHeight();
-            getOffsetWidth();
-        }
-
-        int x = getAbsoluteLeft();
-        int y = getAbsoluteTop();
-
-        /* This is needed for IE7 at least */
-        // Account for the difference between absolute position and the
-        // body's positioning context.
-        x -= Document.get().getBodyOffsetLeft();
-        y -= Document.get().getBodyOffsetTop();
-
-        int width = getOffsetWidth();
-        int height = getOffsetHeight();
-
-        if (width < 0) {
-            width = 0;
-        }
-        if (height < 0) {
-            height = 0;
-        }
-
-        // Animate the shadow size
-        x += (int) (width * (1.0 - progress) / 2.0);
-        y += (int) (height * (1.0 - progress) / 2.0);
-        width = (int) (width * progress);
-        height = (int) (height * progress);
-
-        // Opera needs some shaking to get parts of the shadow showing
-        // properly
-        // (ticket #2704)
-        if (BrowserInfo.get().isOpera()) {
-            // Clear the height of all middle elements
-            DOM.getChild(shadow, 3).getStyle().setProperty("height", "auto");
-            DOM.getChild(shadow, 4).getStyle().setProperty("height", "auto");
-            DOM.getChild(shadow, 5).getStyle().setProperty("height", "auto");
-        }
-
-        // Update correct values
-        DOM.setStyleAttribute(shadow, "zIndex", zIndex);
-        DOM.setStyleAttribute(shadow, "width", width + "px");
-        DOM.setStyleAttribute(shadow, "height", height + "px");
-        DOM.setStyleAttribute(shadow, "top", y + "px");
-        DOM.setStyleAttribute(shadow, "left", x + "px");
-        DOM.setStyleAttribute(shadow, "display", progress < 0.9 ? "none" : "");
-
-        // Opera fix, part 2 (ticket #2704)
-        if (BrowserInfo.get().isOpera()) {
-            // We'll fix the height of all the middle elements
-            DOM.getChild(shadow, 3).getStyle().setPropertyPx("height",
-                    DOM.getChild(shadow, 3).getOffsetHeight());
-            DOM.getChild(shadow, 4).getStyle().setPropertyPx("height",
-                    DOM.getChild(shadow, 4).getOffsetHeight());
-            DOM.getChild(shadow, 5).getStyle().setPropertyPx("height",
-                    DOM.getChild(shadow, 5).getOffsetHeight());
-        }
-
-        // Attach to dom if not there already
-        if (shadow.getParentElement() == null) {
-            RootPanel.get().getElement().insertBefore(shadow, getElement());
-        }
-
-    }
-
-    protected class ShadowAnimation extends Animation {
-        @Override
-        protected void onUpdate(double progress) {
-            if (shadow != null) {
-                updateShadowSizeAndPosition(progress);
-            }
-        }
-    }
-}
index 87bd272af3d938a49ba54e8108f05cbdc10dc11d..57ce65f378002c39e6c388689fb796caa2d7c1fe 100644 (file)
@@ -35,7 +35,7 @@ import com.vaadin.terminal.gwt.client.Util;
  * 
  * @author IT Mill Ltd
  */
-public class VWindow extends VToolkitOverlay implements Container,
+public class VWindow extends VOverlay implements Container,
         ScrollListener {
 
     private static final int MIN_HEIGHT = 100;
@@ -595,7 +595,7 @@ public class VWindow extends VToolkitOverlay implements Container,
             DOM.setStyleAttribute(draggingCurtain, "width", "100%");
             DOM.setStyleAttribute(draggingCurtain, "height", "100%");
             DOM.setStyleAttribute(draggingCurtain, "zIndex", ""
-                    + VToolkitOverlay.Z_INDEX);
+                    + VOverlay.Z_INDEX);
 
             DOM.appendChild(RootPanel.getBodyElement(), draggingCurtain);
         } else if (!show && draggingCurtain != null) {