Documentation Language: Swift

Class

BasicEditingDomain

Actor providing basic editing domain functionality for model modification coordination.

@MainActor final class BasicEditingDomain

Overview

The BasicEditingDomain serves as the central coordinator for all model modifications, integrating command execution, change notification, and resource management. It provides a unified interface for creating and executing commands while maintaining model consistency and enabling undo/redo capabilities.

Overview

The editing domain manages several key aspects of model editing:

Concurrency Model

The BasicEditingDomain is implemented as an actor to ensure thread-safe access to the command stack and editing state. All model modifications are serialised through the actor’s message queue to prevent race conditions.

Example Usage

let editingDomain = BasicEditingDomain(resourceSet: myResourceSet)

// Create and execute a set command
let command = editingDomain.createSetCommand(
    object: person,
    feature: nameAttribute,
    value: "John Doe"
)
let result = try await editingDomain.execute(command)

// Undo the change
try await editingDomain.undo()

Topics

Initializers

?
init(resourceSet:maxCommandHistory:)

Creates a new basic editing domain.

Instance Properties

V
commandStack

The command stack managing command execution and history.

V
isReadOnly

Flag indicating if the editing domain is read-only.

V
readOnly

Get the current read-only state.

V
resourceSet

The resource set containing the models being edited.

V
statistics

Current editing session statistics.

Instance Methods

F
addObserver(_:)

Add an observer for editing domain changes.

F
canRedo()

Check if redo operation is available.

F
canUndo()

Check if undo operation is available.

F
createAddCommand(object:feature:value:)

Create a command to add a value to a many-valued feature.

F
createCompoundCommand(_:)

Create a compound command from multiple commands.

F
createRemoveCommand(object:feature:value:)

Create a command to remove a value from a many-valued feature.

F
createSetCommand(object:feature:value:)

Create a command to set a property value on an object.

F
execute(_:)

Execute a command through the editing domain.

F
flushCommandStack()

Flush the command stack, clearing all history.

F
getStatistics()

Get current editing domain statistics.

F
nextRedoDescription()

Get description of the next command that would be redone.

F
nextUndoDescription()

Get description of the next command that would be undone.

F
redo()

Redo the most recent undone command.

F
removeObserver(_:)

Remove an observer from editing domain changes.

F
resetStatistics()

Reset editing domain statistics.

F
setReadOnly(_:)

Set the read-only state of the editing domain.

F
undo()

Undo the most recent command.

Relationships

Conforms To

See Also

Commands and Editing

C
EMFCommand

Protocol defining a command that can be executed, undone, and redone.

C
CommandStack

Actor managing the execution and undo/redo history of EMF commands.