Revision 44377 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/AbstractStoresRepository.java
AbstractStoresRepository.java | ||
---|---|---|
6 | 6 |
import java.util.List; |
7 | 7 |
import java.util.Map; |
8 | 8 |
import org.apache.commons.lang3.StringUtils; |
9 |
import org.gvsig.tools.observer.Notification; |
|
10 |
import org.gvsig.tools.observer.ObservableHelper; |
|
11 |
import org.gvsig.tools.observer.Observer; |
|
9 | 12 |
import org.gvsig.tools.util.UnmodifiableBasicSet; |
10 | 13 |
import org.gvsig.tools.util.UnmodifiableBasicSetChained; |
11 | 14 |
import org.slf4j.Logger; |
... | ... | |
23 | 26 |
private final String name; |
24 | 27 |
private final String label; |
25 | 28 |
private final List<StoresRepository> subrepositories; |
29 |
private final ObservableHelper observableHelper; |
|
26 | 30 |
|
27 | 31 |
public AbstractStoresRepository(String name) { |
28 | 32 |
this(name, null); |
... | ... | |
32 | 36 |
this.name = name; |
33 | 37 |
this.label = label; |
34 | 38 |
this.subrepositories = new ArrayList<>(); |
39 |
this.observableHelper = new ObservableHelper(); |
|
35 | 40 |
} |
36 | 41 |
|
37 | 42 |
protected abstract DataStoreParameters getMyParameters(String name); |
... | ... | |
43 | 48 |
protected abstract UnmodifiableBasicSet<String> getMyKeySet(); |
44 | 49 |
|
45 | 50 |
@Override |
51 |
public void addObserver(Observer o) { |
|
52 |
this.observableHelper.addObserver(o); |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
public void deleteObserver(Observer o) { |
|
57 |
this.observableHelper.deleteObserver(o); |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
public void deleteObservers() { |
|
62 |
this.observableHelper.deleteObservers(); |
|
63 |
} |
|
64 |
|
|
65 |
protected Notification notifyObservers(String notificationType, Object value) { |
|
66 |
return this.observableHelper.notifyObservers(this, notificationType, value); |
|
67 |
} |
|
68 |
|
|
69 |
protected Notification notifyObservers(String notificationType, Object value1, Object value2) { |
|
70 |
return this.observableHelper.notifyObservers(this, notificationType, value1, value2); |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
46 | 74 |
public void add(String name, DataStoreParameters parameters) { |
47 | 75 |
throw new UnsupportedOperationException(); |
48 | 76 |
} |
... | ... | |
82 | 110 |
|
83 | 111 |
@Override |
84 | 112 |
public boolean addRepository(StoresRepository repository) { |
113 |
if( this.notifyObservers(NOTIFICATION_ADDREPOSITORY, repository).isCanceled() ) { |
|
114 |
return false; |
|
115 |
} |
|
85 | 116 |
this.removeRepository(repository.getID()); |
86 | 117 |
this.subrepositories.add(repository); |
87 | 118 |
return true; |
... | ... | |
89 | 120 |
|
90 | 121 |
@Override |
91 | 122 |
public boolean removeRepository(String name) { |
123 |
if( this.notifyObservers(NOTIFICATION_REMOVEREPOSITORY, name).isCanceled() ) { |
|
124 |
return false; |
|
125 |
} |
|
92 | 126 |
for (int i = 0; i < subrepositories.size(); i++) { |
93 | 127 |
StoresRepository repo = subrepositories.get(i); |
94 | 128 |
if( StringUtils.equalsIgnoreCase(name, repo.getID()) ) { |
Also available in: Unified diff