Interface Editing
@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
commandsfor undo/redo - Maintains command history and supports redo after undo
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendIfPossible(ModelElementProject project, Command command) Append a given command to command for appending<V> VExecutes givenCallableinside already started or starts a new editing command.voidDiscards all commands in the history.voidcompactHistoryUntil(CompositeCommand command) Merges all commands till the end from the specified command.voidDiscards the current command and remove it from the history.default voidExecutes givenRunnableinside already started or starts a new editing command.Returns the current command from the command history for others commands appending.static EditinggetInstance(ModelElementProject project) Returns theEditinginstance for the given project.default booleanisBusy()If history is doing something - complete, undo, redo or cancel.booleanbooleanbooleanIf history doing redo.booleandefault booleanIf command history undoing or redoing at the moment.voidredo()Redo command next to current.default <V> VExecutes givenSupplierinside already started or starts a new editing command.voidundo()Undo the current command.
-
Method Details
-
getInstance
Returns theEditinginstance for the given project.- Parameters:
project- the project- Returns:
- editing instance
-
execute
Executes givenRunnableinside already started or starts a new editing command. Wraps it in aCompositeCommand. Records all changes in the model during execution for undo. Discards newly started command ifRunnablethrowsEditingCanceledException- Parameters:
commandName- command namerunnable- runnable
-
supply
Executes givenSupplierinside already started or starts a new editing command. Wraps it in aCompositeCommand. Records all changes in the model during execution for undo. Discards newly started command ifSupplierthrowsEditingCanceledException.- Parameters:
commandName- command namesupplier- supplier- Returns:
- value from supplier or null if
SupplierthrewEditingCanceledException
-
call
Executes givenCallableinside already started or starts a new editing command. Wraps it in aCompositeCommand. Records all changes in the model during execution for undo. Discards newly started command ifCallablethrowsEditingCanceledException. -
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
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
- Returns:
- current history command. It can be executed or not.
-
getCommandForUndo
- Returns:
- the command that can be undone
-
getCommandForRedo
- Returns:
- the command for redo (next to the current command)
-
appendIfPossible
Append a given command to command for appending- Parameters:
project- projectcommand- command- See Also:
-