From 253686349291d7d808bc9c47bc7dbd604ddc4ff1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Wed, 20 Feb 2013 16:49:43 +0200 Subject: [PATCH] Only update caption for specific state changes (#11092) Change-Id: I31dc599f6ce19a0de07a4323b3146c48db0b9d4b --- .../vaadin/client/ApplicationConnection.java | 6 +++-- client/src/com/vaadin/client/VCaption.java | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 8ecc90bdd5..8f71d15c63 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -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 diff --git a/client/src/com/vaadin/client/VCaption.java b/client/src/com/vaadin/client/VCaption.java index efa9be1850..47287636c4 100644 --- a/client/src/com/vaadin/client/VCaption.java +++ b/client/src/com/vaadin/client/VCaption.java @@ -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 true if the caption might have changed; otherwise + * false + */ + 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. * -- 2.39.5