Browse Source

Only update caption for specific state changes (#11092)

Change-Id: I31dc599f6ce19a0de07a4323b3146c48db0b9d4b
tags/7.0.2
Leif Åstrand 11 years ago
parent
commit
2536863492

+ 4
- 2
client/src/com/vaadin/client/ApplicationConnection.java View 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

+ 24
- 0
client/src/com/vaadin/client/VCaption.java View 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.
*

Loading…
Cancel
Save