Interface CommandStack

All Known Implementing Classes:
BasicCommandStack

public interface CommandStack
A simple and obvious interface for an undoable stack of commands with a listener. See Command for more details about the command methods that this implementation uses and CommandStackListener for details about the listener.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a listener to the command stack, which will be notified whenever a command has been processed on the stack.
    boolean
    Returns whether there are commands past the top of the stack that can be redone.
    boolean
    Returns whether the top command on the stack can be undone.
    void
    execute(Command command)
    Clears any redoable commands not yet redone, adds the command, and then executes the command.
    void
    Disposes all the commands in the stack.
    Returns the command most recently executed, undone, or redone.
    Returns the command that will be redone if redo() is called.
    Returns the command that will be undone if undo() is called.
    void
    Moves the top of the stack up, redoing the new top command.
    void
    Removes a listener from the command stack.
    void
    Moves the top of the stack down, undoing what was formerly the top command.
  • Method Details

    • execute

      void execute(Command command)
      Clears any redoable commands not yet redone, adds the command, and then executes the command.
      Parameters:
      command - the command to execute.
    • canUndo

      boolean canUndo()
      Returns whether the top command on the stack can be undone.
      Returns:
      whether the top command on the stack can be undone.
    • undo

      void undo()
      Moves the top of the stack down, undoing what was formerly the top command.
    • canRedo

      boolean canRedo()
      Returns whether there are commands past the top of the stack that can be redone.
      Returns:
      whether there are commands past the top of the stack that can be redone.
    • getUndoCommand

      Command getUndoCommand()
      Returns the command that will be undone if undo() is called.
      Returns:
      the command that will be undone if undo() is called.
    • getRedoCommand

      Command getRedoCommand()
      Returns the command that will be redone if redo() is called.
      Returns:
      the command that will be redone if redo() is called.
    • getMostRecentCommand

      Command getMostRecentCommand()
      Returns the command most recently executed, undone, or redone.
      Returns:
      the command most recently executed, undone, or redone.
    • redo

      void redo()
      Moves the top of the stack up, redoing the new top command.
    • flush

      void flush()
      Disposes all the commands in the stack.
    • addCommandStackListener

      void addCommandStackListener(CommandStackListener listener)
      Adds a listener to the command stack, which will be notified whenever a command has been processed on the stack.
      Parameters:
      listener - the listener to add.
    • removeCommandStackListener

      void removeCommandStackListener(CommandStackListener listener)
      Removes a listener from the command stack.
      Parameters:
      listener - the listener to remove.