diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2012-10-19 16:59:47 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2012-10-19 17:10:14 +0300 |
commit | 0bbd4c528a22bfab211e46330d1019712adb658e (patch) | |
tree | a46db89e7790a8a2d1067440d3e800070b007b69 | |
parent | 06efa74eafcf78e3654c60bd5c14bb97bed2b13d (diff) | |
download | vaadin-framework-0bbd4c528a22bfab211e46330d1019712adb658e.tar.gz vaadin-framework-0bbd4c528a22bfab211e46330d1019712adb658e.zip |
Properly support extension connectors in debug console (#8422, #9999)
* Clicking an ExtensionConnector entry highlights their ancestor ComponentConnector if any
* Shift-clicking also works, change server side highlighting to support arbitrary ClientConnectors
Change-Id: I834a602a75a70d2fa2a7b44e9ae8da6e85f91be7
4 files changed, 52 insertions, 51 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 05ee63a7d5..9442198772 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -579,13 +579,14 @@ public class ApplicationConnection { /** * Sends a request to the server to print details to console that will help - * developer to locate component in the source code. + * the developer to locate the corresponding server-side connector in the + * source code. * - * @param componentConnector + * @param serverConnector */ - void highlightComponent(ComponentConnector componentConnector) { - String params = getRepaintAllParameters() + "&highlightComponent=" - + componentConnector.getConnectorId(); + void highlightConnector(ServerConnector serverConnector) { + String params = getRepaintAllParameters() + "&highlightConnector=" + + serverConnector.getConnectorId(); makeUidlRequest("", params, false); } diff --git a/client/src/com/vaadin/client/VDebugConsole.java b/client/src/com/vaadin/client/VDebugConsole.java index 331073cd90..0d1c6d89f6 100644 --- a/client/src/com/vaadin/client/VDebugConsole.java +++ b/client/src/com/vaadin/client/VDebugConsole.java @@ -153,7 +153,7 @@ public class VDebugConsole extends VOverlay implements Console { } if (paintable != null) { - a.highlightComponent(paintable); + a.highlightConnector(paintable); return; } } diff --git a/client/src/com/vaadin/client/VUIDLBrowser.java b/client/src/com/vaadin/client/VUIDLBrowser.java index 4f165d6233..6f393b0bb0 100644 --- a/client/src/com/vaadin/client/VUIDLBrowser.java +++ b/client/src/com/vaadin/client/VUIDLBrowser.java @@ -40,7 +40,6 @@ 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.window.VWindow; -import com.vaadin.shared.Connector; /** * TODO Rename to something more Vaadin7-ish? @@ -115,10 +114,22 @@ public class VUIDLBrowser extends SimpleTree { @Override protected void select(ClickEvent event) { - ComponentConnector connector = getConnector(); - highlight(connector); - if (event != null && event.getNativeEvent().getShiftKey()) { - connector.getConnection().highlightComponent(connector); + ServerConnector connector = getConnector(); + + if (connector != null && event != null + && event.getNativeEvent().getShiftKey()) { + connector.getConnection().highlightConnector(connector); + } + + // For connectors that do not have a widget, highlight the widget of + // their ancestor component connector if any + while (connector != null + && !(connector instanceof ComponentConnector)) { + connector = connector.getParent(); + } + if (connector != null) { + ComponentConnector cc = (ComponentConnector) connector; + highlight(cc); } super.select(event); } @@ -126,15 +137,8 @@ public class VUIDLBrowser extends SimpleTree { /** * Returns the Connector associated with this state change. */ - protected ComponentConnector getConnector() { - Connector connector = client.getConnectorMap().getConnector( - getConnectorId()); - - if (connector instanceof ComponentConnector) { - return (ComponentConnector) connector; - } else { - return null; - } + protected ServerConnector getConnector() { + return client.getConnectorMap().getConnector(getConnectorId()); } protected abstract String getConnectorId(); @@ -149,11 +153,11 @@ public class VUIDLBrowser extends SimpleTree { SharedStateItem(String connectorId, ValueMap stateChanges) { this.connectorId = connectorId; - ComponentConnector connector = getConnector(); + ServerConnector connector = getConnector(); if (connector != null) { setText(Util.getConnectorString(connector)); } else { - setText("Unknown connector " + connectorId); + setText("Unknown connector (" + connectorId + ")"); } dir(new JSONObject(stateChanges), this); } diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java index 293fd002e5..7274ff8caf 100644 --- a/server/src/com/vaadin/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java @@ -77,7 +77,6 @@ import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.communication.UidlValue; import com.vaadin.shared.ui.ui.UIConstants; -import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractField; import com.vaadin.ui.Component; import com.vaadin.ui.ConnectorTracker; @@ -162,7 +161,7 @@ public abstract class AbstractCommunicationManager implements Serializable { private int maxInactiveInterval; - private Connector highlightedConnector; + private ClientConnector highlightedConnector; private Map<String, Class<?>> dependencyResourceContexts = new HashMap<String, Class<?>>(); @@ -193,7 +192,7 @@ public abstract class AbstractCommunicationManager implements Serializable { private static final String UTF8 = "UTF8"; - private static final String GET_PARAM_HIGHLIGHT_COMPONENT = "highlightComponent"; + private static final String GET_PARAM_HIGHLIGHT_CONNECTOR = "highlightConnector"; private static String readLine(InputStream stream) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); @@ -558,9 +557,9 @@ public abstract class AbstractCommunicationManager implements Serializable { // analyzing can be done only with repaintAll analyzeLayouts = (request.getParameter(GET_PARAM_ANALYZE_LAYOUTS) != null); - if (request.getParameter(GET_PARAM_HIGHLIGHT_COMPONENT) != null) { + if (request.getParameter(GET_PARAM_HIGHLIGHT_CONNECTOR) != null) { String pid = request - .getParameter(GET_PARAM_HIGHLIGHT_COMPONENT); + .getParameter(GET_PARAM_HIGHLIGHT_CONNECTOR); highlightedConnector = uI.getConnectorTracker().getConnector( pid); highlightConnector(highlightedConnector); @@ -678,59 +677,55 @@ public abstract class AbstractCommunicationManager implements Serializable { } } - protected void highlightConnector(Connector highlightedConnector) { + protected void highlightConnector(ClientConnector highlightedConnector) { StringBuilder sb = new StringBuilder(); - sb.append("*** Debug details of a component: *** \n"); + sb.append("*** Debug details of a connector: *** \n"); sb.append("Type: "); sb.append(highlightedConnector.getClass().getName()); - if (highlightedConnector instanceof AbstractComponent) { - AbstractComponent component = (AbstractComponent) highlightedConnector; - sb.append("\nId:"); - sb.append(highlightedConnector.getConnectorId()); + 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()); } - - printHighlightedComponentHierarchy(sb, component); } + printHighlightedConnectorHierarchy(sb, highlightedConnector); getLogger().info(sb.toString()); } - protected void printHighlightedComponentHierarchy(StringBuilder sb, - AbstractComponent component) { - LinkedList<Component> h = new LinkedList<Component>(); - h.add(component); - Component parent = component.getParent(); + 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("\nComponent hierarchy:\n"); - VaadinServiceSession session2 = component.getUI().getSession(); + sb.append("\nConnector hierarchy:\n"); + VaadinServiceSession session2 = connector.getUI().getSession(); sb.append(session2.getClass().getName()); - sb.append("."); - sb.append(session2.getClass().getSimpleName()); sb.append("("); sb.append(session2.getClass().getSimpleName()); sb.append(".java"); sb.append(":1)"); int l = 1; - for (Component component2 : h) { + for (ClientConnector conector2 : h) { sb.append("\n"); for (int i = 0; i < l; i++) { sb.append(" "); } l++; - Class<? extends Component> componentClass = component2.getClass(); + Class<? extends ClientConnector> componentClass = conector2 + .getClass(); Class<?> topClass = componentClass; while (topClass.getEnclosingClass() != null) { topClass = topClass.getEnclosingClass(); } sb.append(componentClass.getName()); - sb.append("."); - sb.append(componentClass.getSimpleName()); sb.append("("); sb.append(topClass.getSimpleName()); sb.append(".java:1)"); @@ -1320,9 +1315,10 @@ public abstract class AbstractCommunicationManager implements Serializable { Class<?> oldContext = dependencyResourceContexts.get(name); if (oldContext != context) { getLogger().warning( - "Dependency " + name + " defined by both " + context - + " and " + oldContext + ". Dependency from " - + oldContext + " will be used."); + "Dependency " + name + " defined by both " + + context + " and " + oldContext + + ". Dependency from " + oldContext + + " will be used."); } } else { dependencyResourceContexts.put(name, context); |