]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merged "Test case and fix for #2702 - Window.center() fails the first time in certain...
authorArtur Signell <artur.signell@itmill.com>
Fri, 20 Mar 2009 08:28:16 +0000 (08:28 +0000)
committerArtur Signell <artur.signell@itmill.com>
Fri, 20 Mar 2009 08:28:16 +0000 (08:28 +0000)
svn changeset:7120/svn branch:6.0

src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
src/com/itmill/toolkit/tests/components/window/CenteredWindowWithUndefinedSize.java [new file with mode: 0644]

index 7de1f81349391f82b3bd1dc493f0bfd4d2e9bc53..915f4b521e439b15ef248215fc715a93670514b7 100644 (file)
@@ -341,23 +341,8 @@ public class IWindow extends IToolkitOverlay implements Container,
         }
 
         if (dynamicHeight && layoutRelativeHeight) {
-            /*
-             * Window height is undefined, layout is 100% high so the layout
-             * should define the initial window height but on resize the layout
-             * should be as high as the window. We fix the height immediately to
-             * deal with this.
-             */
-
-            int h = contents.getOffsetHeight() + getExtraHeight();
-            int w = contents.getOffsetWidth();
-
             // Prevent resizing until height has been fixed
             resizable = false;
-
-            client.updateVariable(id, "height", h, false);
-            client.updateVariable(id, "width", w, true);
-            // ApplicationConnection.getConsole().log("Fixing window size to " +
-            // w + "x" + h);
         }
 
         // we may have actions and notifications
@@ -429,6 +414,22 @@ public class IWindow extends IToolkitOverlay implements Container,
         if (getOffsetHeight() > Window.getClientHeight()) {
             setHeight(Window.getClientHeight() + "px");
         }
+
+        if (dynamicHeight && layoutRelativeHeight) {
+            /*
+             * Window height is undefined, layout is 100% high so the layout
+             * should define the initial window height but on resize the layout
+             * should be as high as the window. We fix the height to deal with
+             * this.
+             */
+
+            int h = contents.getOffsetHeight() + getExtraHeight();
+            int w = contents.getOffsetWidth();
+
+            client.updateVariable(id, "height", h, false);
+            client.updateVariable(id, "width", w, true);
+        }
+
     }
 
     private void setNaturalWidth() {
diff --git a/src/com/itmill/toolkit/tests/components/window/CenteredWindowWithUndefinedSize.java b/src/com/itmill/toolkit/tests/components/window/CenteredWindowWithUndefinedSize.java
new file mode 100644 (file)
index 0000000..3c0191f
--- /dev/null
@@ -0,0 +1,33 @@
+package com.itmill.toolkit.tests.components.window;
+
+import com.itmill.toolkit.tests.components.TestBase;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.Window;
+
+public class CenteredWindowWithUndefinedSize extends TestBase {
+
+    @Override
+    protected String getDescription() {
+        return "The centered sub-window with undefined height and a 100% high layout should be rendered in the center of the screen and not in the top-left corner.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 2702;
+    }
+
+    @Override
+    protected void setup() {
+        Window centered = new Window("A window");
+        centered.setSizeUndefined();
+        centered.getLayout().setSizeFull();
+        centered.center();
+
+        Label l = new Label("This window should be centered");
+        l.setSizeUndefined();
+        centered.addComponent(l);
+
+        getMainWindow().addWindow(centered);
+
+    }
+}