Class CommandImpl

    • Constructor Detail

      • CommandImpl

        public CommandImpl()
        The default constructor. Initialises the current status to created.
    • Method Detail

      • flush

        public void flush()
        Description copied from interface: Command
        Flushes the command. Can be useful to close streams, free objects, etc. A command should flushed manually only when it is not managed by the cmd registry of the application. When a command is gathered and managed by a command registry, it is automatically flushed when the command registry removes the cmd.
        Specified by:
        flush in interface Command
      • createMemento

        protected void createMemento()
        Commands may need to create a memento before their first execution. This is the goal of the operation that should be overriden. This operator is called a single time before the first execution of the command.
      • doIt

        public boolean doIt()
        Description copied from interface: Command
        This method manages the execution of the command.
        Specified by:
        doIt in interface Command
        Returns:
        True: the execution of the command is OK.
      • canDo

        public boolean canDo()
        Description copied from interface: Command
        Checks whether the command can be executed.
        Specified by:
        canDo in interface Command
        Returns:
        True if the command can be executed.
      • doCmdBody

        protected abstract void doCmdBody()
        This method contains the statements to execute the command. This method is automatically called by DoIt and must not be called explicitly.
        Since:
        0.1
      • getRegistrationPolicy

        public Command.RegistrationPolicy getRegistrationPolicy()
        Description copied from interface: Command
        Specifies whether the command must be saved in the cmd register. For instance, some commands, such as a scroll, should not be saved or put in the undo/redo manager. Such commands should not be registrable.
        Specified by:
        getRegistrationPolicy in interface Command
        Returns:
        The registration policy.
      • hadEffect

        public boolean hadEffect()
        Description copied from interface: Command
        State whether the execution of this command has effects on the system.
        Specified by:
        hadEffect in interface Command
        Returns:
        True: the command has effects on the system.
      • unregisteredBy

        public boolean unregisteredBy​(Command cmd)
        Description copied from interface: Command
        Checks whether the current command can be cancelled by the given one.
        Specified by:
        unregisteredBy in interface Command
        Parameters:
        cmd - The command to check whether it can cancel the current cmd.
        Returns:
        True: The given command can cancel the current cmd.
      • done

        public void done()
        Description copied from interface: Command
        Marks the command as "done" and sends it to the cmd registry.
        Specified by:
        done in interface Command
      • isDone

        public boolean isDone()
        Description copied from interface: Command
        To know whether the command has been marked as 'done'.
        Specified by:
        isDone in interface Command
        Returns:
        True: the command has been marked as 'done'.
      • cancel

        public void cancel()
        Description copied from interface: Command
        Marks the command has aborted.
        Specified by:
        cancel in interface Command
      • getStatus

        public Command.CmdStatus getStatus()
        Description copied from interface: Command
        Provides the status of the command.
        Specified by:
        getStatus in interface Command
        Returns:
        The status of the command.