Search in sources :

Example 56 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class AccessInputDialog method preview.

// Preview the data
private void preview() {
    try {
        // Create the Access input step
        AccessInputMeta oneMeta = new AccessInputMeta();
        getInfo(oneMeta);
        // check if the path is given
        if (!checkInputTableName(oneMeta)) {
            return;
        }
        TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "AccessInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "AccessInputDialog.NumberRows.DialogMessage"));
        int previewSize = numberDialog.open();
        if (previewSize > 0) {
            TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
            progressDialog.open();
            if (!progressDialog.isCancelled()) {
                Trans trans = progressDialog.getTrans();
                String loggingText = progressDialog.getLoggingText();
                if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
                    EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
                    etd.setReadOnly();
                    etd.open();
                }
                PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
                prd.open();
            }
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "AccessInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "AccessInputDialog.ErrorPreviewingData.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) AccessInputMeta(org.pentaho.di.trans.steps.accessinput.AccessInputMeta) TransMeta(org.pentaho.di.trans.TransMeta) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) Trans(org.pentaho.di.trans.Trans)

Example 57 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class MetaInjectDialog method ok.

private void ok() {
    if (Utils.isEmpty(wStepname.getText())) {
        return;
    }
    // return value
    stepname = wStepname.getText();
    try {
        loadTransformation();
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "MetaInjectDialog.ErrorLoadingSpecifiedTransformation.Title"), BaseMessages.getString(PKG, "MetaInjectDialog.ErrorLoadingSpecifiedTransformation.Message"), e);
    }
    if (repository != null) {
        specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME;
    } else {
        specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
    }
    metaInjectMeta.setSpecificationMethod(specificationMethod);
    switch(specificationMethod) {
        case FILENAME:
            metaInjectMeta.setFileName(wPath.getText());
            metaInjectMeta.setDirectoryPath(null);
            metaInjectMeta.setTransName(null);
            metaInjectMeta.setTransObjectId(null);
            break;
        case REPOSITORY_BY_NAME:
            String transPath = wPath.getText();
            String transName = transPath;
            String directory = "";
            int index = transPath.lastIndexOf("/");
            if (index != -1) {
                transName = transPath.substring(index + 1);
                directory = transPath.substring(0, index);
            }
            metaInjectMeta.setDirectoryPath(directory);
            metaInjectMeta.setTransName(transName);
            metaInjectMeta.setFileName(null);
            metaInjectMeta.setTransObjectId(null);
            break;
        default:
            break;
    }
    metaInjectMeta.setSourceStepName(wSourceStep.getText());
    metaInjectMeta.setSourceOutputFields(new ArrayList<MetaInjectOutputField>());
    for (int i = 0; i < wSourceFields.nrNonEmpty(); i++) {
        TableItem item = wSourceFields.getNonEmpty(i);
        int colIndex = 1;
        String name = item.getText(colIndex++);
        int type = ValueMetaFactory.getIdForValueMeta(item.getText(colIndex++));
        int length = Const.toInt(item.getText(colIndex++), -1);
        int precision = Const.toInt(item.getText(colIndex++), -1);
        metaInjectMeta.getSourceOutputFields().add(new MetaInjectOutputField(name, type, length, precision));
    }
    metaInjectMeta.setTargetFile(wTargetFile.getText());
    metaInjectMeta.setNoExecution(!wNoExecution.getSelection());
    final StepMeta streamSourceStep = transMeta.findStep(wStreamingSourceStep.getText());
    metaInjectMeta.setStreamSourceStep(streamSourceStep);
    // PDI-15989 Save streamSourceStepname to find streamSourceStep when loading
    metaInjectMeta.setStreamSourceStepname(streamSourceStep != null ? streamSourceStep.getName() : "");
    metaInjectMeta.setStreamTargetStepname(wStreamingTargetStep.getText());
    metaInjectMeta.setTargetSourceMapping(targetSourceMapping);
    metaInjectMeta.setChanged(true);
    dispose();
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) MetaInjectOutputField(org.pentaho.di.trans.steps.metainject.MetaInjectOutputField) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Point(org.eclipse.swt.graphics.Point)

Example 58 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class MetaInjectDialog method selectFileTrans.

private void selectFileTrans(boolean useVfs) {
    String curFile = transMeta.environmentSubstitute(wPath.getText());
    if (useVfs) {
        FileObject root = null;
        String parentFolder = null;
        try {
            parentFolder = KettleVFS.getFileObject(transMeta.environmentSubstitute(transMeta.getFilename())).getParent().toString();
        } catch (Exception e) {
        // Take no action
        }
        try {
            root = KettleVFS.getFileObject(curFile != null ? curFile : Const.getUserHomeDirectory());
            VfsFileChooserDialog vfsFileChooser = Spoon.getInstance().getVfsFileChooserDialog(root.getParent(), root);
            FileObject file = vfsFileChooser.open(shell, null, Const.STRING_TRANS_FILTER_EXT, Const.getTransformationFilterNames(), VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE);
            if (file == null) {
                return;
            }
            String fileName = file.getName().toString();
            if (fileName != null) {
                loadFileTrans(fileName);
                if (parentFolder != null && fileName.startsWith(parentFolder)) {
                    fileName = fileName.replace(parentFolder, "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}");
                }
                wPath.setText(fileName);
                specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
            }
        } catch (IOException | KettleException e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogMessage"), e);
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) VfsFileChooserDialog(org.pentaho.vfs.ui.VfsFileChooserDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) FileObject(org.apache.commons.vfs2.FileObject) IOException(java.io.IOException) KettleException(org.pentaho.di.core.exception.KettleException) IOException(java.io.IOException)

Example 59 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class JobEntryColumnsExistDialog method getSchemaNames.

private void getSchemaNames() {
    if (wSchemaname.isDisposed()) {
        return;
    }
    DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText());
    if (databaseMeta != null) {
        Database database = new Database(loggingObject, databaseMeta);
        database.shareVariablesWith(jobMeta);
        try {
            database.connect();
            String[] schemas = database.getSchemas();
            if (null != schemas && schemas.length > 0) {
                schemas = Const.sortStrings(schemas);
                EnterSelectionDialog dialog = new EnterSelectionDialog(shell, schemas, BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Title", wConnection.getText()), BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Message"));
                String d = dialog.open();
                if (d != null) {
                    wSchemaname.setText(Const.NVL(d.toString(), ""));
                }
            } else {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                mb.setMessage(BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Empty.Message"));
                mb.setText(BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Empty.Title"));
                mb.open();
            }
        } catch (Exception e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.ConnectionError"), e);
        } finally {
            if (database != null) {
                database.disconnect();
                database = null;
            }
        }
    }
}
Also used : Database(org.pentaho.di.core.database.Database) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 60 with ErrorDialog

use of org.pentaho.di.ui.core.dialog.ErrorDialog in project pentaho-kettle by pentaho.

the class MailInputDialog method preview.

// Preview the data
private void preview() {
    try {
        MailInputMeta oneMeta = new MailInputMeta();
        getInfo(oneMeta);
        TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "MailInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "MailInputDialog.NumberRows.DialogMessage"));
        int previewSize = numberDialog.open();
        if (previewSize > 0) {
            TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
            progressDialog.open();
            if (!progressDialog.isCancelled()) {
                Trans trans = progressDialog.getTrans();
                String loggingText = progressDialog.getLoggingText();
                if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
                    EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
                    etd.setReadOnly();
                    etd.open();
                }
                PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
                prd.open();
            }
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "MailInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "MailInputDialog.ErrorPreviewingData.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) MailInputMeta(org.pentaho.di.trans.steps.mailinput.MailInputMeta) TransMeta(org.pentaho.di.trans.TransMeta) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) Trans(org.pentaho.di.trans.Trans)

Aggregations

ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)527 KettleException (org.pentaho.di.core.exception.KettleException)440 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)178 MessageBox (org.eclipse.swt.widgets.MessageBox)118 TableItem (org.eclipse.swt.widgets.TableItem)97 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)76 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)63 TransMeta (org.pentaho.di.trans.TransMeta)48 Shell (org.eclipse.swt.widgets.Shell)46 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)46 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)44 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)44 ArrayList (java.util.ArrayList)43 TableItemInsertListener (org.pentaho.di.ui.trans.step.TableItemInsertListener)43 EnterSelectionDialog (org.pentaho.di.ui.core.dialog.EnterSelectionDialog)42 SelectionEvent (org.eclipse.swt.events.SelectionEvent)40 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)39 StepMeta (org.pentaho.di.trans.step.StepMeta)38 FormData (org.eclipse.swt.layout.FormData)37 FormLayout (org.eclipse.swt.layout.FormLayout)37