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.5KB

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