List of usage examples for com.google.gwt.user.client Element getPreviousSiblingElement
@Override
public Element getPreviousSiblingElement()
From source file:com.vaadin.client.ComponentLocator.java
License:Apache License
/** * Generates a String locator using domChild[x] parts for the element * relative to the baseElement./*from w w w . ja va 2 s . c om*/ * * @param element * The target element * @param baseElement * The starting point for the locator. The generated path is * relative to this element. * @return A String locator that can be used to locate the target element * using {@link #getElementByDOMPath(Element, String)} or null if * the locator String cannot be created. */ private String getDOMPathForElement(Element element, Element baseElement) { Element e = element; String path = ""; while (true) { int childIndex = -1; Element siblingIterator = e; while (siblingIterator != null) { childIndex++; siblingIterator = siblingIterator.getPreviousSiblingElement().cast(); } path = PARENTCHILD_SEPARATOR + "domChild[" + childIndex + "]" + path; JavaScriptObject parent = e.getParentElement(); if (parent == null) { return null; } // The parent check is a work around for Firefox 15 which fails to // compare elements properly (#9534) if (parent == baseElement) { break; } e = parent.cast(); } return path; }