use of org.eclipse.core.runtime.IProgressMonitor 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.runtime.IProgressMonitor 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.runtime.IProgressMonitor in project flux by eclipse.
the class LiveEditConnector method dispose.
public void dispose() {
this.liveEditCoordinator.removeLiveEditConnector(liveEditConnector);
this.repository.removeRepositoryListener(repositoryListener);
FileBuffers.getTextFileBufferManager().removeFileBufferListener(fileBufferListener);
ResourcesPlugin.getWorkspace().removeResourceChangeListener(workspaceListener);
WorkbenchJob jw = new WorkbenchJob("Removing listener") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
window.getActivePage().removePartListener(partListener);
}
return Status.OK_STATUS;
}
};
jw.setSystem(true);
jw.schedule();
for (IDocument document : documentMappings.values()) {
if (document != null) {
document.removeDocumentListener(documentListener);
}
}
resourceMappings.clear();
documentMappings.clear();
}
use of org.eclipse.core.runtime.IProgressMonitor in project flux by eclipse.
the class AuthFailureReporter method newValue.
@Override
public void newValue(Observable<ConnectionStatus> o, ConnectionStatus v) {
if (v.isAuthFailure()) {
UIJob job = new UIJob("Flux Error Reporter") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
MessageDialog.openError(null, "Flux Connection Failed", "Flux Web Socket handshake failed. Most likely this means " + "your Flux credentials are invalid.");
return Status.OK_STATUS;
}
};
job.schedule();
//We only report this error once.
// since this error is all we handle... there's no point to continue listening
} else if (v.isConnected()) {
//This means credentials must be valid and this listener now useless.
dispose();
}
}
use of org.eclipse.core.runtime.IProgressMonitor in project generator by mybatis.
the class NewConfigFileWizard method performFinish.
/**
* This method is called when 'Finish' button is pressed in the wizard. We
* will create an operation and run it using wizard as execution context.
*/
public boolean performFinish() {
final String containerName = page.getLocation();
final String fileName = page.getFileName();
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
doFinish(containerName, fileName, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
};
try {
getContainer().run(true, false, op);
} catch (InterruptedException e) {
return false;
} catch (InvocationTargetException e) {
Throwable realException = e.getTargetException();
MessageDialog.openError(getShell(), "Error", realException.getMessage());
return false;
}
return true;
}
Aggregations