Search in sources :

Example 86 with KettleException

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

the class SpoonTabsDelegate method tabClose.

public boolean tabClose(TabItem item, boolean force) throws KettleException {
    // Try to find the tab-item that's being closed.
    boolean createPerms = !RepositorySecurityUI.verifyOperations(Spoon.getInstance().getShell(), Spoon.getInstance().getRepository(), false, RepositoryOperation.MODIFY_TRANSFORMATION, RepositoryOperation.MODIFY_JOB);
    boolean close = true;
    boolean canSave = true;
    for (TabMapEntry entry : tabMap) {
        if (item.equals(entry.getTabItem())) {
            final TabItemInterface itemInterface = entry.getObject();
            final Object managedObject = itemInterface.getManagedObject();
            if (!force) {
                if (managedObject != null && AbstractMeta.class.isAssignableFrom(managedObject.getClass())) {
                    canSave = !((AbstractMeta) managedObject).hasMissingPlugins();
                }
                if (canSave) {
                    // Can we close this tab? Only allow users with create content perms to save
                    if (!itemInterface.canBeClosed() && createPerms) {
                        int reply = itemInterface.showChangedWarning();
                        if (reply == SWT.YES) {
                            close = itemInterface.applyChanges();
                        } else {
                            if (reply == SWT.CANCEL) {
                                close = false;
                            } else {
                                close = true;
                            }
                        }
                    }
                }
            }
            String beforeCloseId = null;
            String afterCloseId = null;
            if (itemInterface instanceof TransGraph) {
                beforeCloseId = KettleExtensionPoint.TransBeforeClose.id;
                afterCloseId = KettleExtensionPoint.TransAfterClose.id;
            } else if (itemInterface instanceof JobGraph) {
                beforeCloseId = KettleExtensionPoint.JobBeforeClose.id;
                afterCloseId = KettleExtensionPoint.JobAfterClose.id;
            }
            if (beforeCloseId != null) {
                try {
                    ExtensionPointHandler.callExtensionPoint(log, beforeCloseId, managedObject);
                } catch (KettleException e) {
                    // prevent tab close
                    close = false;
                }
            }
            // 
            if (close) {
                if (itemInterface instanceof TransGraph) {
                    TransMeta transMeta = (TransMeta) managedObject;
                    spoon.delegates.trans.closeTransformation(transMeta);
                    spoon.refreshTree();
                // spoon.refreshCoreObjects();
                } else if (itemInterface instanceof JobGraph) {
                    JobMeta jobMeta = (JobMeta) managedObject;
                    spoon.delegates.jobs.closeJob(jobMeta);
                    spoon.refreshTree();
                // spoon.refreshCoreObjects();
                } else if (itemInterface instanceof SpoonBrowser) {
                    this.removeTab(entry);
                    spoon.refreshTree();
                } else if (itemInterface instanceof Composite) {
                    Composite comp = (Composite) itemInterface;
                    if (comp != null && !comp.isDisposed()) {
                        comp.dispose();
                    }
                }
                if (afterCloseId != null) {
                    try {
                        ExtensionPointHandler.callExtensionPoint(log, afterCloseId, managedObject);
                    } catch (KettleException e) {
                    // fails gracefully... what else could we do?
                    }
                }
            }
            break;
        }
    }
    return close;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) Composite(org.eclipse.swt.widgets.Composite) AbstractMeta(org.pentaho.di.base.AbstractMeta) TransMeta(org.pentaho.di.trans.TransMeta) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) SpoonBrowser(org.pentaho.di.ui.spoon.SpoonBrowser) FileObject(org.apache.commons.vfs2.FileObject) TabItemInterface(org.pentaho.di.ui.spoon.TabItemInterface)

Example 87 with KettleException

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

the class CapabilityManagerDialog method main.

public static void main(String[] args) {
    Display display = new Display();
    try {
        KettleEnvironment.init();
        PropsUI.init(display, Props.TYPE_PROPERTIES_SPOON);
        KettleLogStore.init(PropsUI.getInstance().getMaxNrLinesInLog(), PropsUI.getInstance().getMaxLogLineTimeoutMinutes());
    } catch (KettleException e) {
        e.printStackTrace();
    }
    KettleClientEnvironment.getInstance().setClient(KettleClientEnvironment.ClientType.SPOON);
    Shell shell = new Shell(display, SWT.DIALOG_TRIM);
    shell.open();
    CapabilityManagerDialog capabilityManagerDialog = new CapabilityManagerDialog(shell);
    capabilityManagerDialog.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) Shell(org.eclipse.swt.widgets.Shell) Display(org.eclipse.swt.widgets.Display)

Example 88 with KettleException

use of org.pentaho.di.core.exception.KettleException 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 89 with KettleException

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

the class PGPDecryptStreamDialog method get.

private void get() {
    if (!gotPreviousFields) {
        try {
            String fieldvalue = wStreamFieldName.getText();
            String passphrasefieldvalue = wPassphraseFieldName.getText();
            wStreamFieldName.removeAll();
            wPassphraseFieldName.removeAll();
            RowMetaInterface r = transMeta.getPrevStepFields(stepname);
            if (r != null) {
                String[] fields = r.getFieldNames();
                wStreamFieldName.setItems(fields);
                wPassphraseFieldName.setItems(fields);
            }
            if (fieldvalue != null) {
                wStreamFieldName.setText(fieldvalue);
            }
            if (passphrasefieldvalue != null) {
                wPassphraseFieldName.setText(passphrasefieldvalue);
            }
            gotPreviousFields = true;
        } catch (KettleException ke) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "PGPDecryptStreamDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "PGPDecryptStreamDialog.FailedToGetFields.DialogMessage"), ke);
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Example 90 with KettleException

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

the class PGPEncryptStreamDialog method get.

private void get() {
    if (!gotPreviousFields) {
        try {
            String fieldvalue = wStreamFieldName.getText();
            wStreamFieldName.removeAll();
            String Keyfieldvalue = wKeyNameFieldName.getText();
            wKeyNameFieldName.removeAll();
            RowMetaInterface r = transMeta.getPrevStepFields(stepname);
            if (r != null) {
                wStreamFieldName.setItems(r.getFieldNames());
                wKeyNameFieldName.setItems(r.getFieldNames());
            }
            if (fieldvalue != null) {
                wStreamFieldName.setText(fieldvalue);
            }
            if (Keyfieldvalue != null) {
                wKeyNameFieldName.setText(Keyfieldvalue);
            }
            gotPreviousFields = true;
        } catch (KettleException ke) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "PGPEncryptStreamDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "PGPEncryptStreamDialog.FailedToGetFields.DialogMessage"), ke);
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)1977 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)449 KettleStepException (org.pentaho.di.core.exception.KettleStepException)438 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)317 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)316 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)233 IOException (java.io.IOException)208 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)195 FileObject (org.apache.commons.vfs2.FileObject)150 StepMeta (org.pentaho.di.trans.step.StepMeta)150 ArrayList (java.util.ArrayList)149 KettleFileException (org.pentaho.di.core.exception.KettleFileException)124 TransMeta (org.pentaho.di.trans.TransMeta)119 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)113 Test (org.junit.Test)111 KettleValueException (org.pentaho.di.core.exception.KettleValueException)100 Database (org.pentaho.di.core.database.Database)97 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)95 ObjectId (org.pentaho.di.repository.ObjectId)91 Shell (org.eclipse.swt.widgets.Shell)90