use of org.eclipse.ui.actions.WorkspaceModifyOperation in project xtext-xtend by eclipse.
the class RefactoringIntegrationTest method doRename.
protected void doRename(EObject targetElement, String newName) throws Exception {
URI targetElementURI = EcoreUtil.getURI(targetElement);
RenameElementProcessor processor = processorProvider.get();
processor.initialize(new IRenameElementContext.Impl(targetElementURI, targetElement.eClass(), null, null, null));
processor.setNewName(newName);
RefactoringStatus initialStatus = processor.checkInitialConditions(new NullProgressMonitor());
assertTrue(initialStatus.isOK());
RefactoringStatus finalStatus = processor.checkFinalConditions(new NullProgressMonitor(), null);
assertTrue(finalStatus.toString(), finalStatus.isOK());
final Change change = processor.createChange(new NullProgressMonitor());
assertNotNull(change);
new WorkspaceModifyOperation() {
@Override
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
change.perform(monitor);
}
}.run(null);
}
use of org.eclipse.ui.actions.WorkspaceModifyOperation in project xtext-xtend by eclipse.
the class RenameStrategyTest method testOverrideIndicatorAnnotationAfterFileRename.
@Test
public void testOverrideIndicatorAnnotationAfterFileRename() throws Exception {
testHelper.createFile("test/SuperClass", "package test\nclass SuperClass { def foo() {}}");
final IFile subClassFile = testHelper.createFile("test/SubClass", "package test\nclass SubClass extends SuperClass { override foo () {}}");
IResourcesSetupUtil.waitForBuild();
XtextEditor openEditor = testHelper.openEditor(subClassFile);
final OverrideIndicatorAnnotation[] annotationBeforeFileRename = new OverrideIndicatorAnnotation[] { null };
final OverrideIndicatorAnnotation[] annotationAfterFileRename = new OverrideIndicatorAnnotation[] { null };
final ISourceViewer sourceViewer = openEditor.getInternalSourceViewer();
sleepWhile(Predicates.isNull(), new Provider<Object>() {
@Override
public OverrideIndicatorAnnotation get() {
annotationBeforeFileRename[0] = Iterators.getOnlyElement(Iterators.filter(sourceViewer.getAnnotationModel().getAnnotationIterator(), OverrideIndicatorAnnotation.class), null);
return annotationBeforeFileRename[0];
}
}, TimeUnit.SECONDS.toMillis(10));
assertNotNull(annotationBeforeFileRename[0]);
new WorkspaceModifyOperation() {
@Override
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
subClassFile.move(subClassFile.getFullPath().removeLastSegments(1).append("Test.xtend"), true, monitor);
}
}.run(new NullProgressMonitor());
IResourcesSetupUtil.waitForBuild();
sleepWhile(Predicates.isNull(), new Provider<Object>() {
@Override
public OverrideIndicatorAnnotation get() {
OverrideIndicatorAnnotation ann = Iterators.getOnlyElement(Iterators.filter(sourceViewer.getAnnotationModel().getAnnotationIterator(), OverrideIndicatorAnnotation.class), null);
if (ann != annotationBeforeFileRename[0])
annotationAfterFileRename[0] = ann;
return annotationAfterFileRename[0];
}
}, TimeUnit.SECONDS.toMillis(10));
assertNotNull(annotationAfterFileRename[0]);
assertNotSame(annotationBeforeFileRename[0], annotationAfterFileRename[0]);
}
use of org.eclipse.ui.actions.WorkspaceModifyOperation in project eclipse.platform.text by eclipse.
the class SearchManager method removeAllSearches.
void removeAllSearches() {
SearchPlugin.getWorkspace().removeResourceChangeListener(this);
WorkspaceModifyOperation op = new WorkspaceModifyOperation(null) {
@Override
protected void execute(IProgressMonitor monitor) throws CoreException {
monitor.beginTask(SearchMessages.SearchManager_updating, 100);
SearchPlugin.getWorkspace().getRoot().deleteMarkers(SearchUI.SEARCH_MARKER, true, IResource.DEPTH_INFINITE);
monitor.worked(100);
monitor.done();
}
};
boolean isAutoBuilding = SearchPlugin.setAutoBuilding(false);
try {
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
dialog.run(true, true, op);
} catch (InvocationTargetException ex) {
ExceptionHandler.handle(ex, SearchMessages.Search_Error_deleteMarkers_title, SearchMessages.Search_Error_deleteMarkers_message);
} catch (InterruptedException e) {
// Do nothing. Operation has been canceled.
} finally {
SearchPlugin.getWorkspace().addResourceChangeListener(this);
SearchPlugin.setAutoBuilding(isAutoBuilding);
}
// clear searches
fPreviousSearches = new LinkedList<>();
fCurrentSearch = null;
// update viewers
Iterator<SearchResultViewer> iter = fListeners.iterator();
while (iter.hasNext()) {
SearchResultViewer viewer = iter.next();
handleAllSearchesRemoved(viewer);
}
}
use of org.eclipse.ui.actions.WorkspaceModifyOperation in project linuxtools by eclipse.
the class RPMNewProject method performFinish.
@Override
public boolean performFinish() {
try {
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
@Override
protected void execute(IProgressMonitor monitor) throws CoreException {
createProject(monitor != null ? monitor : new NullProgressMonitor());
}
};
getContainer().run(false, true, op);
} catch (InvocationTargetException x) {
return false;
} catch (InterruptedException x) {
return false;
}
return true;
}
Aggregations