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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.v7.ui;
  17. import com.vaadin.data.HasRequired;
  18. import com.vaadin.data.HasValue.ValueChange;
  19. import com.vaadin.ui.Component;
  20. import com.vaadin.ui.Component.Focusable;
  21. import com.vaadin.v7.data.BufferedValidatable;
  22. import com.vaadin.v7.data.Property;
  23. /**
  24. * LegacyField interface is implemented by all legacy field components that have
  25. * a value that the user can change through the user interface.
  26. *
  27. * LegacyField components are built upon the framework defined in the
  28. * LegacyField interface and the {@link com.vaadin.AbstractField} base class.
  29. *
  30. * The LegacyField interface inherits the {@link com.vaadin.ui.Component}
  31. * superinterface and also the {@link com.vaadin.ui.Property} interface to have
  32. * a value for the field.
  33. *
  34. * @author Vaadin Ltd.
  35. *
  36. * @param <T>
  37. * the type of values in the field, which might not be the same type
  38. * as that of the data source if converters are used
  39. *
  40. * @deprecated This interface is, apart from the rename, identical to the Vaadin
  41. * 7 {@code com.vaadin.ui.Field}. It is provided for compatibility
  42. * and migration purposes. As of 8.0, new field components should
  43. * extend {@link com.vaadin.ui.AbstractField} instead.
  44. */
  45. @Deprecated
  46. public interface Field<T> extends Component, BufferedValidatable, Property<T>,
  47. Property.ValueChangeNotifier, Property.ValueChangeListener,
  48. Property.Editor, Focusable, HasRequired {
  49. /**
  50. * Is this field required.
  51. *
  52. * Required fields must filled by the user.
  53. *
  54. * @return <code>true</code> if the field is required,otherwise
  55. * <code>false</code>.
  56. * @since 3.1
  57. */
  58. @Override
  59. public boolean isRequired();
  60. /**
  61. * Sets the field required. Required fields must filled by the user.
  62. *
  63. * @param required
  64. * Is the field required.
  65. * @since 3.1
  66. */
  67. @Override
  68. public void setRequired(boolean required);
  69. /**
  70. * Sets the error message to be displayed if a required field is empty.
  71. *
  72. * @param requiredMessage
  73. * Error message.
  74. * @since 5.2.6
  75. */
  76. public void setRequiredError(String requiredMessage);
  77. /**
  78. * Gets the error message that is to be displayed if a required field is
  79. * empty.
  80. *
  81. * @return Error message.
  82. * @since 5.2.6
  83. */
  84. public String getRequiredError();
  85. /**
  86. * An <code>Event</code> object specifying the LegacyField whose value has
  87. * been changed.
  88. *
  89. * @author Vaadin Ltd.
  90. * @since 3.0
  91. *
  92. * @deprecated As of 8.0, replaced by {@link ValueChange}.
  93. */
  94. @Deprecated
  95. @SuppressWarnings("serial")
  96. public static class ValueChangeEvent extends Component.Event
  97. implements Property.ValueChangeEvent {
  98. /**
  99. * Constructs a new event object with the specified source field object.
  100. *
  101. * @param source
  102. * the field that caused the event.
  103. */
  104. public ValueChangeEvent(Field source) {
  105. super(source);
  106. }
  107. /**
  108. * Gets the Property which triggered the event.
  109. *
  110. * @return the Source Property of the event.
  111. */
  112. @Override
  113. public Property getProperty() {
  114. return (Property) getSource();
  115. }
  116. }
  117. /**
  118. * Is the field empty?
  119. *
  120. * In general, "empty" state is same as null. As an exception, TextField
  121. * also treats empty string as "empty".
  122. *
  123. * @since 7.4
  124. * @return true if the field is empty, false otherwise
  125. */
  126. public boolean isEmpty();
  127. /**
  128. * Clears the value of the field.
  129. * <p>
  130. * The field value is typically reset to the initial value of the field.
  131. * Calling {@link #isEmpty()} on a cleared field must always returns true.
  132. *
  133. * @since 7.4
  134. */
  135. public void clear();
  136. }