Ticket #9491: 9491.patch

File 9491.patch, 3.5 KB (added by simon04, 9 years ago)
  • src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    diff --git a/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java b/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
    index ecece99..80d722e 100644
    a b private static Command getLastCommand() {  
    807807    }
    808808
    809809    /**
    810      * Present warning in case of large and possibly unwanted movements and undo
    811      * unwanted movements.
     810     * Present warning in the follwing cases and undo unwanted movements: <ul>
     811     * <li>large and possibly unwanted movements</li>
     812     * <li>movement of node with attached ways that are hidden by filters</li>
    812813     *
    813814     * @param e the mouse event causing the action (mouse released)
    814815     */
    815816    private void confirmOrUndoMovement(MouseEvent e) {
     817        boolean movesHiddenPrimitive = false;
     818        for (OsmPrimitive osm : getCurrentDataSet().getSelected()) {
     819            for (Way ref : OsmPrimitive.getFilteredList(osm.getReferrers(), Way.class)) {
     820                if (ref.isDisabledAndHidden()) {
     821                    movesHiddenPrimitive = true;
     822                    break;
     823                }
     824            }
     825        }
     826        if (movesHiddenPrimitive) {
     827            ExtendedDialog ed = new ConfirmMoveDialog();
     828            ed.setContent(tr("Are you sure that you want to move node with attached ways that are hidden by filters?"));
     829            ed.showDialog();
     830            if (ed.getValue() != 1) {
     831                Main.main.undoRedo.undo();
     832            }
     833        }
    816834        int max = Main.pref.getInteger("warn.move.maxelements", 20), limit = max;
    817835        for (OsmPrimitive osm : getCurrentDataSet().getSelected()) {
    818836            if (osm instanceof Way) {
    private void confirmOrUndoMovement(MouseEvent e) {  
    823841            }
    824842        }
    825843        if (limit < 0) {
    826             ExtendedDialog ed = new ExtendedDialog(
    827                     Main.parent,
    828                     tr("Move elements"),
    829                     new String[]{tr("Move them"), tr("Undo move")});
    830             ed.setButtonIcons(new String[]{"reorder", "cancel"});
     844            ExtendedDialog ed = new ConfirmMoveDialog();
    831845            ed.setContent(
    832846                    /* for correct i18n of plural forms - see #9110 */
    833847                    trn("You moved more than {0} element. " + "Moving a large number of elements is often an error.\n" + "Really move them?",
    834848                        "You moved more than {0} elements. " + "Moving a large number of elements is often an error.\n" + "Really move them?",
    835849                        max, max));
    836             ed.setCancelButton(2);
    837             ed.toggleEnable("movedManyElements");
    838850            ed.showDialog();
    839851
    840852            if (ed.getValue() != 1) {
    private void confirmOrUndoMovement(MouseEvent e) {  
    848860        getCurrentDataSet().fireSelectionChanged();
    849861    }
    850862
     863    static class ConfirmMoveDialog extends ExtendedDialog {
     864        public ConfirmMoveDialog() {
     865            super(Main.parent,
     866                    tr("Move elements"),
     867                    new String[]{tr("Move them"), tr("Undo move")});
     868            setButtonIcons(new String[]{"reorder", "cancel"});
     869            setCancelButton(2);
     870            toggleEnable("movedManyElements");
     871        }
     872    }
     873
    851874    /**
    852875     * Merges the selected nodes to the one closest to the given mouse position if the control
    853876     * key is pressed. If there is no such node, no action will be done and no error will be