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.

AbstractFieldState.java 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.shared;
  5. import com.vaadin.shared.ui.TabIndexState;
  6. /**
  7. * Shared state for {@link com.vaadin.ui.AbstractField}.
  8. *
  9. * @author Vaadin Ltd
  10. * @version @VERSION@
  11. * @since 7.0.0
  12. *
  13. */
  14. public class AbstractFieldState extends ComponentState implements TabIndexState {
  15. private boolean propertyReadOnly = false;
  16. private boolean hideErrors = false;
  17. private boolean required = false;
  18. private boolean modified = false;
  19. /**
  20. * The tab order number of this field.
  21. */
  22. private int tabIndex = 0;
  23. /**
  24. * Checks if the property data source for the Field is in read only mode.
  25. * This affects the read only state of the field itself.
  26. *
  27. * @return true if there is a property data source and it is set to read
  28. * only, false otherwise
  29. */
  30. public boolean isPropertyReadOnly() {
  31. return propertyReadOnly;
  32. }
  33. /**
  34. * Sets the read only state of the property data source.
  35. *
  36. * @param propertyReadOnly
  37. * true if the property data source if read only, false otherwise
  38. */
  39. public void setPropertyReadOnly(boolean propertyReadOnly) {
  40. this.propertyReadOnly = propertyReadOnly;
  41. }
  42. /**
  43. * Returns true if the component will hide any errors even if the error
  44. * message is set.
  45. *
  46. * @return true if error messages are disabled
  47. */
  48. public boolean isHideErrors() {
  49. return hideErrors;
  50. }
  51. /**
  52. * Sets whether the component should hide any errors even if the error
  53. * message is set.
  54. *
  55. * This is used e.g. on forms to hide error messages for invalid fields
  56. * before the first user actions.
  57. *
  58. * @param hideErrors
  59. * true if error messages should be hidden
  60. */
  61. public void setHideErrors(boolean hideErrors) {
  62. this.hideErrors = hideErrors;
  63. }
  64. /**
  65. * Is the field required. Required fields must filled by the user.
  66. *
  67. * See {@link com.vaadin.ui.AbstractField#isRequired()} for more
  68. * information.
  69. *
  70. * @return <code>true</code> if the field is required, otherwise
  71. * <code>false</code>.
  72. */
  73. public boolean isRequired() {
  74. return required;
  75. }
  76. /**
  77. * Sets the field required. Required fields must filled by the user.
  78. *
  79. * See {@link com.vaadin.ui.AbstractField#setRequired(boolean)} for more
  80. * information.
  81. *
  82. * @param required
  83. * Is the field required.
  84. */
  85. public void setRequired(boolean required) {
  86. this.required = required;
  87. }
  88. /**
  89. * Has the contents of the field been modified, i.e. has the value been
  90. * updated after it was read from the data source.
  91. *
  92. * @return true if the field has been modified, false otherwise
  93. */
  94. public boolean isModified() {
  95. return modified;
  96. }
  97. /**
  98. * Setter for the modified flag, toggled when the contents of the field is
  99. * modified by the user.
  100. *
  101. * @param modified
  102. * the new modified state
  103. *
  104. */
  105. public void setModified(boolean modified) {
  106. this.modified = modified;
  107. }
  108. /*
  109. * (non-Javadoc)
  110. *
  111. * @see com.vaadin.terminal.gwt.client.ComponentState#getTabIndex()
  112. */
  113. @Override
  114. public int getTabIndex() {
  115. return tabIndex;
  116. }
  117. /*
  118. * (non-Javadoc)
  119. *
  120. * @see com.vaadin.terminal.gwt.client.ui.TabIndexState#setTabIndex(int)
  121. */
  122. @Override
  123. public void setTabIndex(int tabIndex) {
  124. this.tabIndex = tabIndex;
  125. }
  126. }