summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-06-04 22:29:26 +0300
committerVaadin Code Review <review@vaadin.com>2013-06-05 09:19:10 +0000
commitaa99259eac14854e1e9a33fbbd429d0c5ffa9c52 (patch)
treed13f4ce84e739cc21cdb1ee139721ada556966f3 /server
parent132eee59b8914fdbf9c42a9314e3db95f2f51520 (diff)
downloadvaadin-framework-aa99259eac14854e1e9a33fbbd429d0c5ffa9c52.tar.gz
vaadin-framework-aa99259eac14854e1e9a33fbbd429d0c5ffa9c52.zip
Send connector debug (highlight) using RPC (#11536)
Change-Id: I8995e9affd371543457f16568f1245f7467e0804
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/communication/MetadataWriter.java12
-rw-r--r--server/src/com/vaadin/server/communication/UidlRequestHandler.java71
-rw-r--r--server/src/com/vaadin/server/communication/UidlWriter.java2
-rw-r--r--server/src/com/vaadin/ui/UI.java17
-rw-r--r--server/src/com/vaadin/util/ConnectorHelper.java101
5 files changed, 121 insertions, 82 deletions
diff --git a/server/src/com/vaadin/server/communication/MetadataWriter.java b/server/src/com/vaadin/server/communication/MetadataWriter.java
index 1a3f0e946a..9993ef1e44 100644
--- a/server/src/com/vaadin/server/communication/MetadataWriter.java
+++ b/server/src/com/vaadin/server/communication/MetadataWriter.java
@@ -22,7 +22,6 @@ import java.io.Serializable;
import java.io.Writer;
import java.util.List;
-import com.vaadin.server.ClientConnector;
import com.vaadin.server.ComponentSizeValidator;
import com.vaadin.server.ComponentSizeValidator.InvalidLayout;
import com.vaadin.server.SystemMessages;
@@ -54,9 +53,6 @@ public class MetadataWriter implements Serializable {
* @param async
* True if this message is sent by the server asynchronously,
* false if it is a response to a client message.
- * @param hilightedConnector
- * The connector that should be highlighted on the client or null
- * if none.
* @param messages
* a {@link SystemMessages} containing client-side error
* messages.
@@ -65,8 +61,7 @@ public class MetadataWriter implements Serializable {
*
*/
public void write(UI ui, Writer writer, boolean repaintAll,
- boolean analyzeLayouts, boolean async,
- ClientConnector hilightedConnector, SystemMessages messages)
+ boolean analyzeLayouts, boolean async, SystemMessages messages)
throws IOException {
List<InvalidLayout> invalidComponentRelativeSizes = null;
@@ -109,11 +104,6 @@ public class MetadataWriter implements Serializable {
}
writer.write("]");
}
- if (hilightedConnector != null) {
- writer.write(", \"hl\":\"");
- writer.write(hilightedConnector.getConnectorId());
- writer.write("\"");
- }
}
if (async) {
diff --git a/server/src/com/vaadin/server/communication/UidlRequestHandler.java b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
index 73ff92f8bd..55fb473998 100644
--- a/server/src/com/vaadin/server/communication/UidlRequestHandler.java
+++ b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
@@ -19,13 +19,11 @@ package com.vaadin.server.communication;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
-import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.json.JSONException;
-import com.vaadin.server.ClientConnector;
import com.vaadin.server.Constants;
import com.vaadin.server.LegacyCommunicationManager.InvalidUIDLSecurityKeyException;
import com.vaadin.server.ServletPortletHelper;
@@ -39,7 +37,6 @@ import com.vaadin.server.VaadinSession;
import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.JsonConstants;
import com.vaadin.shared.Version;
-import com.vaadin.ui.Component;
import com.vaadin.ui.UI;
/**
@@ -79,11 +76,10 @@ public class UidlRequestHandler extends SynchronizedRequestHandler implements
checkWidgetsetVersion(request);
String requestThemeName = request.getParameter("theme");
- ClientConnector highlightedConnector;
// repaint requested or session has timed out and new one is created
boolean repaintAll;
- // TODO PUSH repaintAll, analyzeLayouts, highlightConnector should be
+ // TODO PUSH repaintAll, analyzeLayouts should be
// part of the message payload to make the functionality transport
// agnostic
@@ -95,14 +91,6 @@ public class UidlRequestHandler extends SynchronizedRequestHandler implements
// analyzing can be done only with repaintAll
analyzeLayouts = (request
.getParameter(ApplicationConstants.PARAM_ANALYZE_LAYOUTS) != null);
-
- String pid = request
- .getParameter(ApplicationConstants.PARAM_HIGHLIGHT_CONNECTOR);
- if (pid != null) {
- highlightedConnector = uI.getConnectorTracker().getConnector(
- pid);
- highlightConnector(highlightedConnector);
- }
}
StringWriter stringWriter = new StringWriter();
@@ -190,63 +178,6 @@ public class UidlRequestHandler extends SynchronizedRequestHandler implements
outWriter.write("for(;;);[{");
}
- // TODO Does this belong here?
- protected void highlightConnector(ClientConnector highlightedConnector) {
- StringBuilder sb = new StringBuilder();
- sb.append("*** Debug details of a connector: *** \n");
- sb.append("Type: ");
- sb.append(highlightedConnector.getClass().getName());
- sb.append("\nId:");
- sb.append(highlightedConnector.getConnectorId());
- if (highlightedConnector instanceof Component) {
- Component component = (Component) highlightedConnector;
- if (component.getCaption() != null) {
- sb.append("\nCaption:");
- sb.append(component.getCaption());
- }
- }
- printHighlightedConnectorHierarchy(sb, highlightedConnector);
- getLogger().info(sb.toString());
- }
-
- // TODO Does this belong here?
- protected void printHighlightedConnectorHierarchy(StringBuilder sb,
- ClientConnector connector) {
- LinkedList<ClientConnector> h = new LinkedList<ClientConnector>();
- h.add(connector);
- ClientConnector parent = connector.getParent();
- while (parent != null) {
- h.addFirst(parent);
- parent = parent.getParent();
- }
-
- sb.append("\nConnector hierarchy:\n");
- VaadinSession session2 = connector.getUI().getSession();
- sb.append(session2.getClass().getName());
- sb.append("(");
- sb.append(session2.getClass().getSimpleName());
- sb.append(".java");
- sb.append(":1)");
- int l = 1;
- for (ClientConnector connector2 : h) {
- sb.append("\n");
- for (int i = 0; i < l; i++) {
- sb.append(" ");
- }
- l++;
- Class<? extends ClientConnector> connectorClass = connector2
- .getClass();
- Class<?> topClass = connectorClass;
- while (topClass.getEnclosingClass() != null) {
- topClass = topClass.getEnclosingClass();
- }
- sb.append(connectorClass.getName());
- sb.append("(");
- sb.append(topClass.getSimpleName());
- sb.append(".java:1)");
- }
- }
-
private static final Logger getLogger() {
return Logger.getLogger(UidlRequestHandler.class.getName());
}
diff --git a/server/src/com/vaadin/server/communication/UidlWriter.java b/server/src/com/vaadin/server/communication/UidlWriter.java
index 9c736d8dd9..a915501056 100644
--- a/server/src/com/vaadin/server/communication/UidlWriter.java
+++ b/server/src/com/vaadin/server/communication/UidlWriter.java
@@ -162,7 +162,7 @@ public class UidlWriter implements Serializable {
.getSystemMessages(ui.getLocale(), null);
// TODO hilightedConnector
new MetadataWriter().write(ui, writer, repaintAll, analyzeLayouts,
- async, null, messages);
+ async, messages);
writer.write(", ");
writer.write("\"resources\" : ");
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index d4ac156787..3194786431 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -23,6 +23,7 @@ import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.concurrent.Future;
+import java.util.logging.Logger;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
@@ -30,6 +31,7 @@ import com.vaadin.event.ActionManager;
import com.vaadin.event.MouseEvents.ClickEvent;
import com.vaadin.event.MouseEvents.ClickListener;
import com.vaadin.navigator.Navigator;
+import com.vaadin.server.ClientConnector;
import com.vaadin.server.LocaleService;
import com.vaadin.server.Page;
import com.vaadin.server.PaintException;
@@ -40,15 +42,18 @@ import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinServlet;
import com.vaadin.server.VaadinSession;
import com.vaadin.server.communication.PushConnection;
+import com.vaadin.shared.Connector;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.communication.PushMode;
+import com.vaadin.shared.ui.ui.DebugWindowServerRpc;
import com.vaadin.shared.ui.ui.ScrollClientRpc;
import com.vaadin.shared.ui.ui.UIClientRpc;
import com.vaadin.shared.ui.ui.UIConstants;
import com.vaadin.shared.ui.ui.UIServerRpc;
import com.vaadin.shared.ui.ui.UIState;
import com.vaadin.ui.Component.Focusable;
+import com.vaadin.util.ConnectorHelper;
import com.vaadin.util.CurrentInstance;
/**
@@ -161,6 +166,14 @@ public abstract class UI extends AbstractSingleComponentContainer implements
*/
}
};
+ private DebugWindowServerRpc debugRpc = new DebugWindowServerRpc() {
+ @Override
+ public void showServerDebugInfo(Connector connector) {
+ String info = ConnectorHelper
+ .getDebugInformation((ClientConnector) connector);
+ getLogger().info(info);
+ }
+ };
/**
* Timestamp keeping track of the last heartbeat of this UI. Updated to the
@@ -193,6 +206,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
*/
public UI(Component content) {
registerRpc(rpc);
+ registerRpc(debugRpc);
setSizeFull();
setContent(content);
}
@@ -1441,4 +1455,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
return localeService;
}
+ private static Logger getLogger() {
+ return Logger.getLogger(UI.class.getName());
+ }
}
diff --git a/server/src/com/vaadin/util/ConnectorHelper.java b/server/src/com/vaadin/util/ConnectorHelper.java
new file mode 100644
index 0000000000..e698e9222a
--- /dev/null
+++ b/server/src/com/vaadin/util/ConnectorHelper.java
@@ -0,0 +1,101 @@
+/*
+ * 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.util;
+
+import java.util.LinkedList;
+
+import com.vaadin.server.ClientConnector;
+import com.vaadin.ui.Component;
+
+/**
+ * Provides various helper methods for connectors. Meant for internal use.
+ *
+ * @since 7.1
+ * @author Vaadin Ltd
+ */
+public class ConnectorHelper {
+
+ /**
+ * Creates a string containing debug info for the connector
+ *
+ * @since 7.1
+ * @param connector
+ * The connector to print debug info about
+ * @return A string with debug information
+ */
+ public static String getDebugInformation(ClientConnector connector) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("*** Debug details of a connector: *** \n");
+ sb.append("Type: ");
+ sb.append(connector.getClass().getName());
+ sb.append("\nId:");
+ sb.append(connector.getConnectorId());
+ if (connector instanceof Component) {
+ Component component = (Component) connector;
+ if (component.getCaption() != null) {
+ sb.append("\nCaption:");
+ sb.append(component.getCaption());
+ }
+ }
+ writeHierarchyInformation(connector, sb);
+ return sb.toString();
+ }
+
+ /**
+ * Creates a string containing hierarchy information for the connector
+ *
+ * @since 7.1
+ * @param connector
+ * The connector to get hierarchy information for
+ * @param builder
+ * The StringBuilder where the information should be written
+ */
+ public static void writeHierarchyInformation(ClientConnector connector,
+ StringBuilder builder) {
+ LinkedList<ClientConnector> h = new LinkedList<ClientConnector>();
+ h.add(connector);
+ ClientConnector parent = connector.getParent();
+ while (parent != null) {
+ h.addFirst(parent);
+ parent = parent.getParent();
+ }
+
+ builder.append("\nConnector hierarchy:\n");
+
+ int l = 0;
+ for (ClientConnector connector2 : h) {
+ if (l != 0) {
+ builder.append("\n");
+ for (int i = 0; i < l; i++) {
+ builder.append(" ");
+ }
+ }
+ l++;
+ Class<? extends ClientConnector> connectorClass = connector2
+ .getClass();
+ Class<?> topClass = connectorClass;
+ while (topClass.getEnclosingClass() != null) {
+ topClass = topClass.getEnclosingClass();
+ }
+ builder.append(connectorClass.getName());
+ builder.append("(");
+ builder.append(topClass.getSimpleName());
+ builder.append(".java:1)");
+ }
+ }
+
+}