Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / impl / undo / DefaultFeatureCommandsStack.java @ 37595

History | View | Annotate | Download (5.55 KB)

1
package org.gvsig.fmap.dal.feature.impl.undo;
2

    
3
import org.gvsig.fmap.dal.exception.DataException;
4
import org.gvsig.fmap.dal.feature.Feature;
5
import org.gvsig.fmap.dal.feature.FeatureReference;
6
import org.gvsig.fmap.dal.feature.FeatureSelection;
7
import org.gvsig.fmap.dal.feature.FeatureType;
8
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureReferenceSelection;
9
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore;
10
import org.gvsig.fmap.dal.feature.impl.FeatureManager;
11
import org.gvsig.fmap.dal.feature.impl.FeatureTypeManager;
12
import org.gvsig.fmap.dal.feature.impl.SpatialManager;
13
import org.gvsig.fmap.dal.feature.impl.undo.command.FTypeUpdateCommand;
14
import org.gvsig.fmap.dal.feature.impl.undo.command.FeatureDeleteCommand;
15
import org.gvsig.fmap.dal.feature.impl.undo.command.FeatureInsertCommand;
16
import org.gvsig.fmap.dal.feature.impl.undo.command.FeatureUpdateCommand;
17
import org.gvsig.fmap.dal.feature.impl.undo.command.SelectionCommandReverse;
18
import org.gvsig.fmap.dal.feature.impl.undo.command.SelectionCommandSelect;
19
import org.gvsig.fmap.dal.feature.impl.undo.command.SelectionCommandSelectAll;
20
import org.gvsig.fmap.dal.feature.impl.undo.command.SelectionCommandSet;
21
import org.gvsig.tools.undo.command.impl.DefaultUndoRedoCommandStack;
22

    
23
/**
24
 * Clase en memoria para registrar y gestionar los comandos que vamos
25
 * realizando. La forma en que ha sido implementada esta clase, en vez de una
26
 * ?nica lista para albergar los comandos de deshacer(undos) y los de
27
 * rehacer(redos), se ha optado por dos pilas una para deshacer(undos) y otra
28
 * para rehacer(redos), de esta forma : Cuando se a?ade un nuevo comando, se
29
 * inserta este a la pila de deshacer(undos) y se borra de la de rehacer(redos).
30
 * Si se realiza un deshacer se desapila este comando de la pila deshacer(undos)
31
 * y se apila en la de rehacer(redos). Y de la misma forma cuando se realiza un
32
 * rehacer se desapila este comando de la pila de rehacer(redos) y pasa a la de
33
 * deshacer(undos).
34
 *
35
 * @author Vicente Caballero Navarro
36
 */
37
public class DefaultFeatureCommandsStack extends DefaultUndoRedoCommandStack
38
        implements FeatureCommandsStack {
39
    private FeatureManager expansionManager;
40
    private SpatialManager spatialManager;
41
    private FeatureTypeManager featureTypeManager;
42
    private DefaultFeatureStore featureStore;
43

    
44
    public DefaultFeatureCommandsStack(DefaultFeatureStore featureStore,
45
        FeatureManager expansionManager, SpatialManager spatialManager, 
46
        FeatureTypeManager featureTypeManager) {
47
        this.featureStore = featureStore;
48
        this.expansionManager = expansionManager;
49
        this.spatialManager = spatialManager;
50
        this.featureTypeManager = featureTypeManager;
51
    }
52

    
53
    public void clear() {
54
        super.clear();
55
        expansionManager.clear();
56
        featureTypeManager.clear();
57
        spatialManager.clear();
58
    }
59

    
60
    public void deselect(DefaultFeatureReferenceSelection selection,
61
            FeatureReference reference) {
62
        SelectionCommandSelect command = new SelectionCommandSelect(selection,
63
                reference, false, "_selectionDeselect");
64
        add(command);
65
    }
66

    
67
    public void deselectAll(DefaultFeatureReferenceSelection selection)
68
            throws DataException {
69
        SelectionCommandSelectAll command = new SelectionCommandSelectAll(
70
                selection, false, "_selectionDeselectAll");
71
        add(command);
72
    }
73

    
74
    public void select(DefaultFeatureReferenceSelection selection,
75
            FeatureReference reference) {
76
        SelectionCommandSelect command = new SelectionCommandSelect(selection,
77
                reference, true, "_selectionSelect");
78
        add(command);
79
    }
80

    
81
    public void selectAll(DefaultFeatureReferenceSelection selection)
82
            throws DataException {
83
        SelectionCommandSelectAll command = new SelectionCommandSelectAll(
84
                selection, true, "_selectionSelectAll");
85
        add(command);
86
    }
87

    
88
    public void selectionReverse(DefaultFeatureReferenceSelection selection) {
89
        SelectionCommandReverse command = new SelectionCommandReverse(
90
                selection, "_selectionReverse");
91
        add(command);
92
    }
93

    
94
    public void selectionSet(DefaultFeatureStore store,
95
            FeatureSelection oldSelection, FeatureSelection newSelection) {
96
        SelectionCommandSet command = new SelectionCommandSet(store,
97
                oldSelection, newSelection, "_selectionSet");
98
        add(command);
99
    }
100

    
101
    public void delete(Feature feature) throws DataException {
102
        FeatureDeleteCommand command = new FeatureDeleteCommand(featureStore,
103
                feature, "_featureDelete");
104
        add(command);
105
        command.execute();
106
    }
107

    
108
    public void insert(Feature feature) throws DataException {
109
        FeatureInsertCommand command = new FeatureInsertCommand(featureStore,
110
                feature, "_featureInsert");
111
        add(command);
112
        command.execute();
113
    }
114

    
115
    public void update(Feature feature, Feature oldFeature) throws DataException {
116
        FeatureUpdateCommand command = new FeatureUpdateCommand(featureStore,
117
               feature, oldFeature,
118
                "_featureUpdate");
119
        add(command);
120
        command.execute();
121
    }
122

    
123
    public void update(FeatureType featureType, FeatureType oldFeatureType) {
124
        FTypeUpdateCommand command = new FTypeUpdateCommand(
125
                featureTypeManager, featureType, oldFeatureType,
126
                "_typeUpdate");
127
        add(command);
128
        command.execute();
129
    }
130

    
131
}