]> source.dussan.org Git - vaadin-framework.git/commitdiff
Remove Root.getName
authorLeif Åstrand <leif@vaadin.com>
Wed, 16 Nov 2011 09:05:41 +0000 (11:05 +0200)
committerLeif Åstrand <leif@vaadin.com>
Wed, 16 Nov 2011 09:05:41 +0000 (11:05 +0200)
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
src/com/vaadin/ui/Root.java

index f7eaa9f2ac12e3dd0b16a8bc06d002250ff34808..2823fd0e8f29af4eb5a251af46cbb6cddae6e868 100644 (file)
@@ -146,7 +146,7 @@ public abstract class AbstractCommunicationManager implements
 
     public static final char VAR_ESCAPE_CHARACTER = '\u001b';
 
-    private final HashMap<String, OpenWindowCache> currentlyOpenWindowsInClient = new HashMap<String, OpenWindowCache>();
+    private final HashMap<Integer, OpenWindowCache> currentlyOpenWindowsInClient = new HashMap<Integer, OpenWindowCache>();
 
     private static final int MAX_BUFFER_SIZE = 64 * 1024;
 
@@ -165,10 +165,6 @@ public abstract class AbstractCommunicationManager implements
 
     private final Application application;
 
-    // Note that this is only accessed from synchronized block and
-    // thus should be thread-safe.
-    private String closingWindowName = null;
-
     private List<String> locales;
 
     private int pendingLocalesIndex;
@@ -181,8 +177,6 @@ public abstract class AbstractCommunicationManager implements
 
     private int maxInactiveInterval;
 
-    private static int nextUnusedWindowSuffix = 1;
-
     /**
      * TODO New constructor - document me!
      * 
@@ -611,10 +605,6 @@ public abstract class AbstractCommunicationManager implements
             paintAfterVariableChanges(request, response, callback, repaintAll,
                     outWriter, root, analyzeLayouts);
 
-            if (closingWindowName != null) {
-                currentlyOpenWindowsInClient.remove(closingWindowName);
-                closingWindowName = null;
-            }
         }
 
         outWriter.close();
@@ -728,23 +718,8 @@ public abstract class AbstractCommunicationManager implements
             outWriter.print("\",");
         }
 
-        // If the browser-window has been closed - we do not need to paint it at
-        // all
-        if (root.getName().equals(closingWindowName)) {
-            outWriter.print("\"changes\":[]");
-        } else {
-            // re-get window - may have been changed
-            Root newRoot = getApplicationRoot(request, callback, application,
-                    root);
-            if (newRoot != root) {
-                root = newRoot;
-                repaintAll = true;
-            }
-
-            writeUidlResponce(callback, repaintAll, outWriter, root,
-                    analyzeLayouts);
+        writeUidlResponce(callback, repaintAll, outWriter, root, analyzeLayouts);
 
-        }
         closeJsonMessage(outWriter);
 
         outWriter.close();
@@ -762,11 +737,12 @@ public abstract class AbstractCommunicationManager implements
 
         JsonPaintTarget paintTarget = new JsonPaintTarget(this, outWriter,
                 !repaintAll);
-        OpenWindowCache windowCache = currentlyOpenWindowsInClient.get(root
-                .getName());
+        OpenWindowCache windowCache = currentlyOpenWindowsInClient.get(Integer
+                .valueOf(application.getRootId(root)));
         if (windowCache == null) {
             windowCache = new OpenWindowCache();
-            currentlyOpenWindowsInClient.put(root.getName(), windowCache);
+            currentlyOpenWindowsInClient.put(
+                    Integer.valueOf(application.getRootId(root)), windowCache);
         }
 
         // Paints components
@@ -1062,8 +1038,8 @@ public abstract class AbstractCommunicationManager implements
             }
         }
         // clean WindowCache
-        OpenWindowCache openWindowCache = currentlyOpenWindowsInClient.get(root
-                .getName());
+        OpenWindowCache openWindowCache = currentlyOpenWindowsInClient
+                .get(Integer.valueOf(application.getRootId(root)));
         if (openWindowCache != null) {
             openWindowCache.clear();
         }
@@ -1155,7 +1131,7 @@ public abstract class AbstractCommunicationManager implements
          * we don't have the required logic implemented on the server side. E.g.
          * a component is removed in a previous burst.
          */
-        return success || closingWindowName != null;
+        return success;
     }
 
     public boolean handleVariableBurst(Object source, Application app,
@@ -1215,7 +1191,8 @@ public abstract class AbstractCommunicationManager implements
                     if (owner instanceof Root) {
                         final Boolean close = (Boolean) m.get("close");
                         if (close != null && close.booleanValue()) {
-                            closingWindowName = ((Root) owner).getName();
+                            throw new RuntimeException(
+                                    "Ensure currentlyOpenWindowsInClient is cleaned up here!");
                         }
                     }
                 } catch (Exception e) {
index e23aa9cd55d485617241e2f6ceed325095038b27..f54ea2ccbf25880d77906729a388c0ff5ec8e58b 100644 (file)
@@ -190,10 +190,6 @@ public class Root extends AbstractComponentContainer {
         return Collections.singleton((Component) getContent()).iterator();
     }
 
-    public String getName() {
-        return "";
-    }
-
     public Terminal getTerminal() {
         return terminal;
     }