diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-09-12 12:43:01 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-09-12 12:04:00 +0000 |
commit | 9f30ebf6662c99a5b6b2e1be2e0c25ed01571592 (patch) | |
tree | c70110ff7d2af932e0d376d4787c02958b44caf7 /client | |
parent | 52cada891a947b593e019639f3b65c773084a938 (diff) | |
download | vaadin-framework-9f30ebf6662c99a5b6b2e1be2e0c25ed01571592.tar.gz vaadin-framework-9f30ebf6662c99a5b6b2e1be2e0c25ed01571592.zip |
Support finding components in v7 packages with ComponentLocator
Change-Id: I60eabf3b1c6363be505a2d21f7ed439c5357f61f
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java index 3ba6284cf2..3f46a0a812 100644 --- a/client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -609,12 +609,11 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { List<String> ids = getIDsForConnector(connector); - Integer[] widgetTags = client.getConfiguration() - .getTagsForServerSideClassName(getFullClassName(widgetName)); - if (widgetTags.length == 0) { - widgetTags = client.getConfiguration() - .getTagsForServerSideClassName( - getFullClassName("com.vaadin.ui." + widgetName)); + List<Integer> widgetTags = new ArrayList<>(); + widgetTags.addAll(getTags(widgetName)); + + if (widgetTags.size() == 0) { + widgetTags.addAll(getTags("com.vaadin.ui" + widgetName)); } for (int i = 0, l = ids.size(); i < l; ++i) { @@ -627,7 +626,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { final String simpleName = getSimpleClassName(name); final String fullName = getFullClassName(name); - if (widgetTags.length > 0) { + if (widgetTags.size() > 0) { Integer[] foundTags = client.getConfiguration() .getTagsForServerSideClassName(fullName); for (int tag : foundTags) { @@ -656,6 +655,28 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { } /** + * Gets the tags for server side class name. Also includes tags for older + * components in v7 package. + * + * @param widgetName + * the server side class name for widget + * @return list of tags + */ + private List<Integer> getTags(String widgetName) { + List<Integer> widgetTags = new ArrayList<>(); + Arrays.stream(client.getConfiguration() + .getTagsForServerSideClassName(getFullClassName(widgetName))) + .forEach(widgetTags::add); + if (widgetName.startsWith("com.vaadin.ui")) { + Arrays.stream(client.getConfiguration() + .getTagsForServerSideClassName(getFullClassName(widgetName + .replace("com.vaadin.ui", "com.vaadin.v7.ui")))) + .forEach(widgetTags::add); + } + return widgetTags; + } + + /** * Extracts the name of the widget class from a path fragment * * @param pathFragment @@ -738,9 +759,9 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { return list; } - private boolean tagsMatch(Integer[] targets, Integer tag) { - for (int i = 0; i < targets.length; ++i) { - if (targets[i].equals(tag)) { + private boolean tagsMatch(List<Integer> targets, Integer tag) { + for (int i = 0; i < targets.size(); ++i) { + if (targets.get(i).equals(tag)) { return true; } } |