summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2009-03-20 08:28:16 +0000
committerArtur Signell <artur.signell@itmill.com>2009-03-20 08:28:16 +0000
commit9b549761439c275fb5949833d97da289315e36c3 (patch)
treee0e48c7f9f77f6a1be3a256287f051017292d982 /src/com
parenta075258a59523079e7d114d8514b442297d11172 (diff)
downloadvaadin-framework-9b549761439c275fb5949833d97da289315e36c3.tar.gz
vaadin-framework-9b549761439c275fb5949833d97da289315e36c3.zip
Merged "Test case and fix for #2702 - Window.center() fails the first time in certain cases"
svn changeset:7120/svn branch:6.0
Diffstat (limited to 'src/com')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java31
-rw-r--r--src/com/itmill/toolkit/tests/components/window/CenteredWindowWithUndefinedSize.java33
2 files changed, 49 insertions, 15 deletions
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);
+
+ }
+}