use of org.pentaho.di.core.ProgressMonitorAdapter in project pentaho-kettle by pentaho.
the class SaveProgressDialog method open.
public boolean open() {
boolean retval = true;
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
rep.save(meta, versionComment, new ProgressMonitorAdapter(monitor));
} catch (KettleException e) {
throw new InvocationTargetException(e, BaseMessages.getString(PKG, "TransSaveProgressDialog.Exception.ErrorSavingTransformation") + e.toString());
}
}
};
try {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
pmd.run(true, true, op);
} catch (InvocationTargetException e) {
MessageDialog errorDialog = new MessageDialog(shell, BaseMessages.getString(PKG, "TransSaveProgressDialog.UnableToSave.DialogTitle"), null, BaseMessages.getString(PKG, "TransSaveProgressDialog.UnableToSave.DialogMessage"), MessageDialog.ERROR, new String[] { BaseMessages.getString(PKG, "TransSaveProgressDialog.UnableToSave.Close") }, 0);
errorDialog.open();
retval = false;
} catch (InterruptedException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "TransSaveProgressDialog.ErrorSavingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransSaveProgressDialog.ErrorSavingTransformation.DialogMessage"), e);
retval = false;
}
return retval;
}
use of org.pentaho.di.core.ProgressMonitorAdapter in project pentaho-kettle by pentaho.
the class GetPreviewTableProgressDialog method open.
public List<Object[]> open() {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
db = new Database(Spoon.loggingObject, dbMeta);
try {
db.connect();
if (limit > 0) {
db.setQueryLimit(limit);
}
rows = db.getFirstRows(tableName, limit, new ProgressMonitorAdapter(monitor));
rowMeta = db.getReturnRowMeta();
} catch (KettleException e) {
throw new InvocationTargetException(e, "Couldn't find any rows because of an error :" + e.toString());
} finally {
db.disconnect();
}
}
};
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 {
db.cancelQuery();
} catch (Exception e) {
// Ignore
}
}
}
};
// Start the cancel tracker in the background!
new Thread(run).start();
pmd.run(true, true, op);
} catch (InvocationTargetException e) {
showErrorDialog(e);
return null;
} catch (InterruptedException e) {
showErrorDialog(e);
return null;
}
return rows;
}
use of org.pentaho.di.core.ProgressMonitorAdapter in project pentaho-kettle by pentaho.
the class JobLoadProgressDialog method open.
public JobMeta 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.JobBeforeOpen.id, (objectId == null) ? jobname : objectId.toString());
if (objectId != null) {
jobInfo = rep.loadJob(objectId, versionLabel);
} else {
jobInfo = rep.loadJob(jobname, repdir, new ProgressMonitorAdapter(monitor), versionLabel);
}
// Call extension point(s) now that the file has been opened
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobAfterOpen.id, jobInfo);
if (jobInfo.hasMissingPlugins()) {
MissingEntryDialog missingDialog = new MissingEntryDialog(shell, jobInfo.getMissingEntries());
if (missingDialog.open() == null) {
jobInfo = null;
}
}
} catch (KettleException e) {
throw new InvocationTargetException(e, "Error loading job");
}
}
};
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, "Error loading job", "An error occured loading the job!", e);
jobInfo = null;
} catch (InterruptedException e) {
new ErrorDialog(shell, "Error loading job", "An error occured loading the job!", e);
jobInfo = null;
}
return jobInfo;
}
use of org.pentaho.di.core.ProgressMonitorAdapter 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.pentaho.di.core.ProgressMonitorAdapter 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;
}
Aggregations