summaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2016-11-01 22:52:48 +0200
committerPekka Hyvönen <pekka@vaadin.com>2016-12-09 09:39:00 +0200
commitcbbd1710fe1a72a841860fedeb274007ebf7ec3b (patch)
tree64cd436b0bfcb33d02dbc235e74406fb08bae0c5 /client/src
parente4af2f2a319b9e4d683ca6286ede423629e5bf52 (diff)
downloadvaadin-framework-cbbd1710fe1a72a841860fedeb274007ebf7ec3b.tar.gz
vaadin-framework-cbbd1710fe1a72a841860fedeb274007ebf7ec3b.zip
Show a sensible message for missing extensions (#10799)
Also remove ComponentMissingFromDefaultWidgetsetTest since it's identical to UnknownComponentConnectorTest Change-Id: I4b4b8f40c8376f4ea26b73d41191a3e7e811df01
Diffstat (limited to 'client/src')
-rw-r--r--client/src/main/java/com/vaadin/client/ApplicationConfiguration.java21
-rw-r--r--client/src/main/java/com/vaadin/client/VUIDLBrowser.java4
-rw-r--r--client/src/main/java/com/vaadin/client/WidgetSet.java50
-rw-r--r--client/src/main/java/com/vaadin/client/debug/internal/OptimizedWidgetsetPanel.java4
-rw-r--r--client/src/main/java/com/vaadin/client/ui/UnknownComponentConnector.java12
-rw-r--r--client/src/main/java/com/vaadin/client/ui/UnknownExtensionConnector.java33
6 files changed, 98 insertions, 26 deletions
diff --git a/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java b/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java
index db7900fd15..102dc15761 100644
--- a/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java
+++ b/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java
@@ -53,6 +53,7 @@ import com.vaadin.client.metadata.ConnectorBundleLoader;
import com.vaadin.client.metadata.NoDataException;
import com.vaadin.client.metadata.TypeData;
import com.vaadin.client.ui.UnknownComponentConnector;
+import com.vaadin.client.ui.UnknownExtensionConnector;
import com.vaadin.client.ui.ui.UIConnector;
import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.ui.ui.UIConstants;
@@ -526,7 +527,11 @@ public class ApplicationConfiguration implements EntryPoint {
currentTag = getParentTag(currentTag.intValue());
}
if (type == null) {
- type = UnknownComponentConnector.class;
+ if (isExtensionType(tag)) {
+ type = UnknownExtensionConnector.class;
+ } else {
+ type = UnknownComponentConnector.class;
+ }
if (unknownComponents == null) {
unknownComponents = new HashMap<>();
}
@@ -537,6 +542,20 @@ public class ApplicationConfiguration implements EntryPoint {
return type;
}
+ private boolean isExtensionType(int tag) {
+ Integer currentTag = Integer.valueOf(tag);
+ while (currentTag != null) {
+ String serverSideClassNameForTag = getServerSideClassNameForTag(
+ currentTag);
+ if ("com.vaadin.server.AbstractExtension"
+ .equals(serverSideClassNameForTag)) {
+ return true;
+ }
+ currentTag = getParentTag(currentTag.intValue());
+ }
+ return false;
+ }
+
public void addComponentInheritanceInfo(ValueMap valueMap) {
JsArrayString keyArray = valueMap.getKeyArray();
for (int i = 0; i < keyArray.length(); i++) {
diff --git a/client/src/main/java/com/vaadin/client/VUIDLBrowser.java b/client/src/main/java/com/vaadin/client/VUIDLBrowser.java
index 990d67dbe1..07315629bd 100644
--- a/client/src/main/java/com/vaadin/client/VUIDLBrowser.java
+++ b/client/src/main/java/com/vaadin/client/VUIDLBrowser.java
@@ -36,6 +36,7 @@ import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ui.UnknownComponentConnector;
+import com.vaadin.client.ui.UnknownExtensionConnector;
import com.vaadin.client.ui.VWindow;
import elemental.json.JsonArray;
@@ -229,7 +230,8 @@ public class VUIDLBrowser extends SimpleTree {
int tag) {
Class<? extends ServerConnector> widgetClassByDecodedTag = conf
.getConnectorClassByEncodedTag(tag);
- if (widgetClassByDecodedTag == UnknownComponentConnector.class) {
+ if (widgetClassByDecodedTag == UnknownComponentConnector.class
+ || widgetClassByDecodedTag == UnknownExtensionConnector.class) {
return conf.getUnknownServerClassNameByTag(tag)
+ "(NO CLIENT IMPLEMENTATION FOUND)";
} else {
diff --git a/client/src/main/java/com/vaadin/client/WidgetSet.java b/client/src/main/java/com/vaadin/client/WidgetSet.java
index 962b756784..8c232de019 100644
--- a/client/src/main/java/com/vaadin/client/WidgetSet.java
+++ b/client/src/main/java/com/vaadin/client/WidgetSet.java
@@ -26,6 +26,8 @@ import com.vaadin.client.metadata.ConnectorBundleLoader;
import com.vaadin.client.metadata.NoDataException;
import com.vaadin.client.metadata.TypeData;
import com.vaadin.client.ui.UnknownComponentConnector;
+import com.vaadin.client.ui.UnknownExtensionConnector;
+import com.vaadin.client.ui.UnknownExtensionConnector;
public class WidgetSet {
/**
@@ -55,33 +57,43 @@ public class WidgetSet {
Class<? extends ServerConnector> classType = resolveInheritedConnectorType(
conf, tag);
- if (classType == null || classType == UnknownComponentConnector.class) {
- String serverSideName = conf.getUnknownServerClassNameByTag(tag);
- UnknownComponentConnector c = GWT
- .create(UnknownComponentConnector.class);
- c.setServerSideClassName(serverSideName);
- Profiler.leave("WidgetSet.createConnector");
- return c;
- } else {
- /*
- * let the auto generated code instantiate this type
- */
- try {
+ try {
+ if (classType == null
+ || classType == UnknownComponentConnector.class
+ || classType == UnknownExtensionConnector.class) {
+ String serverSideName = conf
+ .getUnknownServerClassNameByTag(tag);
+ if (classType == UnknownExtensionConnector.class) {
+ // Display message in the console for non-visual connectors
+ getLogger().severe(UnknownComponentConnector
+ .createMessage(serverSideName));
+ return GWT.create(UnknownExtensionConnector.class);
+ } else {
+ UnknownComponentConnector c = GWT
+ .create(UnknownComponentConnector.class);
+ // Set message to be shown in a widget for visual connectors
+ c.setServerSideClassName(serverSideName);
+ return c;
+ }
+ } else {
+ /*
+ * let the auto generated code instantiate this type
+ */
ServerConnector connector = (ServerConnector) TypeData
.getType(classType).createInstance();
if (connector instanceof HasJavaScriptConnectorHelper) {
((HasJavaScriptConnectorHelper) connector)
.getJavascriptConnectorHelper().setTag(tag);
}
- Profiler.leave("WidgetSet.createConnector");
return connector;
- } catch (NoDataException e) {
- Profiler.leave("WidgetSet.createConnector");
- throw new IllegalStateException(
- "There is no information about " + classType
- + ". Did you remember to compile the right widgetset?",
- e);
}
+ } catch (NoDataException e) {
+ throw new IllegalStateException(
+ "There is no information about " + classType
+ + ". Did you remember to compile the right widgetset?",
+ e);
+ } finally {
+ Profiler.leave("WidgetSet.createConnector");
}
}
diff --git a/client/src/main/java/com/vaadin/client/debug/internal/OptimizedWidgetsetPanel.java b/client/src/main/java/com/vaadin/client/debug/internal/OptimizedWidgetsetPanel.java
index 807b6e65bb..ab8307d39e 100644
--- a/client/src/main/java/com/vaadin/client/debug/internal/OptimizedWidgetsetPanel.java
+++ b/client/src/main/java/com/vaadin/client/debug/internal/OptimizedWidgetsetPanel.java
@@ -26,6 +26,7 @@ import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util;
import com.vaadin.client.ui.UnknownComponentConnector;
+import com.vaadin.client.ui.UnknownExtensionConnector;
/**
* Optimized widgetset view panel of the debug window.
@@ -89,7 +90,8 @@ public class OptimizedWidgetsetPanel extends FlowPanel {
break;
}
- if (connectorClass != UnknownComponentConnector.class) {
+ if (connectorClass != UnknownComponentConnector.class
+ && connectorClass != UnknownExtensionConnector.class) {
usedConnectors.add(connectorClass.getName());
}
tag++;
diff --git a/client/src/main/java/com/vaadin/client/ui/UnknownComponentConnector.java b/client/src/main/java/com/vaadin/client/ui/UnknownComponentConnector.java
index 99de7f0275..b4f425d3d3 100644
--- a/client/src/main/java/com/vaadin/client/ui/UnknownComponentConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/UnknownComponentConnector.java
@@ -31,13 +31,17 @@ public class UnknownComponentConnector extends AbstractComponentConnector {
}
public void setServerSideClassName(String serverClassName) {
- getWidget().setCaption("Widgetset '" + GWT.getModuleName()
- + "' does not contain implementation for " + serverClassName
- + ". Check its component connector's @Connect mapping, widgetsets "
+ getWidget().setCaption(createMessage(serverClassName));
+ }
+
+ public static String createMessage(String serverClassName) {
+ return "Widgetset '" + GWT.getModuleName()
+ + "' does not contain an implementation for " + serverClassName
+ + ". Check the connector's @Connect mapping, the widgetset's "
+ "GWT module description file and re-compile your"
+ " widgetset. In case you have downloaded a vaadin"
+ " add-on package, you might want to refer to "
+ "<a href='http://vaadin.com/using-addons'>add-on "
- + "instructions</a>.");
+ + "instructions</a>.";
}
}
diff --git a/client/src/main/java/com/vaadin/client/ui/UnknownExtensionConnector.java b/client/src/main/java/com/vaadin/client/ui/UnknownExtensionConnector.java
new file mode 100644
index 0000000000..151b1ad526
--- /dev/null
+++ b/client/src/main/java/com/vaadin/client/ui/UnknownExtensionConnector.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.client.ui;
+
+import com.vaadin.client.ServerConnector;
+import com.vaadin.client.extensions.AbstractExtensionConnector;
+
+/**
+ * Connector used as a placeholder for extensions that are not present in the
+ * widgetset.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class UnknownExtensionConnector extends AbstractExtensionConnector {
+ @Override
+ protected void extend(ServerConnector target) {
+ // Noop
+ }
+}