From ceda855ab44ffe2330e639b1e0f51a5152602c42 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 16 Mar 2012 17:42:06 +0200 Subject: [PATCH] Cleaned up code related to storing which type mappings have already been sent to the client --- .../server/AbstractCommunicationManager.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 0a4231941a..6a5bcce7d7 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -131,7 +131,7 @@ public abstract class AbstractCommunicationManager implements public static final char VAR_ESCAPE_CHARACTER = '\u001b'; - private final HashMap currentlyOpenWindowsInClient = new HashMap(); + private final HashMap rootToClientCache = new HashMap(); private static final int MAX_BUFFER_SIZE = 64 * 1024; @@ -799,13 +799,7 @@ public abstract class AbstractCommunicationManager implements JsonPaintTarget paintTarget = new JsonPaintTarget(this, outWriter, !repaintAll); - OpenWindowCache windowCache = currentlyOpenWindowsInClient.get(Integer - .valueOf(root.getRootId())); - if (windowCache == null) { - windowCache = new OpenWindowCache(); - currentlyOpenWindowsInClient.put(Integer.valueOf(root.getRootId()), - windowCache); - } + ClientCache clientCache = getClientCache(root); // TODO These seem unnecessary and could be removed/replaced by looping // through paintQueue without removing paintables from it @@ -1130,7 +1124,7 @@ public abstract class AbstractCommunicationManager implements .getUsedPaintableTypes(); boolean typeMappingsOpen = false; for (Class class1 : usedPaintableTypes) { - if (windowCache.cache(class1)) { + if (clientCache.cache(class1)) { // client does not know the mapping key for this type, send // mapping to client if (!typeMappingsOpen) { @@ -1158,6 +1152,16 @@ public abstract class AbstractCommunicationManager implements } } + private ClientCache getClientCache(Root root) { + Integer rootId = Integer.valueOf(root.getRootId()); + ClientCache cache = rootToClientCache.get(rootId); + if (cache == null) { + cache = new ClientCache(); + rootToClientCache.put(rootId, cache); + } + return cache; + } + private boolean isVisible(Component child) { HasComponents parent = child.getParent(); if (parent == null || !child.isVisible()) { @@ -1269,11 +1273,7 @@ public abstract class AbstractCommunicationManager implements } } // clean WindowCache - OpenWindowCache openWindowCache = currentlyOpenWindowsInClient - .get(Integer.valueOf(root.getRootId())); - if (openWindowCache != null) { - openWindowCache.clear(); - } + getClientCache(root).clear(); } /** @@ -2191,7 +2191,7 @@ public abstract class AbstractCommunicationManager implements * * TODO make customlayout templates (from theme) to be cached here. */ - class OpenWindowCache implements Serializable { + class ClientCache implements Serializable { private final Set res = new HashSet(); -- 2.39.5