You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SharedState.java 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.shared.communication;
  5. import java.io.Serializable;
  6. import com.vaadin.shared.Connector;
  7. import com.vaadin.terminal.gwt.client.ServerConnector;
  8. import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
  9. /**
  10. * Interface to be implemented by all shared state classes used to communicate
  11. * basic information about a {@link Connector} from server to client.
  12. *
  13. * Shared state classes have to be declared in client side packages to be
  14. * accessible both for server and client code. They can be static nested classes
  15. * of a {@link ServerConnector}.
  16. *
  17. * Shared state objects are only sent from the server to the client, and any
  18. * modifications from the client should be performed via an RPC call that
  19. * modifies the authoritative state on the server.
  20. *
  21. * A shared state class should be a bean with getters and setters for each
  22. * field. Supported data types are simple Java types, other beans and maps and
  23. * arrays of these.
  24. *
  25. * On the client side the connector should override
  26. * {@link AbstractComponentConnector#createState()} to create the correct state
  27. * class and {@link AbstractComponentConnector#getState()} override the return
  28. * type.
  29. *
  30. * Subclasses of a {@link Connector} using shared state should also provide a
  31. * subclass of the shared state class of the parent class to extend the state. A
  32. * single {@link Connector} can only have one shared state object.
  33. *
  34. * @since 7.0
  35. */
  36. public class SharedState implements Serializable {
  37. private boolean enabled = true;
  38. /**
  39. * Returns true if the component is enabled.
  40. *
  41. * @see com.vaadin.ui.Component#isEnabled()
  42. *
  43. * @return true if the component is enabled
  44. */
  45. public boolean isEnabled() {
  46. return enabled;
  47. }
  48. /**
  49. * Enables or disables the component.
  50. *
  51. * @see com.vaadin.ui.Component#setEnabled(boolean)
  52. *
  53. * @param enabled
  54. * new mode for the component
  55. */
  56. public void setEnabled(boolean enabled) {
  57. this.enabled = enabled;
  58. }
  59. }