From: Artur Signell Date: Fri, 20 Mar 2009 08:28:16 +0000 (+0000) Subject: Merged "Test case and fix for #2702 - Window.center() fails the first time in certain... X-Git-Tag: 6.7.0.beta1~3061 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9b549761439c275fb5949833d97da289315e36c3;p=vaadin-framework.git Merged "Test case and fix for #2702 - Window.center() fails the first time in certain cases" svn changeset:7120/svn branch:6.0 --- diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java index 7de1f81349..915f4b521e 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java @@ -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 index 0000000000..3c0191ff39 --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/window/CenteredWindowWithUndefinedSize.java @@ -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); + + } +}