From: Artur Signell Date: Wed, 14 Mar 2012 13:34:39 +0000 (+0200) Subject: Do not unregister open sub windows X-Git-Tag: 7.0.0.alpha2~321 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dbb870ec699e98d86cc94be6f2a045f68780f09a;p=vaadin-framework.git Do not unregister open sub windows --- diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 66dcd069ab..9932212623 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -48,6 +48,7 @@ import com.vaadin.terminal.gwt.client.ui.RootConnector; import com.vaadin.terminal.gwt.client.ui.VContextMenu; import com.vaadin.terminal.gwt.client.ui.VNotification; import com.vaadin.terminal.gwt.client.ui.VNotification.HideEvent; +import com.vaadin.terminal.gwt.client.ui.WindowConnector; import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager; import com.vaadin.terminal.gwt.server.AbstractCommunicationManager; @@ -1098,17 +1099,23 @@ public class ApplicationConnection { for (ServerConnector c : currentConnectors) { if (c instanceof ComponentConnector) { ComponentConnector cc = (ComponentConnector) c; - if (cc.getParent() == null - && !(cc instanceof RootConnector)) { + if (cc.getParent() != null) { + if (!cc.getParent().getChildren().contains(cc)) { + VConsole.error("ERROR: Connector is connected to a parent but the parent does not contain the connector"); + } + } else if ((cc instanceof RootConnector && cc == getView())) { + // RootConnector for this connection, leave as-is + } else if (cc instanceof WindowConnector + && getView().hasSubWindow((WindowConnector) cc)) { + // Sub window attached to this RootConnector, leave + // as-is + } else { // The connector has been detached from the // hierarchy, unregister it and any possible // children. The RootConnector should never be // unregistered even though it has no parent. connectorMap.unregisterConnector(cc); unregistered++; - } else if (cc.getParent() != null - && !cc.getParent().getChildren().contains(cc)) { - VConsole.error("ERROR: Connector is connected to a parent but the parent does not contain the connector"); } } diff --git a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java index 0d004dc24b..6e2877fa62 100644 --- a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java +++ b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java @@ -51,6 +51,7 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ui.RootConnector; import com.vaadin.terminal.gwt.client.ui.VLazyExecutor; import com.vaadin.terminal.gwt.client.ui.VOverlay; +import com.vaadin.terminal.gwt.client.ui.VWindow; /** * A helper console for client side development. The debug console can also be @@ -659,8 +660,7 @@ public class VDebugConsole extends VOverlay implements Console { actions.add(analyzeLayout); actions.add(highlight); actions.add(connectorStats); - connectorStats - .setTitle("Show connector statistics for client"); + connectorStats.setTitle("Show connector statistics for client"); highlight .setTitle("Select a component and print details about it to the server log and client side console."); actions.add(savePosition); @@ -821,6 +821,12 @@ public class VDebugConsole extends VOverlay implements Console { ConnectorMap connectorMap = a.getConnectorMap(); Collection registeredConnectors = connectorMap .getConnectors(); + log("Sub windows:"); + Set subWindowHierarchyConnectors = new HashSet(); + for (VWindow w : root.getWidget().getSubWindowList()) { + dumpConnectorHierarchy(connectorMap.getConnector(w), "", + subWindowHierarchyConnectors); + } log("Registered connectors not in hierarchy (should be empty):"); for (ServerConnector registeredConnector : registeredConnectors) { @@ -828,6 +834,9 @@ public class VDebugConsole extends VOverlay implements Console { continue; } + if (subWindowHierarchyConnectors.contains(registeredConnector)) { + continue; + } error(getConnectorString(registeredConnector)); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/RootConnector.java b/src/com/vaadin/terminal/gwt/client/ui/RootConnector.java index ffe9f7f16b..c7f445bd13 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/RootConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/RootConnector.java @@ -338,4 +338,17 @@ public class RootConnector extends AbstractComponentContainerConnector } } + /** + * Checks if the given sub window is a child of this Root Connector + * + * @deprecated Should be replaced by a more generic mechanism for getting + * non-ComponentConnector children + * @param wc + * @return + */ + @Deprecated + public boolean hasSubWindow(WindowConnector wc) { + return getWidget().subWindows.contains(wc.getWidget()); + } + }