diff options
author | Artur Signell <artur@vaadin.com> | 2014-12-09 16:58:01 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-12-10 20:56:27 +0000 |
commit | 22b20bc9fc4067a026cf08b5130bd20afa89d27e (patch) | |
tree | 4d20375ef6a8c44d0573b1d9a709155045004f51 /server/src/com | |
parent | 9107b8d8c520bd297ed7685d7a8482d1078604e9 (diff) | |
download | vaadin-framework-22b20bc9fc4067a026cf08b5130bd20afa89d27e.tar.gz vaadin-framework-22b20bc9fc4067a026cf08b5130bd20afa89d27e.zip |
Add public Field.isEmpty() and clear() (#15354)
Change-Id: I6bda7ff2a66a9ad172c899d855ca868881600be4
Diffstat (limited to 'server/src/com')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractField.java | 19 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/AbstractSelect.java | 2 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/AbstractTextField.java | 2 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Field.java | 22 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Form.java | 9 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/RichTextArea.java | 2 |
6 files changed, 35 insertions, 21 deletions
diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index 369ad1253c..df7bbb68a2 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -1502,25 +1502,12 @@ public abstract class AbstractField<T> extends AbstractComponent implements markAsDirty(); } - /** - * Is the field empty? - * - * In general, "empty" state is same as null. As an exception, TextField - * also treats empty string as "empty". - */ - protected boolean isEmpty() { + @Override + public boolean isEmpty() { return (getFieldValue() == null); } - /** - * Clear the value of the field. - * <p> - * The field value is typically reset to the initial value of the field but - * this is not mandatory. Calling {@link #isEmpty()} on a cleared field must - * always returns true. - * - * @since - */ + @Override public void clear() { setValue(null); } diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index 2c4dd5be5d..70f08c95d8 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -1782,7 +1782,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @see AbstractField#isEmpty(). */ @Override - protected boolean isEmpty() { + public boolean isEmpty() { if (!multiSelect) { return super.isEmpty(); } else { diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 9293d38119..ea0372bc8c 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -317,7 +317,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements } @Override - protected boolean isEmpty() { + public boolean isEmpty() { return super.isEmpty() || getValue().length() == 0; } diff --git a/server/src/com/vaadin/ui/Field.java b/server/src/com/vaadin/ui/Field.java index f191e1bdd7..6dee4de6cb 100644 --- a/server/src/com/vaadin/ui/Field.java +++ b/server/src/com/vaadin/ui/Field.java @@ -113,4 +113,26 @@ public interface Field<T> extends Component, BufferedValidatable, Property<T>, return (Property) getSource(); } } + + /** + * Is the field empty? + * + * In general, "empty" state is same as null. As an exception, TextField + * also treats empty string as "empty". + * + * @since + * @return true if the field is empty, false otherwise + */ + public boolean isEmpty(); + + /** + * Clears the value of the field. + * <p> + * The field value is typically reset to the initial value of the field. + * Calling {@link #isEmpty()} on a cleared field must always returns true. + * + * @since + */ + public void clear(); + } diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java index 48239b09e3..45532756e5 100644 --- a/server/src/com/vaadin/ui/Form.java +++ b/server/src/com/vaadin/ui/Form.java @@ -1186,9 +1186,14 @@ public class Form extends AbstractField<Object> implements Item.Editor, } } - /** Form is empty if all of its fields are empty. */ + /** + * {@inheritDoc} + * <p> + * A Form is empty if all of its fields are empty. + * + */ @Override - protected boolean isEmpty() { + public boolean isEmpty() { for (Iterator<Field<?>> i = fields.values().iterator(); i.hasNext();) { Field<?> f = i.next(); diff --git a/server/src/com/vaadin/ui/RichTextArea.java b/server/src/com/vaadin/ui/RichTextArea.java index 9d05181541..31327b3a6f 100644 --- a/server/src/com/vaadin/ui/RichTextArea.java +++ b/server/src/com/vaadin/ui/RichTextArea.java @@ -285,7 +285,7 @@ public class RichTextArea extends AbstractField<String> implements } @Override - protected boolean isEmpty() { + public boolean isEmpty() { return super.isEmpty() || getValue().length() == 0; } |