diff options
author | Jouni Koivuviita <jouni@vaadin.com> | 2012-08-20 11:54:09 +0300 |
---|---|---|
committer | Jouni Koivuviita <jouni@vaadin.com> | 2012-08-20 11:54:09 +0300 |
commit | 00d45c6036c876686eb3c1305aa07f748ebc8365 (patch) | |
tree | 023e2e085e036927ae41158a9a2a2300e650f4a1 /shared | |
parent | 450e62cb68aa9d16851cedbc87c3c4769cf2a820 (diff) | |
parent | c9689846a8ba1254fb51c164cee6c3c157740eac (diff) | |
download | vaadin-framework-00d45c6036c876686eb3c1305aa07f748ebc8365.tar.gz vaadin-framework-00d45c6036c876686eb3c1305aa07f748ebc8365.zip |
Merge master
Diffstat (limited to 'shared')
6 files changed, 137 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 diff --git a/shared/src/com/vaadin/shared/ui/root/RootState.java b/shared/src/com/vaadin/shared/ui/root/RootState.java index b7c2c88ce5..07c71c8167 100644 --- a/shared/src/com/vaadin/shared/ui/root/RootState.java +++ b/shared/src/com/vaadin/shared/ui/root/RootState.java @@ -20,6 +20,7 @@ import com.vaadin.shared.Connector; public class RootState extends ComponentState { private Connector content; + private int heartbeatInterval; public Connector getContent() { return content; @@ -29,4 +30,11 @@ public class RootState extends ComponentState { this.content = content; } + public int getHeartbeatInterval() { + return heartbeatInterval; + } + + public void setHeartbeatInterval(int heartbeatInterval) { + this.heartbeatInterval = heartbeatInterval; + } }
\ No newline at end of file |