Revision 46390

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/undo/command/FeatureDeleteCommand.java
26 26
import org.gvsig.fmap.dal.exception.DataException;
27 27
import org.gvsig.fmap.dal.feature.Feature;
28 28
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore;
29
import org.gvsig.fmap.dal.feature.impl.editing.memory.FeatureManager;
30
import org.gvsig.tools.undo.RedoException;
29 31
import org.gvsig.tools.undo.UndoException;
30 32

  
31 33

  
......
43 45

  
44 46
    public void undo() throws UndoException {
45 47
        try {
46
            featureStore.doInsert(feature.getEditable());
47
        } catch (DataException e) {
48
            FeatureManager featureManager = featureStore.getFeatureManager();
49
            featureManager.restore(feature.getReference());
50
        } catch (Exception e) {
48 51
            throw new UndoException(this, e);
49 52
        }
50 53
    }
51 54

  
55
    @Override
56
    public void redo() throws RedoException {
57
        try {
58
           featureStore.doDelete(feature);
59
        } catch (Exception e) {
60
            throw new RedoException(this, e);
61
        }
62
    }
63

  
52 64
    public int getType() {
53 65
        return DELETE;
54 66
    }
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/undo/command/FeatureInsertCommand.java
49 49
    @Override
50 50
    public void undo() throws UndoException {
51 51
       try {
52
           featureStore.doDelete(getFeature().getNotEditableCopy());
53
       } catch (DataException e) {
52
           featureStore.getFeatureManager().undoAdd(feature.getEditable());
53
       } catch (Exception e) {
54 54
           throw new UndoException(this, e);
55 55
       }
56 56
    }
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/editing/memory/FeatureManager.java
109 109
        deleted.remove(feature.getReference());
110 110
        deltaSize++;
111 111
    }
112
    
113
    public void undoAdd(EditableFeature feature) {
114
        FeatureReference id = feature.getReference();
115
        if(added.remove(id)!=null){
116
            deltaSize--;
117
        };
118
    }
112 119

  
113 120
    public Feature deleteLastFeature() {
114 121
        expansionAdapter.deleteLastObject();
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java
223 223
    private int mode = MODE_QUERY;
224 224
    private long versionOfUpdate = 0;
225 225
    private boolean hasStrongChanges = true;
226
    private boolean hasInserts = true;
227 226

  
228 227
    private DefaultDataManager dataManager = null;
229 228

  
......
1269 1268

  
1270 1269
        mode = MODE_QUERY;
1271 1270
        hasStrongChanges = true; // Lo deja a true por si las moscas
1272
        hasInserts = true;
1273 1271

  
1274 1272
        this.editingSessionCode = null;
1275 1273
    }
......
1313 1311
                            spatialManager, featureTypeManager);
1314 1312
                    this.mode = MODE_FULLEDIT;
1315 1313
                    hasStrongChanges = false;
1316
                    hasInserts = false;
1317 1314
                    notifyChange(FeatureStoreNotification.AFTER_STARTEDITING, newSessionCode, this.mode);
1318 1315
                    break;
1319 1316

  
......
1329 1326
                    invalidateIndexes();
1330 1327
                    this.provider.beginAppend();
1331 1328
                    this.mode = MODE_APPEND;
1332
                    hasInserts = false;
1333 1329
                    notifyChange(FeatureStoreNotification.AFTER_STARTEDITING,
1334 1330
                            newSessionCode, this.mode);
1335 1331
                    break;
......
1347 1343
                    this.editingSessionCode = newSessionCode;
1348 1344
                    invalidateIndexes();
1349 1345
                    this.mode = MODE_PASS_THROUGH;
1350
                    hasInserts = false;
1351 1346
                    notifyChange(FeatureStoreNotification.AFTER_STARTEDITING,
1352 1347
                            newSessionCode, this.mode);
1353 1348
                    break;
......
1631 1626
                    feature.validate(CHECK_RULES_AT_EDITING);
1632 1627
                    provider.append(((DefaultEditableFeature) feature).getData());
1633 1628
                    hasStrongChanges = true;
1634
                    hasInserts = true;
1635 1629
                    notifyChange(FeatureStoreNotification.AFTER_INSERT, feature);
1636 1630
                    break;
1637 1631

  
......
1685 1679
        spatialManager.insertFeature(newFeature);
1686 1680

  
1687 1681
        hasStrongChanges = true;
1688
        hasInserts = true;
1689 1682
        notifyChange(FeatureStoreNotification.AFTER_INSERT, feature);
1690 1683
    }
1691 1684

  
......
1897 1890
                case MODE_FULLEDIT:
1898 1891
                    boolean clearSelection = this.hasStrongChanges;
1899 1892
                    if (this.selection instanceof FeatureReferenceSelection) {
1900
                        clearSelection = this.hasInserts;
1893
                        clearSelection = this.hasStrongChanges || this.featureManager.hasNews();
1901 1894
                    }
1902
                    if (notifyChange(FeatureStoreNotification.BEFORE_CANCELEDITING).isCanceled()) {
1895
                    if (notifyChange(FeatureStoreNotification.BEFORE_CANCELEDITING,this.editingSessionCode).isCanceled()) {
1903 1896
                        return;
1904 1897
                    }
1905 1898
                    exitEditingMode();
......
1907 1900
                        ((FeatureSelection) this.getSelection()).deselectAll();
1908 1901
                    }
1909 1902
                    updateIndexes();
1910
                    notifyChange(FeatureStoreNotification.AFTER_CANCELEDITING);
1903
                    notifyChange(FeatureStoreNotification.AFTER_CANCELEDITING,this.editingSessionCode);
1911 1904
                    break;
1912 1905

  
1913 1906
                case MODE_PASS_THROUGH:
......
2183 2176
                    exitEditingMode();
2184 2177
                    invalidateIndexes();
2185 2178
                    this.provider.beginAppend();
2186
                    hasInserts = false;
2187 2179
                    break;
2188 2180

  
2189 2181
                case MODE_FULLEDIT:
......
2208 2200
                                    spatialManager, featureTypeManager);
2209 2201
                    featureCount = null;
2210 2202
                    hasStrongChanges = false;
2211
                    hasInserts = false;
2212 2203
                    break;
2213 2204
            }
2214 2205
        } catch (Exception e) {

Also available in: Unified diff