summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/shared/communication/SharedState.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/vaadin/shared/communication/SharedState.java')
-rw-r--r--src/com/vaadin/shared/communication/SharedState.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/com/vaadin/shared/communication/SharedState.java b/src/com/vaadin/shared/communication/SharedState.java
new file mode 100644
index 0000000000..2882b1ed07
--- /dev/null
+++ b/src/com/vaadin/shared/communication/SharedState.java
@@ -0,0 +1,67 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.shared.communication;
+
+import java.io.Serializable;
+
+import com.vaadin.shared.Connector;
+import com.vaadin.terminal.gwt.client.ServerConnector;
+import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
+
+/**
+ * Interface to be implemented by all shared state classes used to communicate
+ * basic information about a {@link Connector} from server to client.
+ *
+ * Shared state classes have to be declared in client side packages to be
+ * accessible both for server and client code. They can be static nested classes
+ * of a {@link ServerConnector}.
+ *
+ * Shared state objects are only sent from the server to the client, and any
+ * modifications from the client should be performed via an RPC call that
+ * modifies the authoritative state on the server.
+ *
+ * A shared state class should be a bean with getters and setters for each
+ * field. Supported data types are simple Java types, other beans and maps and
+ * arrays of these.
+ *
+ * On the client side the connector should override
+ * {@link AbstractComponentConnector#createState()} to create the correct state
+ * class and {@link AbstractComponentConnector#getState()} override the return
+ * type.
+ *
+ * Subclasses of a {@link Connector} using shared state should also provide a
+ * subclass of the shared state class of the parent class to extend the state. A
+ * single {@link Connector} can only have one shared state object.
+ *
+ * @since 7.0
+ */
+public class SharedState implements Serializable {
+
+ private boolean enabled = true;
+
+ /**
+ * Returns true if the component is enabled.
+ *
+ * @see com.vaadin.ui.Component#isEnabled()
+ *
+ * @return true if the component is enabled
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * Enables or disables the component.
+ *
+ * @see com.vaadin.ui.Component#setEnabled(boolean)
+ *
+ * @param enabled
+ * new mode for the component
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+}