From 27d2e12a28ede6a40e0e82487f315130df56bc06 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 23 Sep 2010 10:57:57 +0000 Subject: Fix for #5671 - ComponentLocator should try to find SubPartAware parent widgets for widgets in an VOverlay svn changeset:15150/svn branch:6.4 --- .../terminal/gwt/client/ComponentLocator.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/com') 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) { @@ -147,6 +159,28 @@ public class ComponentLocator { return path + getDOMPathForElement(targetElement, w.getElement()); } + /** + * 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 -- cgit v1.2.3