use of org.eclipse.core.resources.IWorkspaceRunnable in project che by eclipse.
the class JavaProjectHelper method delete.
/**
* Removes an IJavaElement's resource. Retries if deletion failed (e.g. because the indexer
* still locks the file).
*
* @param elem the element to delete
* @throws CoreException if operation failed
* @see #ASSERT_NO_MIXED_LINE_DELIMIERS
*/
public static void delete(final IJavaElement elem) throws CoreException {
// MixedLineDelimiterDetector.assertNoMixedLineDelimiters(elem);
if (elem instanceof JavaProject) {
((JavaProject) elem).close();
JavaModelManager.getJavaModelManager().removePerProjectInfo((JavaProject) elem, true);
}
JavaModelManager.getJavaModelManager().resetTemporaryCache();
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
// performDummySearch();
if (elem instanceof IJavaProject) {
IJavaProject jproject = (IJavaProject) elem;
jproject.setRawClasspath(new IClasspathEntry[0], jproject.getProject().getFullPath(), null);
}
delete(elem.getResource());
}
};
ResourcesPlugin.getWorkspace().run(runnable, null);
// emptyDisplayLoop();
}
use of org.eclipse.core.resources.IWorkspaceRunnable in project che by eclipse.
the class PerformChangeOperation method executeChange.
/**
* Actually executes the change.
*
* @param pm a progress monitor to report progress
*
* @throws CoreException if an unexpected error occurs during
* change execution
*/
protected void executeChange(IProgressMonitor pm) throws CoreException {
fChangeExecuted = false;
if (!fChange.isEnabled())
return;
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
boolean undoInitialized = false;
try {
//$NON-NLS-1$
monitor.beginTask("", 10);
fValidationStatus = fChange.isValid(new SubProgressMonitor(monitor, 1));
if (fValidationStatus.hasFatalError())
return;
boolean aboutToPerformChangeCalled = false;
try {
if (fUndoManager != null) {
ResourcesPlugin.getWorkspace().checkpoint(false);
fUndoManager.aboutToPerformChange(fChange);
aboutToPerformChangeCalled = true;
}
fChangeExecutionFailed = true;
fUndoChange = fChange.perform(new SubProgressMonitor(monitor, 9));
fChangeExecutionFailed = false;
fChangeExecuted = true;
} finally {
if (fUndoManager != null) {
ResourcesPlugin.getWorkspace().checkpoint(false);
if (aboutToPerformChangeCalled)
fUndoManager.changePerformed(fChange, !fChangeExecutionFailed);
}
}
fChange.dispose();
if (fUndoChange != null) {
fUndoChange.initializeValidationData(new NotCancelableProgressMonitor(new SubProgressMonitor(monitor, 1)));
undoInitialized = true;
}
if (fUndoManager != null) {
if (fUndoChange != null) {
fUndoManager.addUndo(fUndoName, fUndoChange);
} else {
fUndoManager.flush();
}
}
} catch (CoreException e) {
if (fUndoManager != null)
fUndoManager.flush();
if (fUndoChange != null && undoInitialized) {
Change ch = fUndoChange;
fUndoChange = null;
ch.dispose();
}
fUndoChange = null;
throw e;
} catch (RuntimeException e) {
if (fUndoManager != null)
fUndoManager.flush();
if (fUndoChange != null && undoInitialized) {
Change ch = fUndoChange;
fUndoChange = null;
ch.dispose();
}
fUndoChange = null;
throw e;
} finally {
monitor.done();
}
}
};
ResourcesPlugin.getWorkspace().run(runnable, fSchedulingRule, IWorkspace.AVOID_UPDATE, pm);
}
use of org.eclipse.core.resources.IWorkspaceRunnable in project che by eclipse.
the class DynamicValidationStateChange method perform.
/**
* {@inheritDoc}
*/
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
final Change[] result = new Change[1];
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
result[0] = DynamicValidationStateChange.super.perform(monitor);
}
};
JavaCore.run(runnable, fSchedulingRule, pm);
return result[0];
}
use of org.eclipse.core.resources.IWorkspaceRunnable in project generator by mybatis.
the class WorkspaceUtilities method createProject.
private static IProject createProject(String projectName) throws CoreException {
final IProject project = getWorkspaceRoot().getProject(projectName);
IWorkspaceRunnable create = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
project.create(null);
project.open(null);
}
};
getWorkspace().run(create, null);
return project;
}
use of org.eclipse.core.resources.IWorkspaceRunnable in project tdi-studio-se by Talend.
the class SaveAsBusinessModelWizard method update.
private void update() {
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
try {
assginVlaues(oldProperty, property);
repositoryFactory.save(oldBusinessProcessItem);
// assign value
businessProcessItem = oldBusinessProcessItem;
} catch (PersistenceException pe) {
throw new CoreException(new Status(IStatus.ERROR, FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "persistance error", //$NON-NLS-1$
pe));
}
}
};
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
// the update the project files need to be done in the workspace runnable to avoid all notification
// of changes before the end of the modifications.
workspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
MessageBoxExceptionHandler.process(e.getCause());
}
}
Aggregations