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.

ComponentState.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client;
  5. import com.vaadin.terminal.gwt.client.communication.SharedState;
  6. /**
  7. * Default shared state implementation for UI components.
  8. *
  9. * State classes of concrete components should extend this class.
  10. *
  11. * @since 7.0
  12. */
  13. public class ComponentState extends SharedState {
  14. private String height = "";
  15. private String width = "";
  16. /**
  17. * Returns the component height as set by the server.
  18. *
  19. * Can be relative (containing the percent sign) or absolute, or empty
  20. * string for undefined height.
  21. *
  22. * @return component height as defined by the server, not null
  23. */
  24. public String getHeight() {
  25. if (height == null) {
  26. return "";
  27. }
  28. return height;
  29. }
  30. /**
  31. * Sets the height of the component in the server format.
  32. *
  33. * Can be relative (containing the percent sign) or absolute, or null or
  34. * empty string for undefined height.
  35. *
  36. * @param height
  37. * component height
  38. */
  39. public void setHeight(String height) {
  40. this.height = height;
  41. }
  42. /**
  43. * Returns true if the component height is undefined, false if defined
  44. * (absolute or relative).
  45. *
  46. * @return true if component height is undefined
  47. */
  48. public boolean isUndefinedHeight() {
  49. return "".equals(getHeight());
  50. }
  51. /**
  52. * Returns the component width as set by the server.
  53. *
  54. * Can be relative (containing the percent sign) or absolute, or empty
  55. * string for undefined height.
  56. *
  57. * @return component width as defined by the server, not null
  58. */
  59. public String getWidth() {
  60. if (width == null) {
  61. return "";
  62. }
  63. return width;
  64. }
  65. /**
  66. * Sets the width of the component in the server format.
  67. *
  68. * Can be relative (containing the percent sign) or absolute, or null or
  69. * empty string for undefined width.
  70. *
  71. * @param width
  72. * component width
  73. */
  74. public void setWidth(String width) {
  75. this.width = width;
  76. }
  77. /**
  78. * Returns true if the component width is undefined, false if defined
  79. * (absolute or relative).
  80. *
  81. * @return true if component width is undefined
  82. */
  83. public boolean isUndefinedWidth() {
  84. return "".equals(getWidth());
  85. }
  86. // TODO more fields to move here: style, readonly, immediate, disabled,
  87. // caption and description
  88. }