summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java7
-rw-r--r--client/src/main/java/com/vaadin/client/ServerConnector.java35
-rw-r--r--client/src/main/java/com/vaadin/client/WidgetSet.java6
-rw-r--r--client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java7
-rw-r--r--client/src/main/java/com/vaadin/client/ui/AbstractConnector.java11
-rw-r--r--uitest/src/main/java/com/vaadin/tests/componentlocator/ComponentLocatorInheritedClasses.java36
-rw-r--r--uitest/src/test/java/com/vaadin/tests/componentlocator/ComponentLocatorInheritedClassesTest.java37
7 files changed, 127 insertions, 12 deletions
diff --git a/client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java b/client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java
index 7f4b1b6759..81793084d2 100644
--- a/client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java
+++ b/client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java
@@ -50,7 +50,6 @@ public class JavaScriptConnectorHelper {
private final Map<Element, Map<JavaScriptObject, ElementResizeListener>> resizeListeners = new HashMap<>();
private JavaScriptObject connectorWrapper;
- private int tag;
private String initFunctionName;
private String tagName;
@@ -407,10 +406,6 @@ public class JavaScriptConnectorHelper {
return new Object[] { Util.json2jso(parametersJson) };
}
- public void setTag(int tag) {
- this.tag = tag;
- }
-
public void invokeJsRpc(MethodInvocation invocation,
JsonArray parametersJson) {
String iface = invocation.getInterfaceName();
@@ -496,7 +491,7 @@ public class JavaScriptConnectorHelper {
ApplicationConfiguration conf = connector.getConnection()
.getConfiguration();
ArrayList<String> initFunctionNames = new ArrayList<String>();
- Integer tag = Integer.valueOf(this.tag);
+ Integer tag = Integer.valueOf(connector.getTag());
while (tag != null) {
String initFunctionName = conf.getServerSideClassNameForTag(tag);
initFunctionName = initFunctionName.replaceAll("\\.", "_");
diff --git a/client/src/main/java/com/vaadin/client/ServerConnector.java b/client/src/main/java/com/vaadin/client/ServerConnector.java
index 9ab076305c..71d65732bb 100644
--- a/client/src/main/java/com/vaadin/client/ServerConnector.java
+++ b/client/src/main/java/com/vaadin/client/ServerConnector.java
@@ -217,4 +217,39 @@ public interface ServerConnector extends Connector {
*/
public boolean hasEventListener(String eventIdentifier);
+ /**
+ * Sets the connector type tag for this connector. This should only be
+ * called from
+ * {@link WidgetSet#createConnector(int, ApplicationConfiguration)}
+ *
+ * @see #getTag()
+ *
+ * @param tag
+ * the connector type tag
+ *
+ * @deprecated This is an internal method and should not be called by an
+ * application developer.
+ *
+ * @since 8.1
+ */
+ @Deprecated
+ public void setTag(int tag);
+
+ /**
+ * Gets the connector type tag for this connector. This type tag is an
+ * identifier used to map client-side connectors to their server-side
+ * classes. The server-side class information is stored in
+ * {@link ApplicationConfiguration} and contains class names and their
+ * hierarchy.
+ *
+ * @see ApplicationConfiguration#getServerSideClassNameForTag(Integer)
+ * @see ApplicationConfiguration#getTagsForServerSideClassName(String)
+ * @see ApplicationConfiguration#getParentTag(int)
+ *
+ * @return the connector type tag
+ *
+ * @since 8.1
+ */
+ public int getTag();
+
}
diff --git a/client/src/main/java/com/vaadin/client/WidgetSet.java b/client/src/main/java/com/vaadin/client/WidgetSet.java
index cf3db7aaa9..2fc486b00e 100644
--- a/client/src/main/java/com/vaadin/client/WidgetSet.java
+++ b/client/src/main/java/com/vaadin/client/WidgetSet.java
@@ -20,7 +20,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.google.gwt.core.client.GWT;
-import com.vaadin.client.communication.HasJavaScriptConnectorHelper;
import com.vaadin.client.metadata.BundleLoadCallback;
import com.vaadin.client.metadata.ConnectorBundleLoader;
import com.vaadin.client.metadata.NoDataException;
@@ -80,10 +79,7 @@ public class WidgetSet {
*/
ServerConnector connector = (ServerConnector) TypeData
.getType(classType).createInstance();
- if (connector instanceof HasJavaScriptConnectorHelper) {
- ((HasJavaScriptConnectorHelper) connector)
- .getJavascriptConnectorHelper().setTag(tag);
- }
+ connector.setTag(tag);
return connector;
}
} catch (NoDataException e) {
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 3f46a0a812..c7abe8c15f 100644
--- a/client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java
+++ b/client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java
@@ -608,12 +608,17 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy {
String widgetName) {
List<String> ids = getIDsForConnector(connector);
+ String exactClass = connector.getConnection().getConfiguration()
+ .getServerSideClassNameForTag(connector.getTag());
+ if (!ids.contains(exactClass)) {
+ ids.add(exactClass);
+ }
List<Integer> widgetTags = new ArrayList<>();
widgetTags.addAll(getTags(widgetName));
if (widgetTags.size() == 0) {
- widgetTags.addAll(getTags("com.vaadin.ui" + widgetName));
+ widgetTags.addAll(getTags("com.vaadin.ui." + widgetName));
}
for (int i = 0, l = ids.size(); i < l; ++i) {
diff --git a/client/src/main/java/com/vaadin/client/ui/AbstractConnector.java b/client/src/main/java/com/vaadin/client/ui/AbstractConnector.java
index 93ab05a883..f7bdf80ee0 100644
--- a/client/src/main/java/com/vaadin/client/ui/AbstractConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/AbstractConnector.java
@@ -61,6 +61,7 @@ public abstract class AbstractConnector
private ApplicationConnection connection;
private String id;
+ private int tag;
private HandlerManager handlerManager;
private FastStringMap<HandlerManager> statePropertyHandlerManagers;
@@ -523,4 +524,14 @@ public abstract class AbstractConnector
}
}
+
+ @Override
+ public int getTag() {
+ return tag;
+ }
+
+ @Override
+ public void setTag(int tag) {
+ this.tag = tag;
+ }
}
diff --git a/uitest/src/main/java/com/vaadin/tests/componentlocator/ComponentLocatorInheritedClasses.java b/uitest/src/main/java/com/vaadin/tests/componentlocator/ComponentLocatorInheritedClasses.java
new file mode 100644
index 0000000000..46fb7cc00e
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/componentlocator/ComponentLocatorInheritedClasses.java
@@ -0,0 +1,36 @@
+package com.vaadin.tests.componentlocator;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class ComponentLocatorInheritedClasses extends UI {
+
+ public static class DefaultLabel extends Label {
+
+ protected DefaultLabel(String content) {
+ super(content);
+ }
+
+ public DefaultLabel() {
+ this("Default Custom Label");
+ }
+ }
+
+ public static class MyCustomLabel extends DefaultLabel {
+ public MyCustomLabel(String content) {
+ super(content);
+ }
+ }
+
+ @Override
+ protected void init(VaadinRequest request) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.addComponents(new Label("Vaadin Basic Label"),
+ new DefaultLabel(), new MyCustomLabel("My Custom Label"));
+ setContent(layout);
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/componentlocator/ComponentLocatorInheritedClassesTest.java b/uitest/src/test/java/com/vaadin/tests/componentlocator/ComponentLocatorInheritedClassesTest.java
new file mode 100644
index 0000000000..4d8449fa38
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/componentlocator/ComponentLocatorInheritedClassesTest.java
@@ -0,0 +1,37 @@
+package com.vaadin.tests.componentlocator;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.testbench.elementsbase.ServerClass;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class ComponentLocatorInheritedClassesTest extends SingleBrowserTest {
+
+ @ServerClass("com.vaadin.tests.componentlocator.ComponentLocatorInheritedClasses.DefaultLabel")
+ public static class DefaultLabelElement extends LabelElement {
+ }
+
+ @ServerClass("com.vaadin.tests.componentlocator.ComponentLocatorInheritedClasses.MyCustomLabel")
+ public static class MyCustomLabelElement extends DefaultLabelElement {
+ }
+
+ @Test
+ public void label_finds_all_three() {
+ openTestURL();
+ Assert.assertEquals(3, $(LabelElement.class).all().size());
+ }
+
+ @Test
+ public void defaultlabel_finds_two() {
+ openTestURL();
+ Assert.assertEquals(2, $(DefaultLabelElement.class).all().size());
+ }
+
+ @Test
+ public void mycustomlabel_finds_one() {
+ openTestURL();
+ Assert.assertEquals(1, $(MyCustomLabelElement.class).all().size());
+ }
+}