| 1 | Index: src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java
|
|---|
| 2 | ===================================================================
|
|---|
| 3 | --- src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java (revision 16489)
|
|---|
| 4 | +++ src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java (working copy)
|
|---|
| 5 | @@ -2,8 +2,15 @@
|
|---|
| 6 |
|
|---|
| 7 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| 8 |
|
|---|
| 9 | +import java.awt.GridBagLayout;
|
|---|
| 10 | +import java.awt.geom.Area;
|
|---|
| 11 | import java.util.*;
|
|---|
| 12 |
|
|---|
| 13 | +import javax.swing.JLabel;
|
|---|
| 14 | +import javax.swing.JOptionPane;
|
|---|
| 15 | +import javax.swing.JPanel;
|
|---|
| 16 | +
|
|---|
| 17 | +import org.openstreetmap.josm.Main;
|
|---|
| 18 | import org.openstreetmap.josm.actions.MergeNodesAction;
|
|---|
| 19 | import org.openstreetmap.josm.command.*;
|
|---|
| 20 | import org.openstreetmap.josm.data.coor.LatLon;
|
|---|
| 21 | @@ -12,6 +19,7 @@
|
|---|
| 22 | import org.openstreetmap.josm.plugins.validator.Test;
|
|---|
| 23 | import org.openstreetmap.josm.plugins.validator.TestError;
|
|---|
| 24 | import org.openstreetmap.josm.plugins.validator.util.Bag;
|
|---|
| 25 | +import org.openstreetmap.josm.tools.DontShowAgainInfo;
|
|---|
| 26 | /**
|
|---|
| 27 | * Tests if there are duplicate nodes
|
|---|
| 28 | *
|
|---|
| 29 | @@ -89,7 +97,8 @@
|
|---|
| 30 | if (target == null)
|
|---|
| 31 | target = nodes.iterator().next();
|
|---|
| 32 |
|
|---|
| 33 | - MergeNodesAction.mergeNodes(nodes, target);
|
|---|
| 34 | + if(checkAndConfirmOutlyingDeletes(nodes))
|
|---|
| 35 | + MergeNodesAction.mergeNodes(nodes, target);
|
|---|
| 36 |
|
|---|
| 37 | return null; // undoRedo handling done in mergeNodes
|
|---|
| 38 | }
|
|---|
| 39 | @@ -99,4 +108,33 @@
|
|---|
| 40 | {
|
|---|
| 41 | return (testError.getTester() instanceof DuplicateNode);
|
|---|
| 42 | }
|
|---|
| 43 | +
|
|---|
| 44 | + /**
|
|---|
| 45 | + * Check whether user is about to delete data outside of the download area.
|
|---|
| 46 | + * Request confirmation if he is.
|
|---|
| 47 | + */
|
|---|
| 48 | + private static boolean checkAndConfirmOutlyingDeletes(LinkedList<Node> del) {
|
|---|
| 49 | + Area a = Main.ds.getDataSourceArea();
|
|---|
| 50 | + if (a != null) {
|
|---|
| 51 | + for (OsmPrimitive osm : del) {
|
|---|
| 52 | + if (osm instanceof Node && osm.id != 0) {
|
|---|
| 53 | + Node n = (Node) osm;
|
|---|
| 54 | + if (!a.contains(n.getCoor())) {
|
|---|
| 55 | + JPanel msg = new JPanel(new GridBagLayout());
|
|---|
| 56 | + msg.add(new JLabel(
|
|---|
| 57 | + "<html>" +
|
|---|
| 58 | + // leave message in one tr() as there is a grammatical connection.
|
|---|
| 59 | + tr("You are about to delete nodes outside of the area you have downloaded." +
|
|---|
| 60 | + "<br>" +
|
|---|
| 61 | + "This can cause problems because other objects (that you don't see) might use them." +
|
|---|
| 62 | + "<br>" +
|
|---|
| 63 | + "Do you really want to delete?") + "</html>"));
|
|---|
| 64 | + return DontShowAgainInfo.show("delete_outside_nodes", msg, false, JOptionPane.YES_NO_OPTION, JOptionPane.YES_OPTION);
|
|---|
| 65 | + }
|
|---|
| 66 | +
|
|---|
| 67 | + }
|
|---|
| 68 | + }
|
|---|
| 69 | + }
|
|---|
| 70 | + return true;
|
|---|
| 71 | + }
|
|---|
| 72 | }
|
|---|