]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added isInitialStateChange to StateChangeEvent (#10477)
authorArtur Signell <artur@vaadin.com>
Wed, 22 May 2013 13:44:01 +0000 (16:44 +0300)
committerVaadin Code Review <review@vaadin.com>
Wed, 22 May 2013 15:11:28 +0000 (15:11 +0000)
Change-Id: I6b9fb8a664974b68b35050a40ba19bce440b6b3c

client/src/com/vaadin/client/communication/StateChangeEvent.java
client/src/com/vaadin/client/ui/AbstractComponentConnector.java

index e17a56aa69b4c3d242fffcf317e88d5713343c61..e8fd95e8182501d0290b37e9292f066431f53db3 100644 (file)
@@ -52,7 +52,7 @@ public class StateChangeEvent extends
     @Deprecated
     private Set<String> 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
      *            <code>true</code> if the state change is for a new connector,
      *            otherwise <code>false</code>
      */
     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
      *         <code>false></code>
      */
     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;
+    }
+
 }
index 13d1e6d56cc5636ab3df01e209db6f300fdb2f47..ebc80c47288649565ea9c95a1cb5aea0fc74d96e 100644 (file)
@@ -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");
     }