Ignore:
Timestamp:
2018-09-30T00:46:01+02:00 (6 years ago)
Author:
Don-vip
Message:

see #12726 - accessors for undo/redo commands

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java

    r14220 r14281  
    2525     *
    2626     * @see #getLastCommand()
     27     * @see #getUndoCommands()
    2728     */
    2829    public final LinkedList<Command> commands = new LinkedList<>();
     30
    2931    /**
    3032     * The stack for redoing commands
     33
     34     * @see #getRedoCommands()
    3135     */
    3236    public final LinkedList<Command> redoCommands = new LinkedList<>();
     
    232236
    233237    /**
     238     * Returns all commands that were made on the dataset, that can be undone.
     239     * @return all commands that were made on the dataset, that can be undone
     240     * @since 14281
     241     */
     242    public LinkedList<Command> getUndoCommands() {
     243        return new LinkedList<>(commands);
     244    }
     245
     246    /**
     247     * Returns all commands that were made and undone on the dataset, that can be redone.
     248     * @return all commands that were made and undone on the dataset, that can be redone.
     249     * @since 14281
     250     */
     251    public LinkedList<Command> getRedoCommands() {
     252        return new LinkedList<>(redoCommands);
     253    }
     254
     255    /**
    234256     * Gets the last command that was executed on the command stack.
    235257     * @return That command or <code>null</code> if there is no such command.
     
    238260    public Command getLastCommand() {
    239261        return commands.peekLast();
     262    }
     263
     264    /**
     265     * Determines if commands can be undone.
     266     * @return {14281 true} if at least a command can be undone
     267     * @since xxx
     268     */
     269    public boolean hasUndoCommands() {
     270        return !commands.isEmpty();
     271    }
     272
     273    /**
     274     * Determines if commands can be redone.
     275     * @return {@code true} if at least a command can be redone
     276     * @since 14281
     277     */
     278    public boolean hasRedoCommands() {
     279        return !redoCommands.isEmpty();
    240280    }
    241281
Note: See TracChangeset for help on using the changeset viewer.