Ignore:
Timestamp:
2020-05-15T09:34:10+02:00 (5 years ago)
Author:
gerdp
Message:

see #josm17196: Undo changes inactive layer

  • change plugins which use direct access on UndoRedoHandler.getInstance().commands or UndoRedoHandler.getInstance().redoCommands

These fields should be private to allow a refactoring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysAction.java

    r34489 r35450  
    4545            return;
    4646
    47         Collection<Node> affectableNodes = AlignWaysSegmentMgr.getInstance(
    48                 MainApplication.getMap().mapView).getSelectedNodes();
     47        Collection<Node> affectableNodes = AlignWaysSegmentMgr.getInstance(MainApplication.getMap().mapView)
     48                        .getSelectedNodes();
    4949
    5050        // c is the last command launched, if any
    51         Command c = !UndoRedoHandler.getInstance().commands.isEmpty() ? UndoRedoHandler.getInstance().commands
    52                 .getLast() : null;
     51        Command c = UndoRedoHandler.getInstance().getLastCommand();
    5352
    54                 // Potentially add my type of command only if last command wasn't my type
    55                 // or, if it was, the rotated nodes were not the same as now
    56                 if (!(c instanceof AlignWaysCmdKeepLength && affectableNodes
    57                         .equals(((AlignWaysCmdKeepLength) c).getPrevAffectedNodes()))) {
     53        // Potentially add my type of command only if last command wasn't my type
     54        // or, if it was, the rotated nodes were not the same as now
     55        if (!(c instanceof AlignWaysCmdKeepLength
     56                && affectableNodes.equals(((AlignWaysCmdKeepLength) c).getPrevAffectedNodes()))) {
    5857
    59                     AlignWaysCmdKeepLength cmdAW;
    60                     if (AlignWaysPlugin.getAwDialog().getAwOpt() == AligningModeOption.ALGN_OPT_KEEP_ANGLE) {
    61                         cmdAW = new AlignWaysCmdKeepAngles(ds);
    62                     } else {
    63                         cmdAW = new AlignWaysCmdKeepLength(ds);
    64                     }
     58            AlignWaysCmdKeepLength cmdAW;
     59            if (AlignWaysPlugin.getAwDialog().getAwOpt() == AligningModeOption.ALGN_OPT_KEEP_ANGLE) {
     60                cmdAW = new AlignWaysCmdKeepAngles(ds);
     61            } else {
     62                cmdAW = new AlignWaysCmdKeepLength(ds);
     63            }
    6564
    66                     if (cmdAW.executable()) {
    67                         // This will also trigger AlignWaysCmdKeepLength.executeCommand()
    68                         UndoRedoHandler.getInstance().add(cmdAW);
    69                     }
    70                 }
     65            if (cmdAW.executable()) {
     66                // This will also trigger AlignWaysCmdKeepLength.executeCommand()
     67                UndoRedoHandler.getInstance().add(cmdAW);
     68            }
     69        }
    7170
    72                 MainApplication.getMap().mapView.repaint();
    73 
    74                 return;
     71        MainApplication.getMap().mapView.repaint();
    7572    }
    7673}
Note: See TracChangeset for help on using the changeset viewer.