use of org.eclipse.ui.operations.IWorkbenchOperationSupport in project hale by halestudio.
the class ProjectServiceImpl method internalClean.
private boolean internalClean() {
if (!changeCheck()) {
return false;
}
// reset current session descriptor
ReportService repService = PlatformUI.getWorkbench().getService(ReportService.class);
repService.updateCurrentSessionDescription();
// clean
final IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
ATransaction trans = log.begin("Clean project");
CleanupService cs = HalePlatform.getService(CleanupService.class);
if (cs != null) {
cs.triggerProjectCleanup();
}
monitor.beginTask("Clean project", IProgressMonitor.UNKNOWN);
try {
synchronized (this) {
main = createDefaultProject();
projectFile = null;
projectLocation = null;
changed = false;
projectLoadContentType = null;
temporarySettings.clear();
}
updateWindowTitle();
notifyClean();
// schemas aren't valid anymore, clear property resolver
// cache
PropertyResolver.clearCache();
} finally {
monitor.done();
trans.end();
}
// clean workbench history AFTER other cleans since they can
// create operations
IWorkbenchOperationSupport os = PlatformUI.getWorkbench().getOperationSupport();
os.getOperationHistory().dispose(os.getUndoContext(), true, true, false);
// suppress the status being set to changed by the clean
synchronized (ProjectServiceImpl.this) {
changed = false;
}
updateWindowTitle();
}
};
try {
ThreadProgressMonitor.runWithProgressDialog(op, false);
} catch (Exception e) {
log.error("Error cleaning the project.", e);
}
return true;
}
use of org.eclipse.ui.operations.IWorkbenchOperationSupport in project hale by halestudio.
the class SchemaServiceImpl method clearSchemas.
/**
* @see SchemaService#clearSchemas(SchemaSpaceID)
*/
@Override
public void clearSchemas(final SchemaSpaceID spaceID) {
Preconditions.checkNotNull(spaceID);
IUndoableOperation operation = new AbstractRemoveResourcesOperation("Clear " + (spaceID == SchemaSpaceID.SOURCE ? "source" : "target") + " schema", spaceID == SchemaSpaceID.SOURCE ? ACTION_READ_SOURCE : ACTION_READ_TARGET) {
/**
* @see eu.esdihumboldt.hale.ui.service.project.internal.AbstractRemoveResourcesOperation#execute(org.eclipse.core.runtime.IProgressMonitor,
* org.eclipse.core.runtime.IAdaptable)
*/
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
synchronized (spaces) {
spaces.remove(spaceID);
}
notifySchemasCleared(spaceID);
return super.execute(monitor, info);
}
};
IWorkbenchOperationSupport operationSupport = PlatformUI.getWorkbench().getOperationSupport();
operation.addContext(operationSupport.getUndoContext());
try {
operationSupport.getOperationHistory().execute(operation, null, null);
} catch (ExecutionException e) {
log.error("Error executing operation on schema service", e);
}
}
Aggregations