summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui/AbstractComponent.java
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2014-03-12 21:17:18 +0200
committerArtur Signell <artur@vaadin.com>2014-05-22 09:52:42 +0000
commit95e563a69b540bae2616466ae25646eba50d4afe (patch)
tree9a011e0417ee06f1ee7648da6975a19ec0401316 /server/src/com/vaadin/ui/AbstractComponent.java
parenta11909909c895032ca5f8b271dfb0fa29efa2a6f (diff)
downloadvaadin-framework-95e563a69b540bae2616466ae25646eba50d4afe.tar.gz
vaadin-framework-95e563a69b540bae2616466ae25646eba50d4afe.zip
Prevent adding/setting parent component as child (#12720).
Change-Id: I9b7b43f176e88d9edca591001297b94475a31854
Diffstat (limited to 'server/src/com/vaadin/ui/AbstractComponent.java')
-rw-r--r--server/src/com/vaadin/ui/AbstractComponent.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java
index d980c27916..b6289e0b7d 100644
--- a/server/src/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/com/vaadin/ui/AbstractComponent.java
@@ -991,4 +991,24 @@ public abstract class AbstractComponent extends AbstractClientConnector
actionManager.removeAction(shortcut);
}
}
+
+ /**
+ * Determine whether a <code>content</code> component is equal to, or the
+ * ancestor of this component.
+ *
+ * @param content
+ * the potential ancestor element
+ * @return <code>true</code> if the relationship holds
+ */
+ protected boolean isOrHasAncestor(Component content) {
+ if (content instanceof HasComponents) {
+ for (Component parent = this; parent != null; parent = parent
+ .getParent()) {
+ if (parent == content) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
}