diff options
author | Henri Sara <henri.sara@itmill.com> | 2011-04-19 11:59:35 +0000 |
---|---|---|
committer | Henri Sara <henri.sara@itmill.com> | 2011-04-19 11:59:35 +0000 |
commit | 5ebd63ba8d1399f510b424846d9be5af8b164e17 (patch) | |
tree | e60c7ad8a68f35a144f93fdbf412837c3862bf04 /src/com | |
parent | 370979eb4082df297ebb70f544714dd0fdb3fb10 (diff) | |
download | vaadin-framework-5ebd63ba8d1399f510b424846d9be5af8b164e17.tar.gz vaadin-framework-5ebd63ba8d1399f510b424846d9be5af8b164e17.zip |
#6860 Moved much of the read-only logic to AbstractProperty
svn changeset:18380/svn branch:6.6
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/vaadin/data/util/AbstractProperty.java | 23 | ||||
-rw-r--r-- | src/com/vaadin/data/util/ObjectProperty.java | 31 | ||||
-rw-r--r-- | src/com/vaadin/data/util/TextFileProperty.java | 17 |
3 files changed, 25 insertions, 46 deletions
diff --git a/src/com/vaadin/data/util/AbstractProperty.java b/src/com/vaadin/data/util/AbstractProperty.java index 9db9013d70..2b3fcf2c93 100644 --- a/src/com/vaadin/data/util/AbstractProperty.java +++ b/src/com/vaadin/data/util/AbstractProperty.java @@ -27,6 +27,29 @@ public abstract class AbstractProperty implements Property, private LinkedList<ValueChangeListener> valueChangeListeners = null; /** + * Is the Property read-only? + */ + private boolean readOnly; + + /** + * {@inheritDoc} + * + * Override for additional restrictions on what is considered a read-only + * property. + */ + public boolean isReadOnly() { + return readOnly; + } + + public void setReadOnly(boolean newStatus) { + boolean oldStatus = isReadOnly(); + readOnly = newStatus; + if (oldStatus != isReadOnly()) { + fireReadOnlyStatusChange(); + } + } + + /** * Returns the value of the <code>Property</code> in human readable textual * format. The return value should be assignable to the * <code>setValue</code> method if the Property is not in read-only mode. diff --git a/src/com/vaadin/data/util/ObjectProperty.java b/src/com/vaadin/data/util/ObjectProperty.java index ee38bc0797..8286e3c6db 100644 --- a/src/com/vaadin/data/util/ObjectProperty.java +++ b/src/com/vaadin/data/util/ObjectProperty.java @@ -22,11 +22,6 @@ import com.vaadin.data.Property; public class ObjectProperty<T> extends AbstractProperty { /** - * A boolean value storing the Property's read-only status information. - */ - private boolean readOnly = false; - - /** * The value contained by the Property. */ private T value; @@ -113,32 +108,6 @@ public class ObjectProperty<T> extends AbstractProperty { } /** - * Tests if the Property is in read-only mode. In read-only mode calls to - * the method <code>setValue</code> will throw - * <code>ReadOnlyException</code>s and will not modify the value of the - * Property. - * - * @return <code>true</code> if the Property is in read-only mode, - * <code>false</code> if it's not - */ - public boolean isReadOnly() { - return readOnly; - } - - /** - * Sets the Property's read-only mode to the specified status. - * - * @param newStatus - * the new read-only status of the Property. - */ - public void setReadOnly(boolean newStatus) { - if (newStatus != readOnly) { - readOnly = newStatus; - fireReadOnlyStatusChange(); - } - } - - /** * Sets the value of the property. This method supports setting from * <code>String</code> if either <code>String</code> is directly assignable * to property type, or the type class contains a string constructor. diff --git a/src/com/vaadin/data/util/TextFileProperty.java b/src/com/vaadin/data/util/TextFileProperty.java index 5915ddd664..dba5aa49f0 100644 --- a/src/com/vaadin/data/util/TextFileProperty.java +++ b/src/com/vaadin/data/util/TextFileProperty.java @@ -29,7 +29,6 @@ import java.nio.charset.Charset; public class TextFileProperty extends AbstractProperty {
private File file;
- private boolean readonly;
private Charset charset = null;
/**
@@ -105,21 +104,9 @@ public class TextFileProperty extends AbstractProperty { *
* @see com.vaadin.data.Property#isReadOnly()
*/
+ @Override
public boolean isReadOnly() {
- return file == null || readonly || !file.canWrite();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.data.Property#setReadOnly(boolean)
- */
- public void setReadOnly(boolean newStatus) {
- boolean oldStatus = isReadOnly();
- readonly = newStatus;
- if (isReadOnly() != oldStatus) {
- fireReadOnlyStatusChange();
- }
+ return file == null || super.isReadOnly() || !file.canWrite();
}
/*
|