Skip to content

Commit

Permalink
#123 Reuse TransactionChangeRecorder in RecordingModelResourceManager
Browse files Browse the repository at this point in the history
Using the RecordingModelResourceManager creates a lot of unnecessary adapters, therefore reuse the TransactionChangeRecorder from the EditingDomain
  • Loading branch information
ndoschek committed Sep 8, 2021
1 parent 845119a commit cc332a4
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.ecore.change.ChangeDescription;
import org.eclipse.emf.ecore.change.util.ChangeRecorder;
import org.eclipse.emf.transaction.impl.TransactionChangeRecorder;
import org.eclipse.emfcloud.modelserver.command.CCommand;
import org.eclipse.emfcloud.modelserver.command.CCommandExecutionResult;
import org.eclipse.emfcloud.modelserver.emf.configuration.ChangePackageConfiguration;
Expand Down Expand Up @@ -47,7 +47,8 @@ public void initialize() {
@Override
protected CommandExecutionContext executeCommand(final ModelServerEditingDomain domain, final Command serverCommand,
final CCommand clientCommand) {
ChangeRecorder recorder = new ChangeRecorder(domain.getResourceSet());
TransactionChangeRecorder recorder = domain.getChangeRecorder();
recorder.beginRecording();
CommandExecutionContext context = super.executeCommand(domain, serverCommand, clientCommand);
ChangeDescription recording = recorder.endRecording();
return new RecordingCommandExecutionContext(context, recording);
Expand All @@ -57,7 +58,8 @@ protected CommandExecutionContext executeCommand(final ModelServerEditingDomain
protected Optional<CommandExecutionContext> undoCommand(final ModelServerEditingDomain domain,
final Command serverCommand,
final CCommand clientCommand) {
ChangeRecorder recorder = new ChangeRecorder(domain.getResourceSet());
TransactionChangeRecorder recorder = domain.getChangeRecorder();
recorder.beginRecording();
Optional<CommandExecutionContext> context = super.undoCommand(domain, serverCommand, clientCommand);
ChangeDescription recording = recorder.endRecording();
return context.map(existingContext -> new RecordingCommandExecutionContext(existingContext, recording));
Expand All @@ -67,7 +69,8 @@ protected Optional<CommandExecutionContext> undoCommand(final ModelServerEditing
protected Optional<CommandExecutionContext> redoCommand(final ModelServerEditingDomain domain,
final Command serverCommand,
final CCommand clientCommand) {
ChangeRecorder recorder = new ChangeRecorder(domain.getResourceSet());
TransactionChangeRecorder recorder = domain.getChangeRecorder();
recorder.beginRecording();
Optional<CommandExecutionContext> context = super.redoCommand(domain, serverCommand, clientCommand);
ChangeDescription recording = recorder.endRecording();
return context.map(existingContext -> new RecordingCommandExecutionContext(existingContext, recording));
Expand Down

0 comments on commit cc332a4

Please sign in to comment.