01: package org.conform;
02:
03: import javax.swing.event.ChangeListener;
04: import javax.swing.event.ChangeEvent;
05: import java.util.List;
06: import java.util.ArrayList;
07:
08: public abstract class AbstractDynamicDomainProvider<T> extends
09: AbstractDomainProvider<T> implements DynamicDomainProvider {
10: List<ChangeListener> listeners = new ArrayList<ChangeListener>();
11:
12: protected AbstractDynamicDomainProvider() {
13: }
14:
15: protected AbstractDynamicDomainProvider(String propertyName) {
16: super (propertyName);
17: }
18:
19: public void addChangeListener(ChangeListener listener) {
20: listeners.add(listener);
21: }
22:
23: public void removeChangeListener(ChangeListener listener) {
24: listeners.remove(listener);
25: }
26:
27: public ChangeListener[] getChangeListeners() {
28: return listeners.toArray(new ChangeListener[listeners.size()]);
29: }
30:
31: protected void fireChangeEvent() {
32: ChangeEvent event = new ChangeEvent(this );
33: for (ChangeListener listener : listeners)
34: listener.stateChanged(event);
35: }
36:
37: public void refresh() {
38: values = null;
39: fireChangeEvent();
40: }
41: }
|