Index: src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java =================================================================== --- src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java (revision 16489) +++ src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java (working copy) @@ -2,8 +2,15 @@ import static org.openstreetmap.josm.tools.I18n.tr; +import java.awt.GridBagLayout; +import java.awt.geom.Area; import java.util.*; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; + +import org.openstreetmap.josm.Main; import org.openstreetmap.josm.actions.MergeNodesAction; import org.openstreetmap.josm.command.*; import org.openstreetmap.josm.data.coor.LatLon; @@ -12,6 +19,7 @@ import org.openstreetmap.josm.plugins.validator.Test; import org.openstreetmap.josm.plugins.validator.TestError; import org.openstreetmap.josm.plugins.validator.util.Bag; +import org.openstreetmap.josm.tools.DontShowAgainInfo; /** * Tests if there are duplicate nodes * @@ -89,7 +97,8 @@ if (target == null) target = nodes.iterator().next(); - MergeNodesAction.mergeNodes(nodes, target); + if(checkAndConfirmOutlyingDeletes(nodes)) + MergeNodesAction.mergeNodes(nodes, target); return null; // undoRedo handling done in mergeNodes } @@ -99,4 +108,33 @@ { return (testError.getTester() instanceof DuplicateNode); } + + /** + * Check whether user is about to delete data outside of the download area. + * Request confirmation if he is. + */ + private static boolean checkAndConfirmOutlyingDeletes(LinkedList del) { + Area a = Main.ds.getDataSourceArea(); + if (a != null) { + for (OsmPrimitive osm : del) { + if (osm instanceof Node && osm.id != 0) { + Node n = (Node) osm; + if (!a.contains(n.getCoor())) { + JPanel msg = new JPanel(new GridBagLayout()); + msg.add(new JLabel( + "" + + // leave message in one tr() as there is a grammatical connection. + tr("You are about to delete nodes outside of the area you have downloaded." + + "
" + + "This can cause problems because other objects (that you don't see) might use them." + + "
" + + "Do you really want to delete?") + "")); + return DontShowAgainInfo.show("delete_outside_nodes", msg, false, JOptionPane.YES_NO_OPTION, JOptionPane.YES_OPTION); + } + + } + } + } + return true; + } }