summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2011-04-18 14:14:35 +0000
committerHenri Sara <henri.sara@itmill.com>2011-04-18 14:14:35 +0000
commitb3d92ad4bdcd3568db2c01478bdfaa48e915a90c (patch)
treee62b52159fa812d5ab6fd47d50a9b5758238d242 /src/com
parent4b13cfab7c0adaefdf8b4cfcb3c68bddf9111dc2 (diff)
downloadvaadin-framework-b3d92ad4bdcd3568db2c01478bdfaa48e915a90c.tar.gz
vaadin-framework-b3d92ad4bdcd3568db2c01478bdfaa48e915a90c.zip
#6860 introduced AbstractProperty with common functionality of most property implementations (listener management etc.), TextFileProperty now implements ReadOnlyStatusChangeListener
svn changeset:18360/svn branch:6.6
Diffstat (limited to 'src/com')
-rw-r--r--src/com/vaadin/data/util/AbstractProperty.java171
-rw-r--r--src/com/vaadin/data/util/MethodProperty.java167
-rw-r--r--src/com/vaadin/data/util/ObjectProperty.java175
-rw-r--r--src/com/vaadin/data/util/PropertyFormatter.java156
-rw-r--r--src/com/vaadin/data/util/TextFileProperty.java95
5 files changed, 191 insertions, 573 deletions
diff --git a/src/com/vaadin/data/util/AbstractProperty.java b/src/com/vaadin/data/util/AbstractProperty.java
new file mode 100644
index 0000000000..9db9013d70
--- /dev/null
+++ b/src/com/vaadin/data/util/AbstractProperty.java
@@ -0,0 +1,171 @@
+package com.vaadin.data.util;
+
+import java.util.LinkedList;
+
+import com.vaadin.data.Property;
+
+/**
+ * Abstract base class for {@link Property} implementations.
+ *
+ * Handles listener management for {@link ValueChangeListener}s and
+ * {@link ReadOnlyStatusChangeListener}s.
+ *
+ * @since 6.6
+ */
+public abstract class AbstractProperty implements Property,
+ Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier {
+
+ /**
+ * List of listeners who are interested in the read-only status changes of
+ * the Property
+ */
+ private LinkedList<ReadOnlyStatusChangeListener> readOnlyStatusChangeListeners = null;
+
+ /**
+ * List of listeners who are interested in the value changes of the Property
+ */
+ private LinkedList<ValueChangeListener> valueChangeListeners = null;
+
+ /**
+ * 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.
+ *
+ * @return String representation of the value stored in the Property
+ */
+ @Override
+ public String toString() {
+ final Object value = getValue();
+ if (value == null) {
+ return null;
+ }
+ return value.toString();
+ }
+
+ /* Events */
+
+ /**
+ * An <code>Event</code> object specifying the Property whose read-only
+ * status has been changed.
+ */
+ protected class ReadOnlyStatusChangeEvent extends java.util.EventObject
+ implements Property.ReadOnlyStatusChangeEvent {
+
+ /**
+ * Constructs a new read-only status change event for this object.
+ *
+ * @param source
+ * source object of the event.
+ */
+ protected ReadOnlyStatusChangeEvent(Property source) {
+ super(source);
+ }
+
+ /**
+ * Gets the Property whose read-only state has changed.
+ *
+ * @return source Property of the event.
+ */
+ public Property getProperty() {
+ return (Property) getSource();
+ }
+
+ }
+
+ /**
+ * Registers a new read-only status change listener for this Property.
+ *
+ * @param listener
+ * the new Listener to be registered.
+ */
+ public void addListener(Property.ReadOnlyStatusChangeListener listener) {
+ if (readOnlyStatusChangeListeners == null) {
+ readOnlyStatusChangeListeners = new LinkedList<ReadOnlyStatusChangeListener>();
+ }
+ readOnlyStatusChangeListeners.add(listener);
+ }
+
+ /**
+ * Removes a previously registered read-only status change listener.
+ *
+ * @param listener
+ * the listener to be removed.
+ */
+ public void removeListener(Property.ReadOnlyStatusChangeListener listener) {
+ if (readOnlyStatusChangeListeners != null) {
+ readOnlyStatusChangeListeners.remove(listener);
+ }
+ }
+
+ /**
+ * Sends a read only status change event to all registered listeners.
+ */
+ protected void fireReadOnlyStatusChange() {
+ if (readOnlyStatusChangeListeners != null) {
+ final Object[] l = readOnlyStatusChangeListeners.toArray();
+ final Property.ReadOnlyStatusChangeEvent event = new ReadOnlyStatusChangeEvent(
+ this);
+ for (int i = 0; i < l.length; i++) {
+ ((Property.ReadOnlyStatusChangeListener) l[i])
+ .readOnlyStatusChange(event);
+ }
+ }
+ }
+
+ /**
+ * An <code>Event</code> object specifying the Property whose value has been
+ * changed.
+ */
+ private class ValueChangeEvent extends java.util.EventObject implements
+ Property.ValueChangeEvent {
+
+ /**
+ * Constructs a new value change event for this object.
+ *
+ * @param source
+ * source object of the event.
+ */
+ protected ValueChangeEvent(Property source) {
+ super(source);
+ }
+
+ /**
+ * Gets the Property whose value has changed.
+ *
+ * @return source Property of the event.
+ */
+ public Property getProperty() {
+ return (Property) getSource();
+ }
+
+ }
+
+ public void addListener(ValueChangeListener listener) {
+ if (valueChangeListeners == null) {
+ valueChangeListeners = new LinkedList<ValueChangeListener>();
+ }
+ valueChangeListeners.add(listener);
+
+ }
+
+ public void removeListener(ValueChangeListener listener) {
+ if (valueChangeListeners != null) {
+ valueChangeListeners.remove(listener);
+ }
+
+ }
+
+ /**
+ * Sends a value change event to all registered listeners.
+ */
+ protected void fireValueChange() {
+ if (valueChangeListeners != null) {
+ final Object[] l = valueChangeListeners.toArray();
+ final Property.ValueChangeEvent event = new ValueChangeEvent(this);
+ for (int i = 0; i < l.length; i++) {
+ ((Property.ValueChangeListener) l[i]).valueChange(event);
+ }
+ }
+ }
+
+}
diff --git a/src/com/vaadin/data/util/MethodProperty.java b/src/com/vaadin/data/util/MethodProperty.java
index 12b69858da..b04fc77b61 100644
--- a/src/com/vaadin/data/util/MethodProperty.java
+++ b/src/com/vaadin/data/util/MethodProperty.java
@@ -8,7 +8,6 @@ import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -48,8 +47,7 @@ import com.vaadin.util.SerializerHelper;
* @since 3.0
*/
@SuppressWarnings("serial")
-public class MethodProperty<T> implements Property,
- Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier {
+public class MethodProperty<T> extends AbstractProperty {
private static final Logger logger = Logger.getLogger(MethodProperty.class
.getName());
@@ -85,18 +83,6 @@ public class MethodProperty<T> implements Property,
*/
private transient Class<? extends T> type;
- /**
- * List of listeners who are interested in the read-only status changes of
- * the MethodProperty
- */
- private LinkedList<ReadOnlyStatusChangeListener> readOnlyStatusChangeListeners = null;
-
- /**
- * List of listeners who are interested in the value changes of the
- * MethodProperty
- */
- private LinkedList<ValueChangeListener> valueChangeListeners = null;
-
/* Special serialization to handle method references */
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
@@ -629,22 +615,6 @@ public class MethodProperty<T> implements Property,
}
/**
- * Returns the value of the <code>MethodProperty</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.
- *
- * @return String representation of the value stored in the Property
- */
- @Override
- public String toString() {
- final Object value = getValue();
- if (value == null) {
- return null;
- }
- return value.toString();
- }
-
- /**
* <p>
* Sets the setter method and getter method argument lists.
* </p>
@@ -852,140 +822,15 @@ public class MethodProperty<T> implements Property,
}
}
- /* Events */
-
- /**
- * An <code>Event</code> object specifying the Property whose read-only
- * status has been changed.
- *
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
- private class ReadOnlyStatusChangeEvent extends java.util.EventObject
- implements Property.ReadOnlyStatusChangeEvent {
-
- /**
- * Constructs a new read-only status change event for this object.
- *
- * @param source
- * source object of the event.
- */
- protected ReadOnlyStatusChangeEvent(MethodProperty<T> source) {
- super(source);
- }
-
- /**
- * Gets the Property whose read-only state has changed.
- *
- * @return source Property of the event.
- */
- public Property getProperty() {
- return (Property) getSource();
- }
-
- }
-
- /**
- * Registers a new read-only status change listener for this Property.
- *
- * @param listener
- * the new Listener to be registered.
- */
- public void addListener(Property.ReadOnlyStatusChangeListener listener) {
- if (readOnlyStatusChangeListeners == null) {
- readOnlyStatusChangeListeners = new LinkedList<ReadOnlyStatusChangeListener>();
- }
- readOnlyStatusChangeListeners.add(listener);
- }
-
- /**
- * Removes a previously registered read-only status change listener.
- *
- * @param listener
- * the listener to be removed.
- */
- public void removeListener(Property.ReadOnlyStatusChangeListener listener) {
- if (readOnlyStatusChangeListeners != null) {
- readOnlyStatusChangeListeners.remove(listener);
- }
- }
-
- /**
- * Sends a read only status change event to all registered listeners.
- */
- private void fireReadOnlyStatusChange() {
- if (readOnlyStatusChangeListeners != null) {
- final Object[] l = readOnlyStatusChangeListeners.toArray();
- final Property.ReadOnlyStatusChangeEvent event = new ReadOnlyStatusChangeEvent(
- this);
- for (int i = 0; i < l.length; i++) {
- ((Property.ReadOnlyStatusChangeListener) l[i])
- .readOnlyStatusChange(event);
- }
- }
- }
-
- /**
- * An <code>Event</code> object specifying the Property whose value has been
- * changed.
- *
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 5.3
- */
- private class ValueChangeEvent extends java.util.EventObject implements
- Property.ValueChangeEvent {
-
- /**
- * Constructs a new value change event for this object.
- *
- * @param source
- * source object of the event.
- */
- protected ValueChangeEvent(MethodProperty<T> source) {
- super(source);
- }
-
- /**
- * Gets the Property whose value has changed.
- *
- * @return source Property of the event.
- */
- public Property getProperty() {
- return (Property) getSource();
- }
-
- }
-
- public void addListener(ValueChangeListener listener) {
- if (valueChangeListeners == null) {
- valueChangeListeners = new LinkedList<ValueChangeListener>();
- }
- valueChangeListeners.add(listener);
-
- }
-
- public void removeListener(ValueChangeListener listener) {
- if (valueChangeListeners != null) {
- valueChangeListeners.remove(listener);
- }
-
- }
-
/**
* Sends a value change event to all registered listeners.
+ *
+ * Public for backwards compatibility, visibility may be reduced in future
+ * versions.
*/
+ @Override
public void fireValueChange() {
- if (valueChangeListeners != null) {
- final Object[] l = valueChangeListeners.toArray();
- final Property.ValueChangeEvent event = new ValueChangeEvent(this);
- for (int i = 0; i < l.length; i++) {
- ((Property.ValueChangeListener) l[i]).valueChange(event);
- }
- }
+ super.fireValueChange();
}
}
diff --git a/src/com/vaadin/data/util/ObjectProperty.java b/src/com/vaadin/data/util/ObjectProperty.java
index 6724f1d40f..ee38bc0797 100644
--- a/src/com/vaadin/data/util/ObjectProperty.java
+++ b/src/com/vaadin/data/util/ObjectProperty.java
@@ -5,7 +5,6 @@
package com.vaadin.data.util;
import java.lang.reflect.Constructor;
-import java.util.LinkedList;
import com.vaadin.data.Property;
@@ -20,8 +19,7 @@ import com.vaadin.data.Property;
* @since 3.0
*/
@SuppressWarnings("serial")
-public class ObjectProperty<T> implements Property,
- Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier {
+public class ObjectProperty<T> extends AbstractProperty {
/**
* A boolean value storing the Property's read-only status information.
@@ -39,16 +37,6 @@ public class ObjectProperty<T> implements Property,
private final Class<T> type;
/**
- * Internal list of registered value change listeners.
- */
- private LinkedList<ValueChangeListener> valueChangeListeners = null;
-
- /**
- * Internal list of registered read-only status change listeners.
- */
- private LinkedList<ReadOnlyStatusChangeListener> readOnlyStatusChangeListeners = null;
-
- /**
* Creates a new instance of ObjectProperty with the given value. The type
* of the property is automatically initialized to be the type of the given
* value.
@@ -125,24 +113,6 @@ public class ObjectProperty<T> implements Property,
}
/**
- * Returns the value of the ObjectProperty 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.
- *
- * @return <code>String</code> representation of the value stored in the
- * ObjectProperty
- */
- @Override
- public String toString() {
- final Object value = getValue();
- if (value != null) {
- return value.toString();
- } else {
- return null;
- }
- }
-
- /**
* 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
@@ -214,147 +184,4 @@ public class ObjectProperty<T> implements Property,
fireValueChange();
}
- /* Events */
-
- /**
- * An <code>Event</code> object specifying the ObjectProperty whose value
- * has changed.
- *
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
- private class ValueChangeEvent extends java.util.EventObject implements
- Property.ValueChangeEvent {
-
- /**
- * Constructs a new value change event for this object.
- *
- * @param source
- * the source object of the event.
- */
- protected ValueChangeEvent(ObjectProperty<T> source) {
- super(source);
- }
-
- /**
- * Gets the Property whose read-only state has changed.
- *
- * @return source the Property of the event.
- */
- public Property getProperty() {
- return (Property) getSource();
- }
- }
-
- /**
- * An <code>Event</code> object specifying the Property whose read-only
- * status has been changed.
- *
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
- private class ReadOnlyStatusChangeEvent extends java.util.EventObject
- implements Property.ReadOnlyStatusChangeEvent {
-
- /**
- * Constructs a new read-only status change event for this object.
- *
- * @param source
- * source object of the event
- */
- protected ReadOnlyStatusChangeEvent(ObjectProperty<T> source) {
- super(source);
- }
-
- /**
- * Gets the Property whose read-only state has changed.
- *
- * @return source Property of the event.
- */
- public Property getProperty() {
- return (Property) getSource();
- }
- }
-
- /**
- * Removes a previously registered value change listener.
- *
- * @param listener
- * the listener to be removed.
- */
- public void removeListener(Property.ValueChangeListener listener) {
- if (valueChangeListeners != null) {
- valueChangeListeners.remove(listener);
- }
- }
-
- /**
- * Registers a new value change listener for this ObjectProperty.
- *
- * @param listener
- * the new Listener to be registered
- */
- public void addListener(Property.ValueChangeListener listener) {
- if (valueChangeListeners == null) {
- valueChangeListeners = new LinkedList<ValueChangeListener>();
- }
- valueChangeListeners.add(listener);
- }
-
- /**
- * Registers a new read-only status change listener for this Property.
- *
- * @param listener
- * the new Listener to be registered
- */
- public void addListener(Property.ReadOnlyStatusChangeListener listener) {
- if (readOnlyStatusChangeListeners == null) {
- readOnlyStatusChangeListeners = new LinkedList<ReadOnlyStatusChangeListener>();
- }
- readOnlyStatusChangeListeners.add(listener);
- }
-
- /**
- * Removes a previously registered read-only status change listener.
- *
- * @param listener
- * the listener to be removed.
- */
- public void removeListener(Property.ReadOnlyStatusChangeListener listener) {
- if (readOnlyStatusChangeListeners != null) {
- readOnlyStatusChangeListeners.remove(listener);
- }
- }
-
- /**
- * Sends a value change event to all registered listeners.
- */
- private void fireValueChange() {
- if (valueChangeListeners != null) {
- final Object[] l = valueChangeListeners.toArray();
- final Property.ValueChangeEvent event = new ValueChangeEvent(this);
- for (int i = 0; i < l.length; i++) {
- ((Property.ValueChangeListener) l[i]).valueChange(event);
- }
- }
- }
-
- /**
- * Sends a read only status change event to all registered listeners.
- */
- private void fireReadOnlyStatusChange() {
- if (readOnlyStatusChangeListeners != null) {
- final Object[] l = readOnlyStatusChangeListeners.toArray();
- final Property.ReadOnlyStatusChangeEvent event = new ReadOnlyStatusChangeEvent(
- this);
- for (int i = 0; i < l.length; i++) {
- ((Property.ReadOnlyStatusChangeListener) l[i])
- .readOnlyStatusChange(event);
- }
- }
- }
}
diff --git a/src/com/vaadin/data/util/PropertyFormatter.java b/src/com/vaadin/data/util/PropertyFormatter.java
index 23e4fb324f..c43a4771dc 100644
--- a/src/com/vaadin/data/util/PropertyFormatter.java
+++ b/src/com/vaadin/data/util/PropertyFormatter.java
@@ -3,8 +3,6 @@
*/
package com.vaadin.data.util;
-import java.util.LinkedList;
-
import com.vaadin.data.Property;
/**
@@ -35,20 +33,8 @@ import com.vaadin.data.Property;
* @since 5.3.0
*/
@SuppressWarnings("serial")
-public abstract class PropertyFormatter implements Property,
- Property.ValueChangeNotifier, Property.ValueChangeListener,
- Property.ReadOnlyStatusChangeListener,
- Property.ReadOnlyStatusChangeNotifier {
-
- /**
- * Internal list of registered value change listeners.
- */
- private LinkedList<Property.ValueChangeListener> valueChangeListeners = null;
-
- /**
- * Internal list of registered read-only status change listeners.
- */
- private LinkedList<Property.ReadOnlyStatusChangeListener> readOnlyStatusChangeListeners = null;
+public abstract class PropertyFormatter extends AbstractProperty implements
+ Property.ValueChangeListener, Property.ReadOnlyStatusChangeListener {
/** Datasource that stores the actual value. */
Property dataSource;
@@ -237,144 +223,6 @@ public abstract class PropertyFormatter implements Property,
}
/**
- * An <code>Event</code> object specifying the ObjectProperty whose value
- * has changed.
- *
- * @author IT Mill Ltd.
- * @since 5.3.0
- */
- private class ValueChangeEvent extends java.util.EventObject implements
- Property.ValueChangeEvent {
-
- /**
- * Constructs a new value change event for this object.
- *
- * @param source
- * the source object of the event.
- */
- protected ValueChangeEvent(PropertyFormatter source) {
- super(source);
- }
-
- /**
- * Gets the Property whose read-only state has changed.
- *
- * @return source the Property of the event.
- */
- public Property getProperty() {
- return (Property) getSource();
- }
- }
-
- /**
- * An <code>Event</code> object specifying the Property whose read-only
- * status has been changed.
- *
- * @author IT Mill Ltd.
- * @since 5.3.0
- */
- private class ReadOnlyStatusChangeEvent extends java.util.EventObject
- implements Property.ReadOnlyStatusChangeEvent {
-
- /**
- * Constructs a new read-only status change event for this object.
- *
- * @param source
- * source object of the event
- */
- protected ReadOnlyStatusChangeEvent(PropertyFormatter source) {
- super(source);
- }
-
- /**
- * Gets the Property whose read-only state has changed.
- *
- * @return source Property of the event.
- */
- public Property getProperty() {
- return (Property) getSource();
- }
- }
-
- /**
- * Removes a previously registered value change listener.
- *
- * @param listener
- * the listener to be removed.
- */
- public void removeListener(Property.ValueChangeListener listener) {
- if (valueChangeListeners != null) {
- valueChangeListeners.remove(listener);
- }
- }
-
- /**
- * Registers a new value change listener for this ObjectProperty.
- *
- * @param listener
- * the new Listener to be registered
- */
- public void addListener(Property.ValueChangeListener listener) {
- if (valueChangeListeners == null) {
- valueChangeListeners = new LinkedList<Property.ValueChangeListener>();
- }
- valueChangeListeners.add(listener);
- }
-
- /**
- * Registers a new read-only status change listener for this Property.
- *
- * @param listener
- * the new Listener to be registered
- */
- public void addListener(Property.ReadOnlyStatusChangeListener listener) {
- if (readOnlyStatusChangeListeners == null) {
- readOnlyStatusChangeListeners = new LinkedList<Property.ReadOnlyStatusChangeListener>();
- }
- readOnlyStatusChangeListeners.add(listener);
- }
-
- /**
- * Removes a previously registered read-only status change listener.
- *
- * @param listener
- * the listener to be removed.
- */
- public void removeListener(Property.ReadOnlyStatusChangeListener listener) {
- if (readOnlyStatusChangeListeners != null) {
- readOnlyStatusChangeListeners.remove(listener);
- }
- }
-
- /**
- * Sends a value change event to all registered listeners.
- */
- private void fireValueChange() {
- if (valueChangeListeners != null) {
- final Object[] l = valueChangeListeners.toArray();
- final Property.ValueChangeEvent event = new ValueChangeEvent(this);
- for (int i = 0; i < l.length; i++) {
- ((Property.ValueChangeListener) l[i]).valueChange(event);
- }
- }
- }
-
- /**
- * Sends a read only status change event to all registered listeners.
- */
- private void fireReadOnlyStatusChange() {
- if (readOnlyStatusChangeListeners != null) {
- final Object[] l = readOnlyStatusChangeListeners.toArray();
- final Property.ReadOnlyStatusChangeEvent event = new ReadOnlyStatusChangeEvent(
- this);
- for (int i = 0; i < l.length; i++) {
- ((Property.ReadOnlyStatusChangeListener) l[i])
- .readOnlyStatusChange(event);
- }
- }
- }
-
- /**
* Listens for changes in the datasource.
*
* This should not be called directly.
diff --git a/src/com/vaadin/data/util/TextFileProperty.java b/src/com/vaadin/data/util/TextFileProperty.java
index 8d99112338..005372a04b 100644
--- a/src/com/vaadin/data/util/TextFileProperty.java
+++ b/src/com/vaadin/data/util/TextFileProperty.java
@@ -14,23 +14,23 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
-import java.util.LinkedList;
-
-import com.vaadin.data.Property;
/**
* Property implementation for wrapping a text file.
*
- * Supports reading and writing of a File from/to String. ValueChangeNotifiers
- * are supported, but only fire when setValue(Object) is explicitly called.
+ * Supports reading and writing of a File from/to String.
+ *
+ * {@link ValueChangeListener}s are supported, but only fire when
+ * setValue(Object) is explicitly called. {@link ReadOnlyStatusChangeListener}s
+ * are supported but only fire when setReadOnly(boolean) is explicitly called.
+ *
*/
@SuppressWarnings("serial")
-public class TextFileProperty implements Property, Property.ValueChangeNotifier {
+public class TextFileProperty extends AbstractProperty {
private File file;
private boolean readonly;
private Charset charset = null;
- private LinkedList<Property.ValueChangeListener> valueChangeListeners = null;
/**
* Wrap given file with property interface.
@@ -115,7 +115,11 @@ public class TextFileProperty implements Property, Property.ValueChangeNotifier
* @see com.vaadin.data.Property#setReadOnly(boolean)
*/
public void setReadOnly(boolean newStatus) {
+ boolean oldStatus = readonly;
readonly = newStatus;
+ if (isReadOnly() != oldStatus) {
+ fireReadOnlyStatusChange();
+ }
}
/*
@@ -147,81 +151,4 @@ public class TextFileProperty implements Property, Property.ValueChangeNotifier
}
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return (String) getValue();
- }
-
- /* Events */
-
- /**
- * An <code>Event</code> object specifying the TextFileProperty whose value
- * has changed.
- */
- private class ValueChangeEvent extends java.util.EventObject implements
- Property.ValueChangeEvent {
-
- /**
- * Constructs a new value change event for this object.
- *
- * @param source
- * the source object of the event.
- */
- protected ValueChangeEvent(TextFileProperty source) {
- super(source);
- }
-
- /**
- * Gets the Property whose read-only state has changed.
- *
- * @return source the Property of the event.
- */
- public Property getProperty() {
- return (Property) getSource();
- }
- }
-
- /**
- * Removes a previously registered value change listener.
- *
- * @param listener
- * the listener to be removed.
- */
- public void removeListener(Property.ValueChangeListener listener) {
- if (valueChangeListeners != null) {
- valueChangeListeners.remove(listener);
- }
- }
-
- /**
- * Registers a new value change listener for this TextFileProperty.
- *
- * @param listener
- * the new Listener to be registered
- */
- public void addListener(Property.ValueChangeListener listener) {
- if (valueChangeListeners == null) {
- valueChangeListeners = new LinkedList<Property.ValueChangeListener>();
- }
- valueChangeListeners.add(listener);
- }
-
- /**
- * Sends a value change event to all registered listeners.
- */
- private void fireValueChange() {
- if (valueChangeListeners != null) {
- final Object[] l = valueChangeListeners.toArray();
- final ValueChangeEvent event = new ValueChangeEvent(this);
- for (int i = 0; i < l.length; i++) {
- ((ValueChangeListener) l[i]).valueChange(event);
- }
- }
- }
-
}