root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / impl / commands / implementation / FeatureCommandsRecord.java @ 24496
History | View | Annotate | Download (4.62 KB)
1 |
package org.gvsig.fmap.dal.feature.impl.commands.implementation; |
---|---|
2 |
|
3 |
import org.gvsig.fmap.dal.exceptions.DataException; |
4 |
import org.gvsig.fmap.dal.feature.*; |
5 |
import org.gvsig.fmap.dal.feature.impl.*; |
6 |
import org.gvsig.fmap.dal.feature.impl.commands.AbstractCommand; |
7 |
import org.gvsig.fmap.dal.feature.impl.commands.AbstractCommandsRecord; |
8 |
|
9 |
/**
|
10 |
* Clase en memoria para registrar y gestionar los comandos que vamos
|
11 |
* realizando. La forma en que ha sido implementada esta clase, en vez de una
|
12 |
* ?nica lista para albergar los comandos de deshacer(undos) y los de
|
13 |
* rehacer(redos), se ha optado por dos pilas una para deshacer(undos) y otra
|
14 |
* para rehacer(redos), de esta forma : Cuando se a?ade un nuevo comando, se
|
15 |
* inserta este a la pila de deshacer(undos) y se borra de la de
|
16 |
* rehacer(redos). Si se realiza un deshacer se desapila este comando de la
|
17 |
* pila deshacer(undos) y se apila en la de rehacer(redos). Y de la misma
|
18 |
* forma cuando se realiza un rehacer se desapila este comando de la pila de
|
19 |
* rehacer(redos) y pasa a la de deshacer(undos).
|
20 |
*
|
21 |
* @author Vicente Caballero Navarro
|
22 |
*/
|
23 |
public class FeatureCommandsRecord extends AbstractCommandsRecord { |
24 |
private FeatureManager expansionManager;
|
25 |
private SpatialManager spatialManager;
|
26 |
private FeatureTypeManager featureTypeManager;
|
27 |
|
28 |
public FeatureCommandsRecord(FeatureManager expansionManager,
|
29 |
SpatialManager spatialManager, FeatureTypeManager featureTypeManager) { |
30 |
this.expansionManager=expansionManager;
|
31 |
this.spatialManager=spatialManager;
|
32 |
this.featureTypeManager=featureTypeManager;
|
33 |
} |
34 |
public void insert(Object obj) { |
35 |
AbstractCommand command = null;
|
36 |
if (obj instanceof Feature){ |
37 |
Feature feature=(Feature)obj; |
38 |
command=new FeatureInsertCommand(expansionManager,spatialManager, feature);
|
39 |
}else if (obj instanceof FeatureType){ |
40 |
FeatureType type=(FeatureType)obj; |
41 |
command=new FeatureTypeInsertCommand(featureTypeManager,type);
|
42 |
}else{
|
43 |
throw new RuntimeException("Object not supported by any command"); |
44 |
} |
45 |
add(command); |
46 |
command.execute(); |
47 |
} |
48 |
public void delete(Object obj) { |
49 |
AbstractCommand command = null;
|
50 |
if (obj instanceof Feature){ |
51 |
Feature feature=(Feature)obj; |
52 |
command=new FeatureDeleteCommand(expansionManager,spatialManager, feature);
|
53 |
}else if (obj instanceof FeatureType){ |
54 |
FeatureType type=(FeatureType)obj; |
55 |
command=new FeatureTypeDeleteCommand(featureTypeManager,type);
|
56 |
}else{
|
57 |
throw new RuntimeException("Object not supported by any command"); |
58 |
} |
59 |
add(command); |
60 |
command.execute(); |
61 |
} |
62 |
public void update(Object obj, Object oldObj) { |
63 |
AbstractCommand command = null;
|
64 |
if (obj instanceof Feature){ |
65 |
Feature feature=(Feature)obj; |
66 |
Feature oldFeature=(Feature)oldObj; |
67 |
command=new FeatureUpdateCommand(expansionManager,spatialManager, feature, oldFeature);
|
68 |
}else if (obj instanceof FeatureType){ |
69 |
FeatureType type=(FeatureType)obj; |
70 |
FeatureType oldType=(FeatureType)obj; |
71 |
command=new FeatureTypeUpdateCommand(featureTypeManager,type,oldType);
|
72 |
}else{
|
73 |
throw new RuntimeException("Object not supported by any command"); |
74 |
} |
75 |
add(command); |
76 |
command.execute(); |
77 |
} |
78 |
|
79 |
public void clear() { |
80 |
super.clear();
|
81 |
expansionManager.clear(); |
82 |
featureTypeManager.clear(); |
83 |
spatialManager.clear(); |
84 |
} |
85 |
|
86 |
public void deselect(FeatureReferenceSelection selection, |
87 |
FeatureReference reference) { |
88 |
AbstractCommand command = new SelectionCommandSelect(selection,
|
89 |
reference, false);
|
90 |
add(command); |
91 |
command.execute(); |
92 |
} |
93 |
|
94 |
public void deselectAll( |
95 |
FeatureReferenceSelection selection) |
96 |
throws DataException {
|
97 |
AbstractCommand command = new SelectionCommandSelectAll(selection,
|
98 |
false);
|
99 |
add(command); |
100 |
command.execute(); |
101 |
} |
102 |
|
103 |
public void select(FeatureReferenceSelection selection, |
104 |
FeatureReference reference) { |
105 |
AbstractCommand command = new SelectionCommandSelect(selection,
|
106 |
reference, true);
|
107 |
add(command); |
108 |
command.execute(); |
109 |
} |
110 |
|
111 |
public void selectAll( |
112 |
FeatureReferenceSelection selection) |
113 |
throws DataException {
|
114 |
AbstractCommand command = new SelectionCommandSelectAll(selection, true); |
115 |
add(command); |
116 |
command.execute(); |
117 |
} |
118 |
|
119 |
public void selectionReverse( |
120 |
FeatureReferenceSelection selection) { |
121 |
AbstractCommand command = new SelectionCommandReverse(selection);
|
122 |
add(command); |
123 |
command.execute(); |
124 |
} |
125 |
|
126 |
public void selectionSet(DefaultFeatureStore store, |
127 |
FeatureReferenceSelection oldSelection, |
128 |
FeatureReferenceSelection newSelection) { |
129 |
AbstractCommand command = new SelectionCommandSet(store, oldSelection,
|
130 |
newSelection); |
131 |
add(command); |
132 |
command.execute(); |
133 |
} |
134 |
|
135 |
} |