]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix for #5671 - ComponentLocator should try to find SubPartAware parent widgets for...
authorArtur Signell <artur.signell@itmill.com>
Thu, 23 Sep 2010 10:57:57 +0000 (10:57 +0000)
committerArtur Signell <artur.signell@itmill.com>
Thu, 23 Sep 2010 10:57:57 +0000 (10:57 +0000)
svn changeset:15150/svn branch:6.4

src/com/vaadin/terminal/gwt/client/ComponentLocator.java

index 6644a243d05a32b1566147a40ecb09a95f442a35..5abfafe4ff8008103ef6002112c4de9bbb0d5418 100644 (file)
@@ -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