-
- All Known Implementing Classes:
ActivateInstrument,AnonCommand,CommandImpl,InactivateInstrument,InstrumentCommand,ModifyValue,OpenWebPage,PositionCommand,Redo,Undo,Zoom
public interface CommandA command is produced and executed in reaction of a user interaction. It follows the command design pattern. It contains statements to execute to perform the command. The interface Undoable can be used to add undo/redo features to a command.- Author:
- Arnaud Blouin
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classCommand.CmdStatusDefines the different states of the command.static classCommand.RegistrationPolicyDefines the registration policy of the command.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcancel()Marks the command has aborted.booleancanDo()Checks whether the command can be executed.booleandoIt()This method manages the execution of the command.voiddone()Marks the command as "done" and sends it to the cmd registry.static voidexecuteAndFlush(Command cmd)Execute if possible (canDo) the given command (if not null) and flush it.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'.booleanunregisteredBy(Command cmd)Checks whether the current command can be cancelled by the given one.
-
-
-
Method Detail
-
executeAndFlush
static void executeAndFlush(Command cmd)
Execute if possible (canDo) the given command (if not null) and flush it.- Parameters:
cmd- The command to execute. Nothing done if null.
-
flush
void flush()
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.
-
getRegistrationPolicy
Command.RegistrationPolicy getRegistrationPolicy()
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.- Returns:
- The registration policy.
-
doIt
boolean doIt()
This method manages the execution of the command.- Returns:
- True: the execution of the command is OK.
-
canDo
boolean canDo()
Checks whether the command can be executed.- Returns:
- True if the command can be executed.
- Since:
- 0.1
-
hadEffect
boolean hadEffect()
State whether the execution of this command has effects on the system.- Returns:
- True: the command has effects on the system.
-
unregisteredBy
boolean unregisteredBy(Command cmd)
Checks whether the current command can be cancelled by the given one.- Parameters:
cmd- The command to check whether it can cancel the current cmd.- Returns:
- True: The given command can cancel the current cmd.
-
done
void done()
Marks the command as "done" and sends it to the cmd registry.- Since:
- 0.1
-
isDone
boolean isDone()
To know whether the command has been marked as 'done'.- Returns:
- True: the command has been marked as 'done'.
-
cancel
void cancel()
Marks the command has aborted.
-
getStatus
Command.CmdStatus getStatus()
Provides the status of the command.- Returns:
- The status of the command.
- Since:
- 0.2
-
-