Interface Command
- All Known Subinterfaces:
CompositeCommand
@OpenApiAll
public interface Command
Represents an executable operation with undo/redo support.
A command encapsulates a model modification that can be executed, undone, or canceled. Canceled commands cannot be undone.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Cancels the command.default intcount()voidexecute()Executes the command.default BaseElementReturns the element affected by this command, if any.getName()Returns the user-visible name of the command.static StringgetNameOfEditCommand(BaseElement element) Retrieves the name of the editing command associated with the given element.voidSets the user-visible name of the command.static voidsetNameOfEditCommand(BaseElement element, Command cmd) Associates a name with the given editing command for the specified element.voidsetWasExecuted(boolean wasExecuted) Sets the execution state of the command.voidundo()Reverts the effects of a previously executed command.booleanIndicates whether the command has been executed.
-
Method Details
-
execute
void execute()Executes the command. -
undo
void undo()Reverts the effects of a previously executed command. -
cancel
void cancel()Cancels the command. -
setName
Sets the user-visible name of the command.- Parameters:
name- command name
-
getName
String getName()Returns the user-visible name of the command.- Returns:
- command name
-
wasExecuted
boolean wasExecuted()Indicates whether the command has been executed.- Returns:
trueif executed, otherwisefalse
-
setWasExecuted
void setWasExecuted(boolean wasExecuted) Sets the execution state of the command.- Parameters:
wasExecuted- execution flag
-
getElementOfThisCommand
Returns the element affected by this command, if any.- Returns:
- associated element, or
nullif not applicable
-
count
default int count() -
setNameOfEditCommand
Associates a name with the given editing command for the specified element.- Parameters:
element- the related elementcmd- the editing command
-
getNameOfEditCommand
Retrieves the name of the editing command associated with the given element.- Parameters:
element- the related element- Returns:
- command name, or
nullif not set
-