aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>2008-09-24 15:10:40 +0000
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>2008-09-24 15:10:40 +0000
commitb515618fedf9dff7ef534dec1d3b82fa6aa2206f (patch)
tree3d2369826c7416b9982810b5fde76a45b7713aa5 /src
parent38d99c4777b6451689c138833b7ca619c1b41b94 (diff)
downloadvaadin-framework-b515618fedf9dff7ef534dec1d3b82fa6aa2206f.tar.gz
vaadin-framework-b515618fedf9dff7ef534dec1d3b82fa6aa2206f.zip
Fixes #2100 : Prevent window from being added to multiple places
svn changeset:5507/svn branch:trunk
Diffstat (limited to 'src')
-rw-r--r--src/com/itmill/toolkit/Application.java7
-rw-r--r--src/com/itmill/toolkit/ui/Window.java14
2 files changed, 17 insertions, 4 deletions
diff --git a/src/com/itmill/toolkit/Application.java b/src/com/itmill/toolkit/Application.java
index c8f318979d..adbf587299 100644
--- a/src/com/itmill/toolkit/Application.java
+++ b/src/com/itmill/toolkit/Application.java
@@ -286,6 +286,13 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
return;
}
+ // Check that one is not adding a sub-window to application
+ if (window.getParent() != null) {
+ throw new IllegalArgumentException(
+ "Window was already added inside another window"
+ + " - it can not be added to application also.");
+ }
+
// Gets the naming proposal from window
String name = window.getName();
diff --git a/src/com/itmill/toolkit/ui/Window.java b/src/com/itmill/toolkit/ui/Window.java
index 8615480553..2d9ce6e9cf 100644
--- a/src/com/itmill/toolkit/ui/Window.java
+++ b/src/com/itmill/toolkit/ui/Window.java
@@ -1009,13 +1009,19 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
public void addWindow(Window window) throws IllegalArgumentException,
NullPointerException {
- if (getParent() != null) {
+ if (window == null) {
+ throw new NullPointerException("Argument must not be null");
+ }
+
+ if (application.getWindows().contains(window)) {
throw new IllegalArgumentException(
- "You can only add windows inside application-level windows");
+ "Window was already added to application"
+ + " - it can not be added to another window also.");
}
- if (window == null) {
- throw new NullPointerException("Argument must not be null");
+ if (getParent() != null) {
+ throw new IllegalArgumentException(
+ "You can only add windows inside application-level windows");
}
subwindows.add(window);