]> source.dussan.org Git - vaadin-framework.git/commitdiff
Implemented review comments for #6766
authorJonatan Kronqvist <jonatan.kronqvist@itmill.com>
Mon, 1 Aug 2011 12:39:06 +0000 (12:39 +0000)
committerJonatan Kronqvist <jonatan.kronqvist@itmill.com>
Mon, 1 Aug 2011 12:39:06 +0000 (12:39 +0000)
svn changeset:20063/svn branch:6.7

src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java

index 3a8ff9096f81d335bbcb4d898d781b49d7b71607..d43ee328847b95a926ab30ce080fb936ecb70816 100644 (file)
@@ -682,14 +682,15 @@ public abstract class AbstractCommunicationManager implements
         requestThemeName = request.getParameter("theme");
         maxInactiveInterval = request.getSession().getMaxInactiveInterval();
         // repaint requested or session has timed out and new one is created
+        boolean repaintAll;
         final OutputStream out;
 
-        setRepaintAll(request.getParameter(GET_PARAM_REPAINT_ALL) != null);
+        repaintAll = (request.getParameter(GET_PARAM_REPAINT_ALL) != null);
         // || (request.getSession().isNew()); FIXME What the h*ll is this??
         out = response.getOutputStream();
 
         boolean analyzeLayouts = false;
-        if (isRepaintAll()) {
+        if (repaintAll) {
             // analyzing can be done only with repaintAll
             analyzeLayouts = (request.getParameter(GET_PARAM_ANALYZE_LAYOUTS) != null);
         }
@@ -747,11 +748,11 @@ public abstract class AbstractCommunicationManager implements
                     }
                 }
                 // No message to show, let's just repaint all.
-                setRepaintAll(true);
+                repaintAll = true;
             }
 
-            paintAfterVariableChanges(request, response, callback, outWriter,
-                    window, analyzeLayouts);
+            paintAfterVariableChanges(request, response, callback, repaintAll,
+                    outWriter, window, analyzeLayouts);
 
             if (closingWindowName != null) {
                 currentlyOpenWindowsInClient.remove(closingWindowName);
@@ -769,6 +770,7 @@ public abstract class AbstractCommunicationManager implements
      * @param request
      * @param response
      * @param callback
+     * @param repaintAll
      * @param outWriter
      * @param window
      * @param analyzeLayouts
@@ -776,10 +778,11 @@ public abstract class AbstractCommunicationManager implements
      * @throws IOException
      */
     private void paintAfterVariableChanges(Request request, Response response,
-            Callback callback, final PrintWriter outWriter, Window window,
-            boolean analyzeLayouts) throws PaintException, IOException {
+            Callback callback, boolean repaintAll, final PrintWriter outWriter,
+            Window window, boolean analyzeLayouts) throws PaintException,
+            IOException {
 
-        if (isRepaintAll()) {
+        if (repaintAll) {
             makeAllPaintablesDirty(window);
         }
 
@@ -819,10 +822,11 @@ public abstract class AbstractCommunicationManager implements
                     application, window);
             if (newWindow != window) {
                 window = newWindow;
-                setRepaintAll(true);
+                repaintAll = true;
             }
 
-            writeUidlResponse(callback, outWriter, window, analyzeLayouts);
+            writeUidlResponse(callback, repaintAll, outWriter, window,
+                    analyzeLayouts);
 
         }
         closeJsonMessage(outWriter);
@@ -831,7 +835,7 @@ public abstract class AbstractCommunicationManager implements
 
     }
 
-    public void writeUidlResponse(Callback callback,
+    public void writeUidlResponse(Callback callback, boolean repaintAll,
             final PrintWriter outWriter, Window window, boolean analyzeLayouts)
             throws PaintException {
         outWriter.print("\"changes\":[");
@@ -841,7 +845,7 @@ public abstract class AbstractCommunicationManager implements
         List<InvalidLayout> invalidComponentRelativeSizes = null;
 
         JsonPaintTarget paintTarget = new JsonPaintTarget(this, outWriter,
-                !isRepaintAll());
+                repaintAll);
         OpenWindowCache windowCache = currentlyOpenWindowsInClient.get(window
                 .getName());
         if (windowCache == null) {
@@ -850,7 +854,7 @@ public abstract class AbstractCommunicationManager implements
         }
 
         // Paints components
-        if (isRepaintAll()) {
+        if (repaintAll) {
             paintables = new ArrayList<Paintable>();
             paintables.add(window);
 
@@ -965,7 +969,7 @@ public abstract class AbstractCommunicationManager implements
         outWriter.print(", \"meta\" : {");
         boolean metaOpen = false;
 
-        if (isRepaintAll()) {
+        if (repaintAll) {
             metaOpen = true;
             outWriter.write("\"repaintAll\":true");
             if (analyzeLayouts) {
@@ -1011,7 +1015,7 @@ public abstract class AbstractCommunicationManager implements
                 && ci.getSessionExpiredCaption() == null
                 && ci.isSessionExpiredNotificationEnabled()) {
             int newTimeoutInterval = getTimeoutInterval();
-            if (isRepaintAll() || (timeoutInterval != newTimeoutInterval)) {
+            if (repaintAll || (timeoutInterval != newTimeoutInterval)) {
                 String escapedURL = ci.getSessionExpiredURL() == null ? "" : ci
                         .getSessionExpiredURL().replace("/", "\\/");
                 if (metaOpen) {
@@ -1102,7 +1106,6 @@ public abstract class AbstractCommunicationManager implements
         if (dragAndDropService != null) {
             dragAndDropService.printJSONResponse(outWriter);
         }
-        setRepaintAll(false);
     }
 
     private int getTimeoutInterval() {
@@ -1215,9 +1218,8 @@ public abstract class AbstractCommunicationManager implements
                     final PrintWriter outWriter = new PrintWriter(
                             new CharArrayWriter());
 
-                    setRepaintAll(true);
                     paintAfterVariableChanges(request, response, callback,
-                            outWriter, window, false);
+                            true, outWriter, window, false);
 
                 }
 
@@ -2119,8 +2121,6 @@ public abstract class AbstractCommunicationManager implements
     private final HashMap<Class<? extends Paintable>, Integer> typeToKey = new HashMap<Class<? extends Paintable>, Integer>();
     private int nextTypeKey = 0;
 
-    private boolean repaintAll = false;
-
     String getTagForType(Class<? extends Paintable> class1) {
         Integer object = typeToKey.get(class1);
         if (object == null) {
@@ -2310,16 +2310,4 @@ public abstract class AbstractCommunicationManager implements
             return b;
         }
     }
-
-    private void setRepaintAll(boolean repaintAll) {
-        this.repaintAll = repaintAll;
-    }
-
-    /**
-     * @return true if a RepaintAll has been requested. E.g. by refreshing the
-     *         browser window or such.
-     */
-    public boolean isRepaintAll() {
-        return repaintAll;
-    }
 }
index da7f838bdaf10e3efcab2fc0a700d3610575a5df..cd31d4bbcab01089a2c54fc91d2eac44a0946d7c 100644 (file)
@@ -79,7 +79,7 @@ public class JsonPaintTarget implements PaintTarget {
 
     private int errorsOpen;
 
-    private boolean cacheEnabled = false;
+    private boolean fullRepaint = false;
 
     private final Collection<Paintable> paintedComponents = new HashSet<Paintable>();
 
@@ -94,12 +94,14 @@ public class JsonPaintTarget implements PaintTarget {
      * @param manager
      * @param outWriter
      *            A character-output stream.
+     * @param fullRepaint
+     *            true if this is a full repaint, i.e. caches are to be
+     *            bypassed.
      * @throws PaintException
      *             if the paint operation failed.
      */
     public JsonPaintTarget(AbstractCommunicationManager manager,
-            PrintWriter outWriter, boolean cachingRequired)
-            throws PaintException {
+            PrintWriter outWriter, boolean fullRepaint) throws PaintException {
 
         this.manager = manager;
 
@@ -109,7 +111,7 @@ public class JsonPaintTarget implements PaintTarget {
         // Initialize tag-writing
         mOpenTags = new Stack<String>();
         openJsonTags = new Stack<JsonTag>();
-        cacheEnabled = cachingRequired;
+        this.fullRepaint = fullRepaint;
     }
 
     public void startTag(String tagName) throws PaintException {
@@ -684,7 +686,7 @@ public class JsonPaintTarget implements PaintTarget {
             customLayoutArgumentsOpen = true;
         }
 
-        return cacheEnabled && isPreviouslyPainted;
+        return !fullRepaint && isPreviouslyPainted;
     }
 
     @Deprecated
@@ -1117,7 +1119,7 @@ public class JsonPaintTarget implements PaintTarget {
      * @see com.vaadin.terminal.PaintTarget#isFullRepaint()
      */
     public boolean isFullRepaint() {
-        return manager.isRepaintAll();
+        return fullRepaint;
     }
 
 }