Revision 37595 branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/undo/command/FeatureUpdateCommand.java
FeatureUpdateCommand.java | ||
---|---|---|
82 | 82 |
*/ |
83 | 83 |
package org.gvsig.fmap.dal.feature.impl.undo.command; |
84 | 84 |
|
85 |
import org.gvsig.fmap.dal.exception.DataException; |
|
86 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
85 | 87 |
import org.gvsig.fmap.dal.feature.Feature; |
86 |
import org.gvsig.fmap.dal.feature.impl.FeatureManager; |
|
87 |
import org.gvsig.fmap.dal.feature.impl.SpatialManager; |
|
88 |
import org.gvsig.tools.undo.RedoException; |
|
88 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore; |
|
89 | 89 |
import org.gvsig.tools.undo.UndoException; |
90 | 90 |
|
91 | 91 |
|
... | ... | |
96 | 96 |
*/ |
97 | 97 |
public class FeatureUpdateCommand extends AbstractFeatureCommand { |
98 | 98 |
private Feature oldFeature; |
99 |
private int position=-1; |
|
100 | 99 |
|
101 |
public FeatureUpdateCommand(FeatureManager expansionManager,
|
|
102 |
SpatialManager spatialManager, Feature feature, Feature oldFeature, String description) {
|
|
103 |
super(expansionManager, spatialManager, feature, description);
|
|
100 |
public FeatureUpdateCommand(DefaultFeatureStore featureStore,
|
|
101 |
Feature feature, Feature oldFeature, String description) { |
|
102 |
super(featureStore, feature, description);
|
|
104 | 103 |
this.oldFeature = oldFeature; |
105 | 104 |
} |
106 | 105 |
|
107 |
/* (non-Javadoc) |
|
108 |
* @see org.gvsig.fmap.dal.commands.Command#undo() |
|
109 |
*/ |
|
110 | 106 |
public void undo() throws UndoException { |
111 |
// if (expansionManager.contains(oldFeature.getReference())) { |
|
112 |
// expansionManager.deleteLastFeature(feature.getReference()); |
|
113 |
// } else { |
|
114 |
// expansionManager.delete(feature.getReference()); |
|
115 |
// } |
|
116 |
|
|
117 |
expansionManager.restore(oldFeature.getReference(),position); |
|
118 |
spatialManager.updateFeature(oldFeature, feature); |
|
107 |
try { |
|
108 |
featureStore.doUpdate(oldFeature.getEditable(), |
|
109 |
((EditableFeature)feature).getNotEditableCopy()); |
|
110 |
} catch (DataException e) { |
|
111 |
throw new UndoException(this, e); |
|
112 |
} |
|
119 | 113 |
} |
120 | 114 |
|
121 |
/* (non-Javadoc) |
|
122 |
* @see org.gvsig.fmap.dal.commands.Command#redo() |
|
123 |
*/ |
|
124 |
public void redo() throws RedoException { |
|
125 |
execute(); |
|
126 |
} |
|
127 |
|
|
128 | 115 |
public int getType() { |
129 | 116 |
return UPDATE; |
130 | 117 |
} |
131 |
|
|
132 |
/* (non-Javadoc) |
|
133 |
* @see org.gvsig.fmap.dal.commands.Command#execute() |
|
134 |
*/ |
|
135 |
public void execute() { |
|
136 |
// Si la geometr?a no ha sido modificada |
|
137 |
// if (!expansionManager.contains(oldFeature.getReference())) { |
|
138 |
// if (expansionManager.delete(oldFeature.getReference())!=null){ |
|
139 |
// expansionManager.add(feature); |
|
140 |
// } else { |
|
141 |
position = expansionManager.update(feature, oldFeature); |
|
142 |
// } |
|
143 |
|
|
144 |
spatialManager.updateFeature(feature, oldFeature); //setFullExtentDirty(true); |
|
118 |
|
|
119 |
public void execute() throws DataException { |
|
120 |
featureStore.doUpdate((EditableFeature)feature, oldFeature); |
|
145 | 121 |
} |
146 | 122 |
|
147 | 123 |
public Feature getOldFeature() { |
Also available in: Unified diff