summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/componentlocator/ComponentLocator.java5
-rw-r--r--client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java31
-rw-r--r--client/src/com/vaadin/client/debug/internal/SelectorPath.java4
3 files changed, 34 insertions, 6 deletions
diff --git a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java
index 8d257f09b4..52c7b57d1d 100644
--- a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java
+++ b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java
@@ -108,7 +108,10 @@ public class ComponentLocator {
* String locator could not be created.
*/
public String getPathForElement(Element targetElement) {
- return getPathForElement(DOM.asOld(targetElement));
+ if (targetElement != null) {
+ return getPathForElement(DOM.asOld(targetElement));
+ }
+ return null;
}
/**
diff --git a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java
index 6075d1bf48..9ed071c38f 100644
--- a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java
+++ b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java
@@ -20,6 +20,7 @@ import java.util.Arrays;
import java.util.List;
import com.google.gwt.dom.client.Element;
+import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConnection;
@@ -72,8 +73,24 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy {
*/
@Override
public String getPathForElement(Element targetElement) {
- if (targetElement == null) {
- return "";
+ Element oldTarget = targetElement;
+ Widget targetWidget = Util.findPaintable(client, targetElement)
+ .getWidget();
+ targetElement = targetWidget.getElement();
+
+ // Find SubPart name if needed.
+ String subPart = null;
+ boolean hasSubParts = targetWidget instanceof SubPartAware;
+ if (oldTarget != targetElement) {
+ if (hasSubParts) {
+ subPart = ((SubPartAware) targetWidget).getSubPartName(DOM
+ .asOld(oldTarget));
+ }
+
+ if (!hasSubParts || subPart == null) {
+ // Couldn't find SubPart name for element.
+ return null;
+ }
}
List<ConnectorPath> hierarchy = getConnectorHierarchyForElement(targetElement);
@@ -102,7 +119,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy {
return null;
}
- return getBestSelector(generateQueries(path), targetElement);
+ return getBestSelector(generateQueries(path), targetElement, subPart);
}
/**
@@ -114,9 +131,12 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy {
* List of selectors
* @param target
* Target element
+ * @param subPart
+ * sub part selector string for actual target
* @return Best selector string formatted with a post filter
*/
- private String getBestSelector(List<String> selectors, Element target) {
+ private String getBestSelector(List<String> selectors, Element target,
+ String subPart) {
// The last selector gives us smallest list index for target element.
String bestSelector = selectors.get(selectors.size() - 1);
int min = getElementsByPath(bestSelector).indexOf(target);
@@ -141,7 +161,8 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy {
}
}
- return "(" + bestSelector + ")[" + min + "]";
+ return "(" + bestSelector + (subPart != null ? "#" + subPart : "")
+ + ")[" + min + "]";
}
diff --git a/client/src/com/vaadin/client/debug/internal/SelectorPath.java b/client/src/com/vaadin/client/debug/internal/SelectorPath.java
index 5627bf0250..3f21e46a96 100644
--- a/client/src/com/vaadin/client/debug/internal/SelectorPath.java
+++ b/client/src/com/vaadin/client/debug/internal/SelectorPath.java
@@ -82,6 +82,10 @@ public class SelectorPath {
.extractPostFilterPredicates(path);
if (postFilters.size() > 0) {
tmpPath = tmpPath.substring(1, tmpPath.lastIndexOf(')'));
+ if (tmpPath.contains("#")) {
+ // FIXME: SubParts should be handled.
+ tmpPath = tmpPath.split("#")[0];
+ }
}
// Generate an ElementQuery