@OpenApiAll public interface Editing
Provides an API for executing and managing model editing operations with transaction and undo/redo support.

This framework:

  • Executes model modifications within Transactions
  • Records changes as commands for undo/redo
  • Maintains command history and supports redo after undo

  • Method Details

    • getInstance

      static Editing getInstance(ModelElementProject project)
      Returns the Editing instance for the given project.
      Parameters:
      project - the project
      Returns:
      editing instance
    • execute

      default void execute(String commandName, Runnable runnable)
      Executes given Runnable inside already started or starts a new editing command. Wraps it in a CompositeCommand. Records all changes in the model during execution for undo. Discards newly started command if Runnable throws EditingCanceledException
      Parameters:
      commandName - command name
      runnable - runnable
    • supply

      default <V> V supply(String commandName, Supplier<V> supplier)
      Executes given Supplier inside already started or starts a new editing command. Wraps it in a CompositeCommand. Records all changes in the model during execution for undo. Discards newly started command if Supplier throws EditingCanceledException.
      Parameters:
      commandName - command name
      supplier - supplier
      Returns:
      value from supplier or null if Supplier threw EditingCanceledException
    • call

      <V> V call(String commandName, Callable<V> callable) throws Exception
      Executes given Callable inside already started or starts a new editing command. Wraps it in a CompositeCommand. Records all changes in the model during execution for undo. Discards newly started command if Callable throws EditingCanceledException.
      Parameters:
      commandName - command name
      callable - supplier
      Returns:
      value from callable or null if Callable threw EditingCanceledException
      Throws:
      Exception
    • redo

      void redo()
      Redo command next to current. The current command needs to be complete.
    • undo

      void undo()
      Undo the current command. It needs to be completed.
    • discardCurrent

      void discardCurrent()
      Discards the current command and remove it from the history. Command needs to be executed.
    • compactHistoryUntil

      void compactHistoryUntil(CompositeCommand command)
      Merges all commands till the end from the specified command. All commands must be executed. If non-executed commands are found, merge is not performed.
      Parameters:
      command - the command to merge up to (including it)
    • clearHistory

      void clearHistory()
      Discards all commands in the history. History will be empty.
    • isCompleting

      boolean isCompleting()
      Returns:
      true if history is executing some command at this moment
    • isUndoing

      boolean isUndoing()
      Returns:
      true if history is undoing some command at this moment
    • isCanceling

      boolean isCanceling()
      Returns:
      true if history is canceling some command at this moment
    • isRedoing

      boolean isRedoing()
      If history doing redo.
      Returns:
      true if now doing redo.
    • isUndoingOrRedoing

      default boolean isUndoingOrRedoing()
      If command history undoing or redoing at the moment.
      Returns:
      true if undo or redo operations are in progress.
    • isBusy

      default boolean isBusy()
      If history is doing something - complete, undo, redo or cancel.
      Returns:
      true if now doing redo.
    • getCommandForAppending

      CompositeCommand getCommandForAppending()
      Returns the current command from the command history for others commands appending. Such a command is available only if the current command in the project's command history is not executed yet.
      Returns:
      the command for other commands appending
    • getCurrentCommand

      @CheckForNull CompositeCommand getCurrentCommand()
      Returns:
      current history command. It can be executed or not.
    • getCommandForUndo

      @CheckForNull CompositeCommand getCommandForUndo()
      Returns:
      the command that can be undone
    • getCommandForRedo

      @CheckForNull CompositeCommand getCommandForRedo()
      Returns:
      the command for redo (next to the current command)
    • appendIfPossible

      static void appendIfPossible(ModelElementProject project, Command command)
      Append a given command to command for appending
      Parameters:
      project - project
      command - command
      See Also: