summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2010-03-17 16:04:13 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2010-03-17 16:04:13 +0000
commit7f8a52344107eb6c0631f21039b9ee9b21bab6ea (patch)
tree66a790fb5f21f8f0f4a5226c6d356adcb16af849
parent0a049a0d913a548cd327542320bc8c22f5184f91 (diff)
downloadvaadin-framework-7f8a52344107eb6c0631f21039b9ee9b21bab6ea.tar.gz
vaadin-framework-7f8a52344107eb6c0631f21039b9ee9b21bab6ea.zip
fixes #4362 + test case
svn changeset:11939/svn branch:6.3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VWindow.java19
-rw-r--r--tests/src/com/vaadin/tests/components/window/PositionedSubWindows.java41
2 files changed, 52 insertions, 8 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
index 78a9b9eda5..6005556fff 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
@@ -278,15 +278,16 @@ public class VWindow extends VOverlay implements Container, ScrollListener {
setClosable(!uidl.getBooleanAttribute("readonly"));
// Initialize the position form UIDL
- try {
- final int positionx = uidl.getIntVariable("positionx");
- final int positiony = uidl.getIntVariable("positiony");
- if (positionx >= 0 && positiony >= 0) {
- setPopupPosition(positionx, positiony);
+ int positionx = uidl.getIntVariable("positionx");
+ int positiony = uidl.getIntVariable("positiony");
+ if (positionx >= 0 || positiony >= 0) {
+ if (positionx < 0) {
+ positionx = 0;
}
- } catch (final IllegalArgumentException e) {
- // Silently ignored as positionx and positiony are not required
- // parameters
+ if (positiony < 0) {
+ positiony = 0;
+ }
+ setPopupPosition(positionx, positiony);
}
if (uidl.hasAttribute("caption")) {
@@ -733,6 +734,8 @@ public class VWindow extends VOverlay implements Container, ScrollListener {
@Override
public void setPopupPosition(int left, int top) {
if (top < 0) {
+ // ensure window is not moved out of browser window from top of the
+ // screen
top = 0;
}
super.setPopupPosition(left, top);
diff --git a/tests/src/com/vaadin/tests/components/window/PositionedSubWindows.java b/tests/src/com/vaadin/tests/components/window/PositionedSubWindows.java
new file mode 100644
index 0000000000..9fe44dd7e8
--- /dev/null
+++ b/tests/src/com/vaadin/tests/components/window/PositionedSubWindows.java
@@ -0,0 +1,41 @@
+package com.vaadin.tests.components.window;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Window;
+
+public class PositionedSubWindows extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "Subwindows should obey setPositionX/Y methods also if only one is called";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4362;
+ }
+
+ @Override
+ protected void setup() {
+ Window smallWindow = getSmallWindow("Top:200");
+
+ smallWindow.setPositionY(200);
+ getMainWindow().addWindow(smallWindow);
+ smallWindow = getSmallWindow("Left:200");
+ smallWindow.setPositionX(200);
+ getMainWindow().addWindow(smallWindow);
+
+ smallWindow = getSmallWindow("50/50");
+ smallWindow.setPositionX(50);
+ smallWindow.setPositionY(50);
+ getMainWindow().addWindow(smallWindow);
+
+ }
+
+ private Window getSmallWindow(String caption) {
+ Window window2 = new Window(caption);
+ window2.setWidth("100px");
+ window2.setHeight("50px");
+ return window2;
+ }
+}