Ignore:
Timestamp:
2007-12-30T23:55:51+01:00 (16 years ago)
Author:
gebner
Message:

SelectAction: When complaining about moving nodes outsides the world, don't
leave the nodes there.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r484 r502  
    149149                if (mode == Mode.rotate && affectedNodes.size() < 2)
    150150                        return;
    151                
    152 
    153                 // check if any coordinate would be outside the world
    154                 for (OsmPrimitive osm : affectedNodes) {
    155                         if (osm instanceof Node && ((Node)osm).coor.isOutSideWorld()) {
    156                                 JOptionPane.showMessageDialog(Main.parent,
    157                                         tr("Cannot move objects outside of the world."));
    158                                 return;
    159                         }
    160                 }
     151
    161152                Command c = !Main.main.undoRedo.commands.isEmpty()
    162153                        ? Main.main.undoRedo.commands.getLast() : null;
     
    166157                                ((MoveCommand)c).moveAgain(dx,dy);
    167158                        else
    168                                 Main.main.undoRedo.add(new MoveCommand(selection, dx, dy));
     159                                Main.main.undoRedo.add(
     160                                        c = new MoveCommand(selection, dx, dy));
     161
     162                        for (Node n : affectedNodes) {
     163                                if (n.coor.isOutSideWorld()) {
     164                                        // Revert move
     165                                        ((MoveCommand) c).moveAgain(-dx, -dy);
     166
     167                                        JOptionPane.showMessageDialog(Main.parent,
     168                                                tr("Cannot move objects outside of the world."));
     169                                        return;
     170                                }
     171                        }
    169172                } else if (mode == Mode.rotate) {
    170173                        if (c instanceof RotateCommand && affectedNodes.equals(((RotateCommand)c).objects))
Note: See TracChangeset for help on using the changeset viewer.