aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/ui/AbstractComponent.java
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2008-02-01 11:34:50 +0000
committerMarc Englund <marc.englund@itmill.com>2008-02-01 11:34:50 +0000
commit8a30d9ec793b343e48ff4ec05391be0fca1cd9d0 (patch)
tree6a5369d2ff95d623b78cdb7ed561a37b32fd189a /src/com/itmill/toolkit/ui/AbstractComponent.java
parent4585aecfabe3ba603c8354611ebd84d90d695b53 (diff)
downloadvaadin-framework-8a30d9ec793b343e48ff4ec05391be0fca1cd9d0.tar.gz
vaadin-framework-8a30d9ec793b343e48ff4ec05391be0fca1cd9d0.zip
AbstractComponent.setParent(parent) cannot be called if component already has parent, unless the new parent is null (unsetting parent).
AbstractComponentContainer.addComponent(component) removes the component from it's previous ComponentContainer if needed (moves component), or throws if the component can't be removed. Fixes #1137 All components that contain other components should implement ComponentContainer for this to be perfect (e.g CustomComponent, Table) svn changeset:3698/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/ui/AbstractComponent.java')
-rw-r--r--src/com/itmill/toolkit/ui/AbstractComponent.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/com/itmill/toolkit/ui/AbstractComponent.java b/src/com/itmill/toolkit/ui/AbstractComponent.java
index 73afcb6aa8..3508266d91 100644
--- a/src/com/itmill/toolkit/ui/AbstractComponent.java
+++ b/src/com/itmill/toolkit/ui/AbstractComponent.java
@@ -450,15 +450,18 @@ public abstract class AbstractComponent implements Component, MethodEventSource
*/
public void setParent(Component parent) {
- // If the parent is not changed, dont do nothing
+ // If the parent is not changed, don't do anything
if (parent == this.parent) {
return;
}
+ if (parent != null && this.parent != null) {
+ throw new IllegalStateException("Component already has a parent.");
+ }
+
// Send detach event if the component have been connected to a window
if (getApplication() != null) {
detach();
- this.parent = null;
}
// Connect to new parent