01: package org.drools.eclipse.editors.rete.model;
02:
03: import java.beans.PropertyChangeListener;
04: import java.beans.PropertyChangeSupport;
05:
06: /**
07: * Abstract prototype of a model element.
08: */
09: public abstract class ModelElement {
10:
11: /** Delegate used to implemenent property-change-support. */
12: private transient PropertyChangeSupport pcsDelegate = new PropertyChangeSupport(
13: this );
14:
15: /**
16: * Attach a non-null PropertyChangeListener to this object.
17: *
18: * @param l a non-null PropertyChangeListener instance
19: * @throws IllegalArgumentException if the parameter is null
20: */
21: public synchronized void addPropertyChangeListener(
22: PropertyChangeListener l) {
23: if (l == null) {
24: throw new IllegalArgumentException();
25: }
26: pcsDelegate.addPropertyChangeListener(l);
27: }
28:
29: /**
30: * Report a property change to registered listeners (for example edit parts).
31: *
32: * @param property the programmatic name of the property that changed
33: * @param oldValue the old value of this property
34: * @param newValue the new value of this property
35: */
36: protected void firePropertyChange(String property, Object oldValue,
37: Object newValue) {
38: if (pcsDelegate.hasListeners(property)) {
39: pcsDelegate
40: .firePropertyChange(property, oldValue, newValue);
41: }
42: }
43:
44: /**
45: * Remove a PropertyChangeListener from this component.
46: *
47: * @param l a PropertyChangeListener instance
48: */
49: public synchronized void removePropertyChangeListener(
50: PropertyChangeListener l) {
51: if (l != null) {
52: pcsDelegate.removePropertyChangeListener(l);
53: }
54: }
55:
56: }
|