use of org.eclipse.jface.operation.IRunnableWithProgress in project pentaho-kettle by pentaho.
the class JobSaveProgressDialog method open.
public boolean open() {
boolean retval = true;
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
rep.save(jobMeta, versionComment, new ProgressMonitorAdapter(monitor));
} catch (KettleException e) {
throw new InvocationTargetException(e, "Error saving job");
}
}
};
try {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
pmd.run(true, true, op);
} catch (InvocationTargetException e) {
new ErrorDialog(shell, "Error saving job", "An error occured saving the job!", e);
retval = false;
} catch (InterruptedException e) {
new ErrorDialog(shell, "Error saving job", "An error occured saving the job!", e);
retval = false;
}
return retval;
}
use of org.eclipse.jface.operation.IRunnableWithProgress in project pentaho-kettle by pentaho.
the class UpgradeRepositoryProgressDialog method open.
public boolean open() {
boolean retval = true;
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// This is running in a new process: copy some KettleVariables info
// LocalVariables.getInstance().createKettleVariables(Thread.currentThread(),
// kettleVariables.getLocalThread(), true);
// --> don't set variables if not running in different thread --> pmd.run(true,true,
// op);
// Ask if you want to do a dry run first?
//
MessageBox box = new MessageBox(shell, SWT.YES | SWT.NO);
box.setMessage(BaseMessages.getString(PKG, "UpgradeRepositoryDialog.DryRunQuestion.Message"));
box.setText(BaseMessages.getString(PKG, "UpgradeRepositoryDialog.DryRunQuestion.Title"));
int answer = box.open();
try {
if (answer == SWT.YES) {
// First do a dry-run
//
dryRun = true;
rep.createRepositorySchema(new ProgressMonitorAdapter(monitor), upgrade, generatedStatements, true);
} else {
rep.createRepositorySchema(new ProgressMonitorAdapter(monitor), upgrade, generatedStatements, false);
}
} catch (KettleException e) {
log.logError(toString(), Const.getStackTracker(e));
throw new InvocationTargetException(e, BaseMessages.getString(PKG, "UpgradeRepositoryDialog.Error.CreateUpdate", e.getMessage()));
}
}
};
try {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
pmd.run(false, false, op);
} catch (InvocationTargetException e) {
log.logError(UpgradeRepositoryProgressDialog.class.toString(), "Error creating/updating repository: " + e.toString());
log.logError(toString(), Const.getStackTracker(e));
showErrorDialog(e);
retval = false;
} catch (InterruptedException e) {
log.logError(UpgradeRepositoryProgressDialog.class.toString(), "Error creating/updating repository: " + e.toString());
log.logError(toString(), Const.getStackTracker(e));
showErrorDialog(e);
retval = false;
}
return retval;
}
use of org.eclipse.jface.operation.IRunnableWithProgress in project pentaho-kettle by pentaho.
the class TransLoadProgressDialog method open.
public TransMeta open() {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
Spoon spoon = Spoon.getInstance();
try {
// Call extension point(s) before the file has been opened
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.TransBeforeOpen.id, (objectId == null) ? transname : objectId.toString());
if (objectId != null) {
transInfo = rep.loadTransformation(objectId, versionLabel);
} else {
transInfo = rep.loadTransformation(transname, repdir, new ProgressMonitorAdapter(monitor), true, versionLabel);
}
// Call extension point(s) now that the file has been opened
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.TransAfterOpen.id, transInfo);
if (transInfo.hasMissingPlugins()) {
StepMeta stepMeta = transInfo.getStep(0);
Display.getDefault().syncExec(() -> {
MissingTransDialog missingTransDialog = new MissingTransDialog(shell, transInfo.getMissingTrans(), stepMeta.getStepMetaInterface(), transInfo, stepMeta.getName());
if (missingTransDialog.open() == null) {
transInfo = null;
}
});
}
} catch (KettleException e) {
throw new InvocationTargetException(e, BaseMessages.getString(PKG, "TransLoadProgressDialog.Exception.ErrorLoadingTransformation"));
}
}
};
try {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
pmd.run(true, false, op);
} catch (InvocationTargetException e) {
KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
if (krle != null) {
throw krle;
}
new ErrorDialog(shell, BaseMessages.getString(PKG, "TransLoadProgressDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransLoadProgressDialog.ErrorLoadingTransformation.DialogMessage"), e);
transInfo = null;
} catch (InterruptedException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "TransLoadProgressDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransLoadProgressDialog.ErrorLoadingTransformation.DialogMessage"), e);
transInfo = null;
}
return transInfo;
}
use of org.eclipse.jface.operation.IRunnableWithProgress in project pentaho-kettle by pentaho.
the class TransPreviewProgressDialog method open.
/**
* Opens the progress dialog
* @param showErrorDialogs dictates whether error dialogs should be shown when errors occur - can be set to false
* to let the caller control error dialogs instead.
* @return a {@link TransMeta}
*/
public TransMeta open(final boolean showErrorDialogs) {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
doPreview(monitor, showErrorDialogs);
}
};
try {
final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
// Run something in the background to cancel active database queries, forecably if needed!
Runnable run = new Runnable() {
public void run() {
IProgressMonitor monitor = pmd.getProgressMonitor();
while (pmd.getShell() == null || (!pmd.getShell().isDisposed() && !monitor.isCanceled())) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// Ignore
}
}
if (monitor.isCanceled()) {
try {
trans.stopAll();
} catch (Exception e) {
/* Ignore */
}
}
}
};
// Start the cancel tracker in the background!
new Thread(run).start();
pmd.run(true, true, op);
} catch (InvocationTargetException e) {
if (showErrorDialogs) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "TransPreviewProgressDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransPreviewProgressDialog.ErrorLoadingTransformation.DialogMessage"), e);
}
transMeta = null;
} catch (InterruptedException e) {
if (showErrorDialogs) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "TransPreviewProgressDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransPreviewProgressDialog.ErrorLoadingTransformation.DialogMessage"), e);
}
transMeta = null;
}
return transMeta;
}
use of org.eclipse.jface.operation.IRunnableWithProgress in project xtext-eclipse by eclipse.
the class TemplateNewProjectWizard method performFinish.
@Override
public boolean performFinish() {
final IProjectInfo projectInfo = getProjectInfo();
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
doFinish(projectInfo, monitor);
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
};
try {
getContainer().run(true, false, op);
} catch (InterruptedException e) {
return false;
} catch (InvocationTargetException e) {
logger.error(e.getMessage(), e);
Throwable realException = e.getTargetException();
// $NON-NLS-1$
MessageDialog.openError(getShell(), "Error", realException.getMessage());
return false;
}
return true;
}
Aggregations