Class CmdHandler


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

      • instance

        private static CmdHandler instance
        Singleton command handler
      • undoStack

        private final Deque<Command> undoStack
        Undo stack
    • Constructor Detail

      • CmdHandler

        private CmdHandler()
        Private constructor
    • 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
      • undoCmd

        public void undoCmd()
        Undoes the last command from the undo stack.