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 Type
    Method
    Description
    void
    Cancels the command.
    default int
     
    void
    Executes the command.
    default BaseElement
    Returns the element affected by this command, if any.
    Returns the user-visible name of the command.
    static String
    Retrieves the name of the editing command associated with the given element.
    void
    Sets the user-visible name of the command.
    static void
    Associates a name with the given editing command for the specified element.
    void
    setWasExecuted(boolean wasExecuted)
    Sets the execution state of the command.
    void
    Reverts the effects of a previously executed command.
    boolean
    Indicates 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

      void setName(String name)
      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:
      true if executed, otherwise false
    • setWasExecuted

      void setWasExecuted(boolean wasExecuted)
      Sets the execution state of the command.
      Parameters:
      wasExecuted - execution flag
    • getElementOfThisCommand

      @CheckForNull default BaseElement getElementOfThisCommand()
      Returns the element affected by this command, if any.
      Returns:
      associated element, or null if not applicable
    • count

      default int count()
    • setNameOfEditCommand

      static void setNameOfEditCommand(BaseElement element, Command cmd)
      Associates a name with the given editing command for the specified element.
      Parameters:
      element - the related element
      cmd - the editing command
    • getNameOfEditCommand

      static String getNameOfEditCommand(BaseElement element)
      Retrieves the name of the editing command associated with the given element.
      Parameters:
      element - the related element
      Returns:
      command name, or null if not set