Search in sources :

Example 1 with ProgressMonitorAdapter

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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ProgressMonitorAdapter(org.pentaho.di.core.ProgressMonitorAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 2 with ProgressMonitorAdapter

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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) Database(org.pentaho.di.core.database.Database) ProgressMonitorAdapter(org.pentaho.di.core.ProgressMonitorAdapter) InvocationTargetException(java.lang.reflect.InvocationTargetException) KettleException(org.pentaho.di.core.exception.KettleException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 3 with ProgressMonitorAdapter

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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Spoon(org.pentaho.di.ui.spoon.Spoon) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ProgressMonitorAdapter(org.pentaho.di.core.ProgressMonitorAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) MissingEntryDialog(org.pentaho.di.ui.job.entries.missing.MissingEntryDialog) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 4 with ProgressMonitorAdapter

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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ProgressMonitorAdapter(org.pentaho.di.core.ProgressMonitorAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 5 with ProgressMonitorAdapter

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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ProgressMonitorAdapter(org.pentaho.di.core.ProgressMonitorAdapter) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)13 ProgressMonitorAdapter (org.pentaho.di.core.ProgressMonitorAdapter)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)12 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)12 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)12 KettleException (org.pentaho.di.core.exception.KettleException)9 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)9 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)2 Spoon (org.pentaho.di.ui.spoon.Spoon)2 ArrayList (java.util.ArrayList)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 Database (org.pentaho.di.core.database.Database)1 DatabaseMetaInformation (org.pentaho.di.core.database.DatabaseMetaInformation)1 KettleStepException (org.pentaho.di.core.exception.KettleStepException)1 ExportFeedback (org.pentaho.di.repository.ExportFeedback)1 IRepositoryExporter (org.pentaho.di.repository.IRepositoryExporter)1 IRepositoryExporterFeedback (org.pentaho.di.repository.IRepositoryExporterFeedback)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 MissingEntryDialog (org.pentaho.di.ui.job.entries.missing.MissingEntryDialog)1