- java.lang.Object
-
- io.github.interacto.command.CommandImpl
-
- All Implemented Interfaces:
Command
- Direct Known Subclasses:
AnonCommand,InstrumentCommand,ModifyValue,OpenWebPage,PositionCommand,Redo,Undo
public abstract class CommandImpl extends Object implements Command
Base implementation of the Command interface.- Author:
- Arnaud BLOUIN
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.github.interacto.command.Command
Command.CmdStatus, Command.RegistrationPolicy
-
-
Field Summary
Fields Modifier and Type Field Description protected Command.CmdStatusstatusThe state of the command.
-
Constructor Summary
Constructors Constructor Description CommandImpl()The default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcancel()Marks the command has aborted.booleancanDo()Checks whether the command can be executed.protected voidcreateMemento()Commands may need to create a memento before their first execution.protected abstract voiddoCmdBody()This method contains the statements to execute the command.booleandoIt()This method manages the execution of the command.voiddone()Marks the command as "done" and sends it to the cmd registry.voidflush()Flushes the command.Command.RegistrationPolicygetRegistrationPolicy()Specifies whether the command must be saved in the cmd register.Command.CmdStatusgetStatus()Provides the status of the command.booleanhadEffect()State whether the execution of this command has effects on the system.booleanisDone()To know whether the command has been marked as 'done'.StringtoString()booleanunregisteredBy(Command cmd)Checks whether the current command can be cancelled by the given one.
-
-
-
Field Detail
-
status
protected Command.CmdStatus status
The state of the command.
-
-
Method Detail
-
flush
public void flush()
Description copied from interface:CommandFlushes 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.
-
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:CommandThis method manages the execution of the command.
-
canDo
public boolean canDo()
Description copied from interface:CommandChecks whether 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:CommandSpecifies 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:
getRegistrationPolicyin interfaceCommand- Returns:
- The registration policy.
-
hadEffect
public boolean hadEffect()
Description copied from interface:CommandState whether the execution of this command has effects on the system.
-
unregisteredBy
public boolean unregisteredBy(Command cmd)
Description copied from interface:CommandChecks whether the current command can be cancelled by the given one.- Specified by:
unregisteredByin interfaceCommand- 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:CommandMarks the command as "done" and sends it to the cmd registry.
-
isDone
public boolean isDone()
Description copied from interface:CommandTo know whether the command has been marked as 'done'.
-
cancel
public void cancel()
Description copied from interface:CommandMarks the command has aborted.
-
getStatus
public Command.CmdStatus getStatus()
Description copied from interface:CommandProvides the status of the command.
-
-