From 9686323c4ae29a708ea0a5e8cf39b60881d6f7ba Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 22 May 2013 16:44:01 +0300 Subject: [PATCH] Added isInitialStateChange to StateChangeEvent (#10477) Change-Id: I6b9fb8a664974b68b35050a40ba19bce440b6b3c --- .../communication/StateChangeEvent.java | 25 ++++++++++++++----- .../client/ui/AbstractComponentConnector.java | 6 +---- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/client/src/com/vaadin/client/communication/StateChangeEvent.java b/client/src/com/vaadin/client/communication/StateChangeEvent.java index e17a56aa69..e8fd95e818 100644 --- a/client/src/com/vaadin/client/communication/StateChangeEvent.java +++ b/client/src/com/vaadin/client/communication/StateChangeEvent.java @@ -52,7 +52,7 @@ public class StateChangeEvent extends @Deprecated private Set changedPropertiesSet; - private boolean isNewConnector = false; + private boolean initialStateChange = false; private JSONObject stateJson; @@ -110,15 +110,15 @@ public class StateChangeEvent extends * the event whose state has changed * @param stateJson * the JSON representation of the state change - * @param isNewConnector + * @param initialStateChange * true if the state change is for a new connector, * otherwise false */ public StateChangeEvent(ServerConnector connector, JSONObject stateJson, - boolean isNewConnector) { + boolean initialStateChange) { setConnector(connector); this.stateJson = stateJson; - this.isNewConnector = isNewConnector; + this.initialStateChange = initialStateChange; } @Override @@ -178,7 +178,7 @@ public class StateChangeEvent extends changedProperties = FastStringSet.create(); addJsonFields(stateJson, changedProperties, ""); - if (isNewConnector) { + if (isInitialStateChange()) { addAllStateFields( AbstractConnector.getStateType(getConnector()), changedProperties, ""); @@ -198,7 +198,7 @@ public class StateChangeEvent extends * false> */ public boolean hasPropertyChanged(String property) { - if (isNewConnector) { + if (isInitialStateChange()) { // Everything has changed for a new connector return true; } else if (stateJson != null) { @@ -309,4 +309,17 @@ public class StateChangeEvent extends } } } + + /** + * Checks if the state change event is the first one for the given + * connector. + * + * @since 7.1 + * @return true if this is the first state change event for the connector, + * false otherwise + */ + public boolean isInitialStateChange() { + return initialStateChange; + } + } diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java index 13d1e6d56c..ebc80c4728 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java @@ -51,8 +51,6 @@ public abstract class AbstractComponentConnector extends AbstractConnector private String lastKnownWidth = ""; private String lastKnownHeight = ""; - private boolean initialStateEvent = true; - private boolean tooltipListenersAttached = false; /** @@ -124,7 +122,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector if (stateChangeEvent.hasPropertyChanged("id")) { if (getState().id != null) { getWidget().getElement().setId(getState().id); - } else if (!initialStateEvent) { + } else if (!stateChangeEvent.isInitialStateChange()) { getWidget().getElement().removeAttribute("id"); } } @@ -175,8 +173,6 @@ public abstract class AbstractComponentConnector extends AbstractConnector } Profiler.leave("AbstractComponentContainer.onStateChanged check tooltip"); - initialStateEvent = false; - Profiler.leave("AbstractComponentConnector.onStateChanged"); } -- 2.39.5