]> source.dussan.org Git - vaadin-framework.git/commitdiff
Only update caption for specific state changes (#11092)
authorLeif Åstrand <leif@vaadin.com>
Wed, 20 Feb 2013 14:49:43 +0000 (16:49 +0200)
committerLeif Åstrand <leif@vaadin.com>
Wed, 20 Feb 2013 14:50:42 +0000 (16:50 +0200)
Change-Id: I31dc599f6ce19a0de07a4323b3146c48db0b9d4b

client/src/com/vaadin/client/ApplicationConnection.java
client/src/com/vaadin/client/VCaption.java

index 8ecc90bdd520f8be6459225fbd811d958bd6c7e0..8f71d15c63750243a6034137bf2ced9e4878f478 100644 (file)
@@ -1574,8 +1574,10 @@ public class ApplicationConnection {
 
                 // Find components with potentially changed caption state
                 for (StateChangeEvent event : pendingStateChangeEvents) {
-                    ServerConnector connector = event.getConnector();
-                    needsCaptionUpdate.add(connector);
+                    if (VCaption.mightChange(event)) {
+                        ServerConnector connector = event.getConnector();
+                        needsCaptionUpdate.add(connector.getConnectorId());
+                    }
                 }
 
                 // Update captions for all suitable candidates
index efa9be18509c6b5a1af9b993f752d2cc6ed1bbee..47287636c47ec597fc70c2c2689a0a09339c461f 100644 (file)
@@ -20,6 +20,7 @@ import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.ui.HTML;
+import com.vaadin.client.communication.StateChangeEvent;
 import com.vaadin.client.ui.AbstractFieldConnector;
 import com.vaadin.client.ui.Icon;
 import com.vaadin.shared.AbstractComponentState;
@@ -407,6 +408,29 @@ public class VCaption extends HTML {
         return false;
     }
 
+    /**
+     * Checks whether anything in a given state change might cause the caption
+     * to change.
+     * 
+     * @param event
+     *            the state change event to check
+     * @return <code>true</code> if the caption might have changed; otherwise
+     *         <code>false</code>
+     */
+    public static boolean mightChange(StateChangeEvent event) {
+        if (event.hasPropertyChanged("caption")) {
+            return true;
+        }
+        if (event.hasPropertyChanged("resources")) {
+            return true;
+        }
+        if (event.hasPropertyChanged("errorMessage")) {
+            return true;
+        }
+
+        return false;
+    }
+
     /**
      * Returns Paintable for which this Caption belongs to.
      *