Changeset 18274 in josm for trunk/src/org


Ignore:
Timestamp:
2021-10-13T11:17:10+02:00 (3 years ago)
Author:
GerdP
Message:

fix #20899: Improve Way Accuracy Action: Warn when moving elements by a large distance
(patch w-confirmMovement.patch by ljdelight)
This patch updates the W-shortcut logic to check for nodes that move a large distance and show a warning dialog.

Location:
trunk/src/org/openstreetmap/josm/actions/mapmode
Files:
2 edited

Legend:

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

    r17896 r18274  
    512512                UndoRedoHandler.getInstance().add(
    513513                        new MoveCommand(candidateNode, cursorEN.east() - nodeEN.east(), cursorEN.north() - nodeEN.north()));
     514
     515                SelectAction.checkCommandForLargeDistance(UndoRedoHandler.getInstance().getLastCommand());
    514516            }
    515517        }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r17896 r18274  
    838838            showConfirmMoveDialog(ed);
    839839        }
     840
    840841        final Command lastCommand = UndoRedoHandler.getInstance().getLastCommand();
    841842        if (lastCommand == null) {
     
    843844            return;
    844845        }
     846
     847        SelectAction.checkCommandForLargeDistance(lastCommand);
     848
     849        final int moveCount = lastCommand.getParticipatingPrimitives().size();
     850        final int max = Config.getPref().getInt("warn.move.maxelements", 20);
     851        if (moveCount > max) {
     852            final ConfirmMoveDialog ed = new ConfirmMoveDialog();
     853            ed.setContent(
     854                    /* for correct i18n of plural forms - see #9110 */
     855                    trn("You moved more than {0} element. " + "Moving a large number of elements is often an error.\n" + "Really move them?",
     856                        "You moved more than {0} elements. " + "Moving a large number of elements is often an error.\n" + "Really move them?",
     857                        max, max));
     858            ed.toggleEnable("movedManyElements");
     859            showConfirmMoveDialog(ed);
     860        } else {
     861            // if small number of elements were moved,
     862            updateKeyModifiers(e);
     863            if (ctrl) mergePrims(e.getPoint());
     864        }
     865    }
     866
     867    static void checkCommandForLargeDistance(Command lastCommand) {
    845868        final int moveCount = lastCommand.getParticipatingPrimitives().size();
    846869        if (lastCommand instanceof MoveCommand) {
     
    858881            }
    859882        }
    860         int max = Config.getPref().getInt("warn.move.maxelements", 20);
    861         if (moveCount > max) {
    862             final ConfirmMoveDialog ed = new ConfirmMoveDialog();
    863             ed.setContent(
    864                     /* for correct i18n of plural forms - see #9110 */
    865                     trn("You moved more than {0} element. " + "Moving a large number of elements is often an error.\n" + "Really move them?",
    866                         "You moved more than {0} elements. " + "Moving a large number of elements is often an error.\n" + "Really move them?",
    867                         max, max));
    868             ed.toggleEnable("movedManyElements");
    869             showConfirmMoveDialog(ed);
    870         } else {
    871             // if small number of elements were moved,
    872             updateKeyModifiers(e);
    873             if (ctrl) mergePrims(e.getPoint());
    874         }
    875     }
    876 
    877     private void showConfirmMoveDialog(ConfirmMoveDialog ed) {
     883    }
     884
     885    private static void showConfirmMoveDialog(ConfirmMoveDialog ed) {
    878886        if (ed.showDialog().getValue() != 1) {
    879887            UndoRedoHandler.getInstance().undo();
Note: See TracChangeset for help on using the changeset viewer.