IWorkspace workspace = ResourcesPlugin.getWorkspace();
ResourceChangeListener rcl = new ResourceChangeListener();
workspace.addResourceChangeListener(rcl);
try{
PerformChangeOperation changeOperation = new PerformChangeOperation(change);
// passing in refactor.name to the change op doesn't seem to do the
// trick, so lets force our name on the change since the undo manager
// will use the change's name if label is null (which it shouldn't be,
// but is, hence this hack).
if (change instanceof CompositeChange){
try{
Field fName = CompositeChange.class.getDeclaredField("fName");
fName.setAccessible(true);
fName.set(change, refactor.name);
}catch(NoSuchFieldException nsfe){
// change doesn't have the expected fName field.
}
}
changeOperation.setUndoManager(
RefactoringCore.getUndoManager(), change.getName());
changeOperation.run(new SubProgressMonitor(monitor, 4));
return rcl.getChangedFiles();
}finally{
workspace.removeResourceChangeListener(rcl);
}
}catch(RefactorException re){