summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-06-07 10:01:17 +0300
committerVaadin Code Review <review@vaadin.com>2013-06-07 07:08:27 +0000
commita5ec937fb8a91a55d754f8f2048416a5dd10b931 (patch)
tree529139147265bd2777bd3d55900b9c19cc28b34a
parentda29e2b1a50b3e8d7240e9c76d829042772f65ef (diff)
downloadvaadin-framework-a5ec937fb8a91a55d754f8f2048416a5dd10b931.tar.gz
vaadin-framework-a5ec937fb8a91a55d754f8f2048416a5dd10b931.zip
Info section for the debug window (#12019)
Change-Id: Ie265c6e994c8038a3dc0bb05b94233bbc2506c58
-rw-r--r--WebContent/VAADIN/themes/base/debug/debug.scss8
-rw-r--r--client/src/com/vaadin/client/ApplicationConfiguration.java2
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java16
-rw-r--r--client/src/com/vaadin/client/communication/AtmospherePushConnection.java10
-rw-r--r--client/src/com/vaadin/client/communication/PushConnection.java9
-rw-r--r--client/src/com/vaadin/client/debug/internal/InfoSection.java289
6 files changed, 334 insertions, 0 deletions
diff --git a/WebContent/VAADIN/themes/base/debug/debug.scss b/WebContent/VAADIN/themes/base/debug/debug.scss
index 209c3e0469..d71575c818 100644
--- a/WebContent/VAADIN/themes/base/debug/debug.scss
+++ b/WebContent/VAADIN/themes/base/debug/debug.scss
@@ -254,5 +254,13 @@
.v-debugwindow-row > span.value {
width: 100%;
}
+
+ /* INFO */
+ .v-debugwindow-info {
+ .v-debugwindow-row {
+ display:block;
+ min-width: 100%;
+ }
+ }
} \ No newline at end of file
diff --git a/client/src/com/vaadin/client/ApplicationConfiguration.java b/client/src/com/vaadin/client/ApplicationConfiguration.java
index a1f2e4f30e..86ab9455ed 100644
--- a/client/src/com/vaadin/client/ApplicationConfiguration.java
+++ b/client/src/com/vaadin/client/ApplicationConfiguration.java
@@ -36,6 +36,7 @@ import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.vaadin.client.debug.internal.ErrorNotificationHandler;
import com.vaadin.client.debug.internal.HierarchySection;
+import com.vaadin.client.debug.internal.InfoSection;
import com.vaadin.client.debug.internal.LogSection;
import com.vaadin.client.debug.internal.NetworkSection;
import com.vaadin.client.debug.internal.ProfilerSection;
@@ -575,6 +576,7 @@ public class ApplicationConfiguration implements EntryPoint {
if (LogConfiguration.loggingIsEnabled()) {
window.addSection((Section) GWT.create(LogSection.class));
}
+ window.addSection((Section) GWT.create(InfoSection.class));
window.addSection((Section) GWT.create(HierarchySection.class));
window.addSection((Section) GWT.create(NetworkSection.class));
if (Profiler.isEnabled()) {
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index ac058b5536..4229ca0b67 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -3400,4 +3400,20 @@ public class ApplicationConnection {
public void handlePushMessage(String message) {
handleJSONText(message, 200);
}
+
+ /**
+ * Returns a human readable string representation of the method used to
+ * communicate with the server.
+ *
+ * @since 7.1
+ * @return A string representation of the current transport type
+ */
+ public String getCommunicationMethod() {
+ if (push != null) {
+ return "Push (" + push.getTransportType() + ")";
+ } else {
+ return "XHR";
+ }
+ }
+
}
diff --git a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
index f7936f8717..506716040d 100644
--- a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
+++ b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
@@ -471,4 +471,14 @@ public class AtmospherePushConnection implements PushConnection {
});
}
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.communication.PushConnection#getTransportType()
+ */
+ @Override
+ public String getTransportType() {
+ return transport;
+ }
}
diff --git a/client/src/com/vaadin/client/communication/PushConnection.java b/client/src/com/vaadin/client/communication/PushConnection.java
index bc2af98f1a..a7eba224be 100644
--- a/client/src/com/vaadin/client/communication/PushConnection.java
+++ b/client/src/com/vaadin/client/communication/PushConnection.java
@@ -92,4 +92,13 @@ public interface PushConnection {
*/
public void disconnect(Command command);
+ /**
+ * Returns a human readable string representation of the transport type used
+ * to communicate with the server.
+ *
+ * @since 7.1
+ * @return A human readable string representation of the transport type
+ */
+ public String getTransportType();
+
} \ No newline at end of file
diff --git a/client/src/com/vaadin/client/debug/internal/InfoSection.java b/client/src/com/vaadin/client/debug/internal/InfoSection.java
new file mode 100644
index 0000000000..05908c8834
--- /dev/null
+++ b/client/src/com/vaadin/client/debug/internal/InfoSection.java
@@ -0,0 +1,289 @@
+/*
+ * Copyright 2000-2013 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.debug.internal;
+
+import java.util.logging.Level;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.client.ApplicationConfiguration;
+import com.vaadin.client.ApplicationConnection;
+import com.vaadin.client.ValueMap;
+import com.vaadin.shared.Version;
+import com.vaadin.shared.util.SharedUtil;
+
+/**
+ * Information section of the debug window
+ *
+ * @since 7.1
+ * @author Vaadin Ltd
+ */
+public class InfoSection implements Section {
+
+ private static final String THEME_VERSION_CLASSNAME = "v-vaadin-version";
+ private static final String PRIMARY_STYLE_NAME = VDebugWindow.STYLENAME
+ + "-info";
+ private static final String ERROR_STYLE = Level.SEVERE.getName();
+ private final HTML content = new HTML();
+ private DebugButton tabButton = new DebugButton(Icon.INFO);
+ private FlowPanel controls = new FlowPanel();
+
+ /**
+ *
+ */
+ public InfoSection() {
+ createContent();
+ }
+
+ /**
+ * @since 7.1
+ */
+ private void createContent() {
+ content.setStylePrimaryName(PRIMARY_STYLE_NAME);
+ refresh();
+ }
+
+ private void addRow(String parameter, String value) {
+ addRow(parameter, value, null);
+ }
+
+ private void addRow(String parameter, String value, String className) {
+ Element row = DOM.createDiv();
+ row.addClassName(VDebugWindow.STYLENAME + "-row");
+ if (className != null) {
+ row.addClassName(className);
+ }
+ Element span = DOM.createSpan();
+ span.setInnerText(parameter + ": " + value);
+ row.appendChild(span);
+ content.getElement().appendChild(row);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.debug.internal.Section#getTabButton()
+ */
+ @Override
+ public DebugButton getTabButton() {
+ return tabButton;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.debug.internal.Section#getControls()
+ */
+ @Override
+ public Widget getControls() {
+ return controls;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.debug.internal.Section#getContent()
+ */
+ @Override
+ public Widget getContent() {
+ return content;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.debug.internal.Section#show()
+ */
+ @Override
+ public void show() {
+ refresh();
+ }
+
+ /**
+ * Updates the information for all running applications
+ *
+ * @since 7.1
+ */
+ private void refresh() {
+ clear();
+ for (ApplicationConnection application : ApplicationConfiguration
+ .getRunningApplications()) {
+ refresh(application);
+ }
+ }
+
+ /**
+ * Updates the information for a single running application
+ *
+ * @since 7.1
+ */
+ private void refresh(ApplicationConnection connection) {
+ clear();
+ ApplicationConfiguration configuration = connection.getConfiguration();
+
+ addVersionInfo(configuration);
+ addRow("Widget set", GWT.getModuleName());
+ addRow("Theme", connection.getConfiguration().getThemeName());
+
+ String communicationMethodInfo = connection.getCommunicationMethod();
+ int pollInterval = connection.getUIConnector().getState().pollInterval;
+ if (pollInterval > 0) {
+ communicationMethodInfo += " (poll interval " + pollInterval + "s)";
+ }
+ addRow("Communication method", communicationMethodInfo);
+
+ String heartBeatInfo;
+ if (configuration.getHeartbeatInterval() < 0) {
+ heartBeatInfo = "Disabled";
+ } else {
+ heartBeatInfo = configuration.getHeartbeatInterval() + "s";
+ }
+ addRow("Heartbeat", heartBeatInfo);
+ }
+
+ /**
+ * Logs version information for client/server/theme.
+ *
+ * @param applicationConfiguration
+ * @since 7.1
+ */
+ private void addVersionInfo(
+ ApplicationConfiguration applicationConfiguration) {
+ String clientVersion = Version.getFullVersion();
+ String servletVersion = applicationConfiguration.getServletVersion();
+
+ String themeVersion;
+ boolean themeOk;
+ if (com.vaadin.client.BrowserInfo.get().isIE8()) {
+ themeVersion = "<IE8 can't detect this>";
+ themeOk = true;
+ } else {
+ themeVersion = getThemeVersion();
+ themeOk = equalsEither(themeVersion, clientVersion, servletVersion);
+ }
+
+ boolean clientOk = equalsEither(clientVersion, servletVersion,
+ themeVersion);
+ boolean servletOk = equalsEither(servletVersion, clientVersion,
+ themeVersion);
+ addRow("Client engine version", clientVersion, clientOk ? null
+ : ERROR_STYLE);
+ addRow("Server engine version", servletVersion, servletOk ? null
+ : ERROR_STYLE);
+ addRow("Theme version", themeVersion, themeOk ? null : ERROR_STYLE);
+ }
+
+ /**
+ * Checks if the target value equals one of the reference values
+ *
+ * @param target
+ * The value to compare
+ * @param reference1
+ * A reference value
+ * @param reference2
+ * A reference value
+ * @return true if target equals one of the references, false otherwise
+ */
+ private boolean equalsEither(String target, String reference1,
+ String reference2) {
+ if (SharedUtil.equals(target, reference1)) {
+ return true;
+ }
+ if (SharedUtil.equals(target, reference2)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Finds out the version of the current theme (i.e. the version of Vaadin
+ * used to compile it)
+ *
+ * @since 7.1
+ * @return The full version as a string
+ */
+ private String getThemeVersion() {
+ Element div = DOM.createDiv();
+ div.setClassName(THEME_VERSION_CLASSNAME);
+ RootPanel.get().getElement().appendChild(div);
+ String version = getComputedStyle(div, ":after", "content");
+ div.removeFromParent();
+ if (version != null) {
+ // String version = new ComputedStyle(div).getProperty("content");
+ version = version.replace("'", "");
+ version = version.replace("\"", "");
+ }
+ return version;
+ }
+
+ private native String getComputedStyle(Element elem, String pseudoElement,
+ String property)
+ /*-{
+ if ($wnd.document.defaultView && $wnd.document.defaultView.getComputedStyle) {
+ return $wnd.document.defaultView.getComputedStyle(elem, pseudoElement)[property];
+ } else {
+ return null;
+ }
+ }-*/;
+
+ /**
+ * Removes all content
+ *
+ * @since 7.1
+ */
+ private void clear() {
+ content.getElement().setInnerHTML("");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.debug.internal.Section#hide()
+ */
+ @Override
+ public void hide() {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.debug.internal.Section#meta(com.vaadin.client.
+ * ApplicationConnection, com.vaadin.client.ValueMap)
+ */
+ @Override
+ public void meta(ApplicationConnection ac, ValueMap meta) {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.debug.internal.Section#uidl(com.vaadin.client.
+ * ApplicationConnection, com.vaadin.client.ValueMap)
+ */
+ @Override
+ public void uidl(ApplicationConnection ac, ValueMap uidl) {
+ }
+
+}