summaryrefslogtreecommitdiffstats
path: root/shared
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-08-20 08:53:33 +0300
committerLeif Åstrand <leif@vaadin.com>2012-08-20 08:53:33 +0300
commit890356e6ab17661364a04d60ded9fe01628b0830 (patch)
treef602189d4f3f47e1026f7327eb4324e89b3c5a9d /shared
parente69c4908ba61b1fd09f0b50ecbc2e0ec11cd06f5 (diff)
downloadvaadin-framework-890356e6ab17661364a04d60ded9fe01628b0830.tar.gz
vaadin-framework-890356e6ab17661364a04d60ded9fe01628b0830.zip
Support @Delayable and change window size update to use it (#8421)
Diffstat (limited to 'shared')
-rw-r--r--shared/src/com/vaadin/shared/annotations/Delayed.java54
-rw-r--r--shared/src/com/vaadin/shared/communication/LegacyChangeVariablesInvocation.java57
-rw-r--r--shared/src/com/vaadin/shared/communication/MethodInvocation.java14
-rw-r--r--shared/src/com/vaadin/shared/ui/root/RootConstants.java4
-rw-r--r--shared/src/com/vaadin/shared/ui/root/RootServerRpc.java5
5 files changed, 129 insertions, 5 deletions
diff --git a/shared/src/com/vaadin/shared/annotations/Delayed.java b/shared/src/com/vaadin/shared/annotations/Delayed.java
new file mode 100644
index 0000000000..706ffc1c53
--- /dev/null
+++ b/shared/src/com/vaadin/shared/annotations/Delayed.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.shared.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+import com.vaadin.shared.communication.ServerRpc;
+
+/**
+ * Invoking a method in a {@link ServerRpc} interface marked with this
+ * annotation will only add the invocation to a queue of outgoing RPC
+ * invocations, but it will not cause the queue to be purged and sent to the
+ * server. The queue will instead be sent when any RPC method not marked as @Delayed
+ * has been invoked.
+ *
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0.0
+ */
+@Target(ElementType.METHOD)
+@Documented
+public @interface Delayed {
+ /**
+ * By setting lastonly to <code>true</code>, any previous invocations of the
+ * same method will be removed from the queue when a new invocation is
+ * added. This can be used in cases where only the last value is of
+ * interest.
+ * <p>
+ * The default value is <code>false</code> which means that invoking the
+ * method multiple times will cause multiple invocations to be enqueued and
+ * eventually sent to the server.
+ *
+ * @return <code>true</code> if only the last invocation of the annotated
+ * method should be sent to the server, <code>false</code> if all
+ * enqueued invocations should be sent.
+ */
+ public boolean lastonly() default false;
+}
diff --git a/shared/src/com/vaadin/shared/communication/LegacyChangeVariablesInvocation.java b/shared/src/com/vaadin/shared/communication/LegacyChangeVariablesInvocation.java
new file mode 100644
index 0000000000..2ffc56dd71
--- /dev/null
+++ b/shared/src/com/vaadin/shared/communication/LegacyChangeVariablesInvocation.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.shared.communication;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.vaadin.shared.ApplicationConstants;
+
+public class LegacyChangeVariablesInvocation extends MethodInvocation {
+ private Map<String, Object> variableChanges = new HashMap<String, Object>();
+
+ public LegacyChangeVariablesInvocation(String connectorId,
+ String variableName, Object value) {
+ super(connectorId, ApplicationConstants.UPDATE_VARIABLE_INTERFACE,
+ ApplicationConstants.UPDATE_VARIABLE_METHOD, new Object[] {
+ variableName, new UidlValue(value) });
+ setVariableChange(variableName, value);
+ }
+
+ public static boolean isLegacyVariableChange(String interfaceName,
+ String methodName) {
+ return ApplicationConstants.UPDATE_VARIABLE_METHOD
+ .equals(interfaceName)
+ && ApplicationConstants.UPDATE_VARIABLE_METHOD
+ .equals(methodName);
+ }
+
+ public void setVariableChange(String name, Object value) {
+ variableChanges.put(name, value);
+ }
+
+ public Map<String, Object> getVariableChanges() {
+ return variableChanges;
+ }
+
+ @Override
+ public String getLastonlyTag() {
+ assert variableChanges.size() == 1;
+ return super.getLastonlyTag()
+ + variableChanges.keySet().iterator().next();
+ }
+
+}
diff --git a/shared/src/com/vaadin/shared/communication/MethodInvocation.java b/shared/src/com/vaadin/shared/communication/MethodInvocation.java
index 720ce09fcb..c4da937c27 100644
--- a/shared/src/com/vaadin/shared/communication/MethodInvocation.java
+++ b/shared/src/com/vaadin/shared/communication/MethodInvocation.java
@@ -71,4 +71,18 @@ public class MethodInvocation implements Serializable {
+ Arrays.toString(parameters) + ")";
}
+ /**
+ * Gets a String tag that is used to uniquely identify previous method
+ * invocations that should be purged from the queue if
+ * <code>{@literal @}Delay(lastonly = true)</code> is used.
+ * <p>
+ * The returned string should contain at least one non-number char to ensure
+ * it doesn't collide with the keys used for invocations without lastonly.
+ *
+ * @return a string identifying this method invocation
+ */
+ public String getLastonlyTag() {
+ return connectorId + "-" + getInterfaceName() + "-" + getMethodName();
+ }
+
} \ No newline at end of file
diff --git a/shared/src/com/vaadin/shared/ui/root/RootConstants.java b/shared/src/com/vaadin/shared/ui/root/RootConstants.java
index bc4f6017f6..34c17ac71f 100644
--- a/shared/src/com/vaadin/shared/ui/root/RootConstants.java
+++ b/shared/src/com/vaadin/shared/ui/root/RootConstants.java
@@ -21,12 +21,8 @@ public class RootConstants {
*/
@Deprecated
public static final String RESIZE_LAZY = "rL";
- @Deprecated
- public static final String BROWSER_HEIGHT_VAR = "browserHeight";
@Deprecated
- public static final String BROWSER_WIDTH_VAR = "browserWidth";
- @Deprecated
public static final String NOTIFICATION_HTML_CONTENT_NOT_ALLOWED = "useplain";
@Deprecated
diff --git a/shared/src/com/vaadin/shared/ui/root/RootServerRpc.java b/shared/src/com/vaadin/shared/ui/root/RootServerRpc.java
index f074a8d3cc..df2031f7d5 100644
--- a/shared/src/com/vaadin/shared/ui/root/RootServerRpc.java
+++ b/shared/src/com/vaadin/shared/ui/root/RootServerRpc.java
@@ -15,9 +15,12 @@
*/
package com.vaadin.shared.ui.root;
+import com.vaadin.shared.annotations.Delayed;
import com.vaadin.shared.communication.ServerRpc;
import com.vaadin.shared.ui.ClickRpc;
public interface RootServerRpc extends ClickRpc, ServerRpc {
-
+ @Delayed(lastonly = true)
+ public void resize(int viewWidth, int viewHeight, int windowWidth,
+ int windowHeight);
} \ No newline at end of file