Class CmdHandler


  • public class CmdHandler
    extends Object
    Handler for commands. Allows undo and redo of commands.
    Author:
    Herbert Prähofer
    • Field Detail

      • instance

        private static CmdHandler instance
        Singleton command handler
      • undoStack

        private final Deque<Command> undoStack
        Undo stack
      • redoStack

        private final Deque<Command> redoStack
        Redo stack
    • Constructor Detail

      • CmdHandler

        public CmdHandler()
    • Method Detail

      • getInstance

        public static CmdHandler getInstance()
        Gets the singleton command handler.
        Returns:
        the singleton command handler
      • doCmd

        public void doCmd​(Command cmd)
        Executes the command and stores it in the undo stack.
        Parameters:
        cmd - the command to execute
      • undoCommand

        public void undoCommand()
        Undoes the last command from the undo stack.
      • redoCmd

        public void redoCmd()
        Undoes the last command from the redo stack.