summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-05-22 16:44:01 +0300
committerVaadin Code Review <review@vaadin.com>2013-05-22 15:11:28 +0000
commit9686323c4ae29a708ea0a5e8cf39b60881d6f7ba (patch)
treef5e485801cea716c5193597beaea2d0b017a8182
parent05ef43f8bfccbe1cbb0e48a0a96204a0485c3f49 (diff)
downloadvaadin-framework-9686323c4ae29a708ea0a5e8cf39b60881d6f7ba.tar.gz
vaadin-framework-9686323c4ae29a708ea0a5e8cf39b60881d6f7ba.zip
Added isInitialStateChange to StateChangeEvent (#10477)
Change-Id: I6b9fb8a664974b68b35050a40ba19bce440b6b3c
-rw-r--r--client/src/com/vaadin/client/communication/StateChangeEvent.java25
-rw-r--r--client/src/com/vaadin/client/ui/AbstractComponentConnector.java6
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<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;
+ }
+
}
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");
}