61 // reference, so that there is no need to check for serialized.
62 private Action action;
63
64 private static ReferenceQueue<JComponent> getQueue() {
65 synchronized(ActionPropertyChangeListener.class) {
66 if (queue == null) {
67 queue = new ReferenceQueue<JComponent>();
68 }
69 }
70 return queue;
71 }
72
73 public ActionPropertyChangeListener(T c, Action a) {
74 super();
75 setTarget(c);
76 this.action = a;
77 }
78
79 /**
80 * PropertyChangeListener method. If the target has been gc'ed this
81 * will remove the <code>PropertyChangeListener</code> from the Action,
82 * otherwise this will invoke actionPropertyChanged.
83 */
84 public final void propertyChange(PropertyChangeEvent e) {
85 T target = getTarget();
86 if (target == null) {
87 getAction().removePropertyChangeListener(this);
88 } else {
89 actionPropertyChanged(target, getAction(), e);
90 }
91 }
92
93 /**
94 * Invoked when a property changes on the Action and the target
95 * still exists.
96 */
97 protected abstract void actionPropertyChanged(T target, Action action,
98 PropertyChangeEvent e);
99
100 private void setTarget(T c) {
101 ReferenceQueue<JComponent> queue = getQueue();
|
61 // reference, so that there is no need to check for serialized.
62 private Action action;
63
64 private static ReferenceQueue<JComponent> getQueue() {
65 synchronized(ActionPropertyChangeListener.class) {
66 if (queue == null) {
67 queue = new ReferenceQueue<JComponent>();
68 }
69 }
70 return queue;
71 }
72
73 public ActionPropertyChangeListener(T c, Action a) {
74 super();
75 setTarget(c);
76 this.action = a;
77 }
78
79 /**
80 * PropertyChangeListener method. If the target has been gc'ed this
81 * will remove the {@code PropertyChangeListener} from the Action,
82 * otherwise this will invoke actionPropertyChanged.
83 */
84 public final void propertyChange(PropertyChangeEvent e) {
85 T target = getTarget();
86 if (target == null) {
87 getAction().removePropertyChangeListener(this);
88 } else {
89 actionPropertyChanged(target, getAction(), e);
90 }
91 }
92
93 /**
94 * Invoked when a property changes on the Action and the target
95 * still exists.
96 */
97 protected abstract void actionPropertyChanged(T target, Action action,
98 PropertyChangeEvent e);
99
100 private void setTarget(T c) {
101 ReferenceQueue<JComponent> queue = getQueue();
|