Ticket #5209: josm_5209.patch

File josm_5209.patch, 3.0 KB (added by ax, 15 years ago)
  • data/UndoRedoHandler.java

    public class UndoRedoHandler implements MapView.La  
    7373        if (commands.isEmpty())
    7474            return;
    7575        Collection<? extends OsmPrimitive> oldSelection = Main.main.getCurrentDataSet().getSelected();
    76         for (int i=1; i<=num; ++i) {
    77             final Command c = commands.removeLast();
    78             c.undoCommand();
    79             redoCommands.addFirst(c);
    80             if (commands.isEmpty()) {
    81                 break;
     76        Main.main.getCurrentDataSet().beginUpdate();
     77        try {
     78            for (int i=1; i<=num; ++i) {
     79                final Command c = commands.removeLast();
     80                c.undoCommand();
     81                redoCommands.addFirst(c);
     82                if (commands.isEmpty()) {
     83                    break;
     84                }
    8285            }
    8386        }
     87        finally {
     88            Main.main.getCurrentDataSet().endUpdate();
     89        }
    8490        fireCommandsChanged();
    8591        Collection<? extends OsmPrimitive> newSelection = Main.main.getCurrentDataSet().getSelected();
    8692        if (!oldSelection.equals(newSelection)) {
  • command/ChangePropertyCommand.java

    import java.util.List;  
    1212
    1313import javax.swing.JLabel;
    1414
     15import org.openstreetmap.josm.Main;
    1516import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1617import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1718import org.openstreetmap.josm.gui.DefaultNameFormatter;
    public class ChangePropertyCommand extends Command  
    7273    }
    7374
    7475    @Override public boolean executeCommand() {
    75         super.executeCommand(); // save old
    76         if (value == null) {
    77             for (OsmPrimitive osm : objects) {
    78                 osm.setModified(true);
    79                 osm.remove(key);
     76        Main.main.getCurrentDataSet().beginUpdate();
     77        try {
     78            super.executeCommand(); // save old
     79            if (value == null) {
     80                for (OsmPrimitive osm : objects) {
     81                    osm.setModified(true);
     82                    osm.remove(key);
     83                }
     84            } else {
     85                for (OsmPrimitive osm : objects) {
     86                    osm.setModified(true);
     87                    osm.put(key, value);
     88                }
    8089            }
    81         } else {
    82             for (OsmPrimitive osm : objects) {
    83                 osm.setModified(true);
    84                 osm.put(key, value);
    85             }
     90            return true;
    8691        }
    87         return true;
     92        finally {
     93            Main.main.getCurrentDataSet().endUpdate();
     94        }
    8895    }
    8996
    9097    @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {