diff options
author | Artur Signell <artur.signell@itmill.com> | 2010-09-23 10:57:57 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2010-09-23 10:57:57 +0000 |
commit | 27d2e12a28ede6a40e0e82487f315130df56bc06 (patch) | |
tree | d3d3ca497cb0f53e10baa7525387097610238df8 /src/com | |
parent | c5ae4882fe98a6d0fbdced9d7f35b5f1dcced6ef (diff) | |
download | vaadin-framework-27d2e12a28ede6a40e0e82487f315130df56bc06.tar.gz vaadin-framework-27d2e12a28ede6a40e0e82487f315130df56bc06.zip |
Fix for #5671 - ComponentLocator should try to find SubPartAware parent widgets for widgets in an VOverlay
svn changeset:15150/svn branch:6.4
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ComponentLocator.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ComponentLocator.java b/src/com/vaadin/terminal/gwt/client/ComponentLocator.java index 6644a243d0..5abfafe4ff 100644 --- a/src/com/vaadin/terminal/gwt/client/ComponentLocator.java +++ b/src/com/vaadin/terminal/gwt/client/ComponentLocator.java @@ -91,6 +91,9 @@ public class ComponentLocator { Widget w = null; if (pid != null) { + // If we found a Paintable then we use that as reference. We should + // find the Paintable for all but very special cases (like + // overlays). w = (Widget) client.getPaintable(pid); } if (w == null) { @@ -106,6 +109,15 @@ public class ComponentLocator { break; } } + if (w != null) { + // We found a widget but we should still see if we find a + // SubPartAware implementor (we cannot find the Paintable as + // there is no link from VOverlay to its paintable/owner). + Widget subPartAwareWidget = findSubPartAwareParentWidget(w); + if (subPartAwareWidget != null) { + w = subPartAwareWidget; + } + } } if (w == null) { @@ -148,6 +160,28 @@ public class ComponentLocator { } /** + * Finds the first widget in the hierarchy (moving upwards) that implements + * SubPartAware. Returns the SubPartAware implementor or null if none is + * found. + * + * @param w + * The widget to start from. This is returned if it implements + * SubPartAware. + * @return The first widget (upwards in hierarchy) that implements + * SubPartAware or null + */ + private Widget findSubPartAwareParentWidget(Widget w) { + + while (w != null) { + if (w instanceof SubPartAware) { + return w; + } + w = w.getParent(); + } + return null; + } + + /** * Returns the first widget found when going from {@code targetElement} * upwards in the DOM hierarchy, assuming that {@code ancestorWidget} is a * parent of {@code targetElement}. |