Ignore:
Timestamp:
2009-08-10T13:40:31+02:00 (15 years ago)
Author:
stoecker
Message:

applied josm 2755 (slightly modified)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java

    r16629 r16970  
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
     4
     5import java.awt.geom.Area;
    46
    57import java.util.Collection;
     
    79import java.util.List;
    810
     11import javax.swing.JOptionPane;
     12
     13import org.openstreetmap.josm.Main;
    914import org.openstreetmap.josm.actions.MergeNodesAction;
    1015import org.openstreetmap.josm.command.Command;
     
    1217import org.openstreetmap.josm.data.osm.Node;
    1318import org.openstreetmap.josm.data.osm.OsmPrimitive;
     19import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
    1420import org.openstreetmap.josm.plugins.validator.Severity;
    1521import org.openstreetmap.josm.plugins.validator.Test;
     
    9399            target = nodes.iterator().next();
    94100
    95         new  MergeNodesAction().mergeNodes(nodes, target);
     101        if(checkAndConfirmOutlyingDeletes(nodes))
     102            new MergeNodesAction().mergeNodes(nodes, target);
    96103
    97104        return null; // undoRedo handling done in mergeNodes
     
    103110        return (testError.getTester() instanceof DuplicateNode);
    104111    }
     112
     113    /**
     114     * Check whether user is about to delete data outside of the download area.
     115     * Request confirmation if he is.
     116     */
     117    private static boolean checkAndConfirmOutlyingDeletes(LinkedList<Node> del) {
     118        Area a = Main.main.getCurrentDataSet().getDataSourceArea();
     119        if (a != null) {
     120            for (OsmPrimitive osm : del) {
     121                if (osm instanceof Node && osm.id != 0) {
     122                    Node n = (Node) osm;
     123                    if (!a.contains(n.getCoor())) {
     124                        return ConditionalOptionPaneUtil.showConfirmationDialog(
     125                            "delete_outside_nodes",
     126                            Main.parent,
     127                            tr("You are about to delete nodes outside of the area you have downloaded." +
     128                                                "<br>" +
     129                                                "This can cause problems because other objects (that you don't see) might use them." +
     130                                                "<br>" +
     131                                        "Do you really want to delete?") + "</html>",
     132                            tr("Confirmation"),
     133                            JOptionPane.YES_NO_OPTION,
     134                            JOptionPane.QUESTION_MESSAGE,
     135                            JOptionPane.YES_OPTION);
     136                    }
     137                }
     138            }
     139        }
     140        return true;
     141    }
    105142}
Note: See TracChangeset for help on using the changeset viewer.