Ignore:
Timestamp:
2017-06-04T20:59:41+02:00 (7 years ago)
Author:
michael2402
Message:

Add a method to undo/redo to get the last command.

File:
1 edited

Legend:

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

    r12314 r12316  
    809809     */
    810810    private static Command getLastCommandInDataset(DataSet ds) {
    811         LinkedList<Command> commands = Main.main.undoRedo.commands;
    812         if (!commands.isEmpty()) {
    813             Command lastCommand = commands.getLast();
    814             if (lastCommand instanceof SequenceCommand) {
    815                 lastCommand = ((SequenceCommand) lastCommand).getLastCommand();
    816             }
    817             if (ds.equals(lastCommand.getAffectedDataSet())) {
    818                 return lastCommand;
    819             }
    820         }
    821         return null;
     811        Command lastCommand = Main.main.undoRedo.getLastCommand();
     812        if (lastCommand instanceof SequenceCommand) {
     813            lastCommand = ((SequenceCommand) lastCommand).getLastCommand();
     814        }
     815        if (lastCommand != null && ds.equals(lastCommand.getAffectedDataSet())) {
     816            return lastCommand;
     817        } else {
     818            return null;
     819        }
    822820    }
    823821
Note: See TracChangeset for help on using the changeset viewer.