[xtext 2.0] supress confirmation "Undoing ... affects elements outside of ..." on undo ref [message #665321] |
Thu, 14 April 2011 09:47 |
Sebastian Paul Messages: 106 Registered: July 2009 |
Senior Member |
|
|
Hi,
I have a simple example which modifies the semantic model using the new
refactoring API. Briefly, I implemented a "Clear state transitions"
refactoring for the FowlerDsl example. I noticed that I always get the
confirmation dialog "Undoing 'Clear transitions' affects elements
outside of test.fowlerdsl'", although there is only one file. Is it
possible to avoid that?
This is how I implemented the refactoring:
public class ClearStateTransitionsRefactoring extends
org.eclipse.ltk.core.refactoring.Refactoring {
....
@Override
public Change createChange(IProgressMonitor pm) throws CoreException,
OperationCanceledException {
Resource targetResource = object.eResource();
try {
if (object instanceof State) {
((State)object).getTransitions().clear();
}
changeUtil.addSaveAsUpdate(targetResource, updateAcceptor);
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, "", "cannot save
resource", e));
}
return updateAcceptor.createCompositeChange(getName(), pm);
}
}
Maybe the problem is the way how I invoke the refactoring:
Refactoring refactoring = new ClearStateTransitionsRefactoring(eObject,
updateAcceptorProvider.get(), changeUtil);
NullProgressMonitor nullProgressMonitor = new NullProgressMonitor();
Change change = refactoring.createChange(nullProgressMonitor);
change.initializeValidationData(nullProgressMonitor);
PerformChangeOperation performChangeOperation =
new PerformChangeOperation(change);
performChangeOperation.setUndoManager(RefactoringCore.getUnd oManager(),
refactoring.getName());
performChangeOperation.setSchedulingRule(ResourcesPlugin.get Workspace().getRoot());
ResourcesPlugin.getWorkspace().run(performChangeOperation,
nullProgressMonitor);
My XText version is the nightly build 2.0.0.v201104111605
--
Best regards,
Sebastian Paul
|
|
|
Powered by
FUDForum. Page generated in 0.02878 seconds