Search in sources :

Example 6 with ProgressMonitorAdapter

use of org.pentaho.di.core.ProgressMonitorAdapter 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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MissingTransDialog(org.pentaho.di.ui.trans.steps.missing.MissingTransDialog) 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) StepMeta(org.pentaho.di.trans.step.StepMeta) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 7 with ProgressMonitorAdapter

use of org.pentaho.di.core.ProgressMonitorAdapter in project pentaho-kettle by pentaho.

the class GetDatabaseInfoProgressDialog method open.

public DatabaseMetaInformation open() {
    final DatabaseMetaInformation dmi = new DatabaseMetaInformation(dbInfo);
    IRunnableWithProgress op = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                dmi.getData(Spoon.loggingObject, new ProgressMonitorAdapter(monitor));
            } catch (Exception e) {
                throw new InvocationTargetException(e, BaseMessages.getString(PKG, "GetDatabaseInfoProgressDialog.Error.GettingInfoTable", e.toString()));
            }
        }
    };
    try {
        ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
        pmd.run(true, true, op);
    } catch (InvocationTargetException e) {
        showErrorDialog(e);
        return null;
    } catch (InterruptedException e) {
        showErrorDialog(e);
        return null;
    }
    return dmi;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ProgressMonitorAdapter(org.pentaho.di.core.ProgressMonitorAdapter) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) DatabaseMetaInformation(org.pentaho.di.core.database.DatabaseMetaInformation) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 8 with ProgressMonitorAdapter

use of org.pentaho.di.core.ProgressMonitorAdapter in project pentaho-kettle by pentaho.

the class AnalyseImpactProgressDialog method open.

public boolean open() {
    IRunnableWithProgress op = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                // Start with a clean slate!!
                impact.clear();
                transMeta.analyseImpact(impact, new ProgressMonitorAdapter(monitor));
                impactHasRun = true;
            } catch (Exception e) {
                impact.clear();
                impactHasRun = false;
                // Problem encountered generating impact list: {0}
                throw new InvocationTargetException(e, BaseMessages.getString(PKG, "AnalyseImpactProgressDialog.RuntimeError.UnableToAnalyzeImpact.Exception", e.toString()));
            }
        }
    };
    try {
        ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
        pmd.run(true, true, op);
    } catch (InvocationTargetException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "AnalyseImpactProgressDialog.Dialog.UnableToAnalyzeImpact.Title"), BaseMessages.getString(PKG, "AnalyseImpactProgressDialog.Dialog.UnableToAnalyzeImpact.Messages"), e);
    } catch (InterruptedException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "AnalyseImpactProgressDialog.Dialog.UnableToAnalyzeImpact.Title"), BaseMessages.getString(PKG, "AnalyseImpactProgressDialog.Dialog.UnableToAnalyzeImpact.Messages"), e);
    }
    return impactHasRun;
}
Also used : 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) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 9 with ProgressMonitorAdapter

use of org.pentaho.di.core.ProgressMonitorAdapter in project pentaho-kettle by pentaho.

the class CheckTransProgressDialog method open.

public void open() {
    final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
    IRunnableWithProgress op = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                transMeta.checkSteps(remarks, onlySelected, new ProgressMonitorAdapter(monitor), space, repository, metaStore);
            } catch (Exception e) {
                throw new InvocationTargetException(e, BaseMessages.getString(PKG, "AnalyseImpactProgressDialog.RuntimeError.ErrorCheckingTransformation.Exception", e.toString()));
            }
        }
    };
    try {
        // Run something in the background to cancel active database queries, force this 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(250);
                    } catch (InterruptedException e) {
                    // Ignore sleep interruption exception
                    }
                }
                if (monitor.isCanceled()) {
                    try {
                        transMeta.cancelQueries();
                    } catch (Exception e) {
                    // Ignore cancel errors
                    }
                }
            }
        };
        // Dump the cancel looker in the background!
        new Thread(run).start();
        pmd.run(true, true, op);
    } catch (InvocationTargetException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "CheckTransProgressDialog.Dialog.ErrorCheckingTransformation.Title"), BaseMessages.getString(PKG, "CheckTransProgressDialog.Dialog.ErrorCheckingTransformation.Message"), e);
    } catch (InterruptedException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "CheckTransProgressDialog.Dialog.ErrorCheckingTransformation.Title"), BaseMessages.getString(PKG, "CheckTransProgressDialog.Dialog.ErrorCheckingTransformation.Message"), e);
    }
}
Also used : 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) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 10 with ProgressMonitorAdapter

use of org.pentaho.di.core.ProgressMonitorAdapter in project pentaho-kettle by pentaho.

the class GetJobSQLProgressDialog method open.

public List<SQLStatement> open() {
    IRunnableWithProgress op = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                stats = jobMeta.getSQLStatements(repository, new ProgressMonitorAdapter(monitor));
            } catch (KettleException e) {
                throw new InvocationTargetException(e, BaseMessages.getString(PKG, "GetJobSQLProgressDialog.RuntimeError.UnableToGenerateSQL.Exception", // Error
                e.getMessage()));
            // generating
            // SQL for
            // job:
            // \n{0}
            }
        }
    };
    try {
        ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
        pmd.run(false, false, op);
    } catch (InvocationTargetException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "GetJobSQLProgressDialog.Dialog.UnableToGenerateSQL.Title"), BaseMessages.getString(PKG, "GetJobSQLProgressDialog.Dialog.UnableToGenerateSQL.Message"), e);
        stats = null;
    } catch (InterruptedException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "GetJobSQLProgressDialog.Dialog.UnableToGenerateSQL.Title"), BaseMessages.getString(PKG, "GetJobSQLProgressDialog.Dialog.UnableToGenerateSQL.Message"), e);
        stats = null;
    }
    return stats;
}
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)

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