Revision 44377

View differences:

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
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()) ) {
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/BaseStoresRepository.java
52 52
        if( StringUtils.isBlank(name) ) {
53 53
            throw new IllegalArgumentException("name can't be blank.");
54 54
        }
55
        if( this.notifyObservers(NOTIFICATION_ADD, name, parameters).isCanceled() ) {
56
            return;
57
        }
55 58
        this.repository.put(name, parameters);
56 59
    }
57 60

  
......
61 64
            LOGGER.warn("parameter name can't be blank");
62 65
            return;
63 66
        }
67
        if( this.notifyObservers(NOTIFICATION_REMOVE, name).isCanceled() ) {
68
            return;
69
        }
64 70
        this.repository.remove(name);
65 71
    }
66 72
    
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/StoresRepository.java
1 1
package org.gvsig.fmap.dal;
2 2

  
3 3
import java.util.Collection;
4
import org.gvsig.tools.observer.Observable;
4 5
import org.gvsig.tools.util.UnmodifiableBasicMap;
5 6

  
6 7
/**
7 8
 *
8 9
 * @author jjdelcerro
9 10
 */
10
public interface StoresRepository extends UnmodifiableBasicMap<String, DataStoreParameters> {
11
public interface StoresRepository 
12
        extends 
13
            UnmodifiableBasicMap<String, DataStoreParameters>,
14
            Observable
15
    {
16
    
17
    public static final String NOTIFICATION_ADDREPOSITORY = "addRepository";
18
    public static final String NOTIFICATION_REMOVEREPOSITORY = "removeRepository";
19
    public static final String NOTIFICATION_ADD = "add";
20
    public static final String NOTIFICATION_REMOVE = "remove";
21
    
11 22

  
12 23
    public String getID();
13 24
    

Also available in: Unified diff