diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-03-25 16:59:36 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-03-26 06:22:41 +0000 |
commit | c364912a86c5ffd236d78d38c843fcf8e5959262 (patch) | |
tree | 74447abe3899c04ba366846a1021eee2453e7146 /client/src | |
parent | 32d319ebf8bee29252f280c0764dc7f2e83de75f (diff) | |
download | vaadin-framework-c364912a86c5ffd236d78d38c843fcf8e5959262.tar.gz vaadin-framework-c364912a86c5ffd236d78d38c843fcf8e5959262.zip |
Add id check for ElementQuery generation in Debug Window
Change-Id: Ic514dbfca241756b74798b3fb057a97ef9cdfa70
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/com/vaadin/client/debug/internal/SelectorPath.java | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/client/src/com/vaadin/client/debug/internal/SelectorPath.java b/client/src/com/vaadin/client/debug/internal/SelectorPath.java index 5e800f4295..56b48b2447 100644 --- a/client/src/com/vaadin/client/debug/internal/SelectorPath.java +++ b/client/src/com/vaadin/client/debug/internal/SelectorPath.java @@ -112,20 +112,41 @@ public class SelectorPath { elementQueryString += queryFragment; } - if (index == 0) { - elementQueryString += ".first()"; - } else { - elementQueryString += ".get(" + index + ");"; + if (!hasId(fragments[fragments.length - 1])) { + if (index == 0) { + elementQueryString += ".first()"; + } else { + elementQueryString += ".get(" + index + ")"; + } } // Return full Java variable assignment and eQuery return generateJavaVariable(fragments[fragments.length - 1]) - + elementQueryString; + + elementQueryString + ";"; + } + + /** + * Finds out if the given query fragment has a defined id + * + * @param fragment + * Query fragment + * @return true if has id + */ + private boolean hasId(String fragment) { + for (SelectorPredicate p : SelectorPredicate + .extractPredicates(fragment)) { + if (p.getName().equals("id")) { + return true; + } + } + return false; } /** * Generates a recursive ElementQuery for given path fragment * + * @param fragment + * Query fragment * @return ElementQuery java code as a String */ private String generateFragment(String fragment) { @@ -143,10 +164,11 @@ public class SelectorPath { } /** - * @since - * @param frags - * @param i - * @return + * Returns the name of the component described by given query fragment + * + * @param fragment + * Query fragment + * @return Class part of fragment */ protected String getComponentName(String fragment) { return fragment.split("\\[")[0]; |