]> source.dussan.org Git - vaadin-framework.git/commitdiff
Do not unregister open sub windows
authorArtur Signell <artur@vaadin.com>
Wed, 14 Mar 2012 13:34:39 +0000 (15:34 +0200)
committerArtur Signell <artur@vaadin.com>
Wed, 14 Mar 2012 14:01:26 +0000 (16:01 +0200)
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
src/com/vaadin/terminal/gwt/client/VDebugConsole.java
src/com/vaadin/terminal/gwt/client/ui/RootConnector.java

index 66dcd069ab130932ef8d9b2b31c46e12116f91ff..993221262367ea228fee054d5468a4577a685c50 100644 (file)
@@ -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");
                         }
                     }
 
index 0d004dc24b718ad36e6ceb861365aaf6ebf89421..6e2877fa62e637d1a2957f60479eebcaf9cf62be 100644 (file)
@@ -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<? extends ServerConnector> registeredConnectors = connectorMap
                 .getConnectors();
+        log("Sub windows:");
+        Set<ComponentConnector> subWindowHierarchyConnectors = new HashSet<ComponentConnector>();
+        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));
 
         }
index ffe9f7f16bb4f74b04b6267c950909f01cf58e01..c7f445bd134a782378c451180ca75ec40a278c35 100644 (file)
@@ -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());
+    }
+
 }