Search in sources :

Example 56 with EnterTextDialog

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

the class ExcelInputDialog method preview.

/**
 * Preview the data generated by this step. This generates a transformation using this step & a dummy and previews it.
 */
private void preview() {
    // Create the excel reader step...
    ExcelInputMeta oneMeta = new ExcelInputMeta();
    getInfo(oneMeta);
    if (oneMeta.isAcceptingFilenames()) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
        // Nothing
        mb.setMessage(BaseMessages.getString(PKG, "ExcelInputDialog.Dialog.SpecifyASampleFile.Message"));
        // found
        // that
        // matches
        // your
        // criteria
        // Sorry!
        mb.setText(BaseMessages.getString(PKG, "ExcelInputDialog.Dialog.SpecifyASampleFile.Title"));
        mb.open();
        return;
    }
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "ExcelInputDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "ExcelInputDialog.PreviewSize.DialogMessage"));
    int previewSize = numberDialog.open();
    if (previewSize > 0) {
        TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
        progressDialog.open();
        Trans trans = progressDialog.getTrans();
        String loggingText = progressDialog.getLoggingText();
        if (!progressDialog.isCancelled()) {
            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();
    }
}
Also used : ExcelInputMeta(org.pentaho.di.trans.steps.excelinput.ExcelInputMeta) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) Trans(org.pentaho.di.trans.Trans) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 57 with EnterTextDialog

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

the class PaloDimInputDialog method preview.

private void preview() {
    PaloDimInputMeta oneMeta = new PaloDimInputMeta();
    try {
        getInfo(oneMeta);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "PaloInputDialog.Illegal.Dialog.Settings.Title"), BaseMessages.getString(PKG, "PaloInputDialog.Illegal.Dialog.Settings.Message"), e);
        return;
    }
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, textStepName.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, 500, BaseMessages.getString("System.Dialog.EnterPreviewSize.Title"), BaseMessages.getString("System.Dialog.EnterPreviewSize.Message"));
    int previewSize = numberDialog.open();
    if (previewSize > 0) {
        TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { textStepName.getText() }, new int[] { previewSize });
        progressDialog.open();
        Trans trans = progressDialog.getTrans();
        String loggingText = progressDialog.getLoggingText();
        if (!progressDialog.isCancelled()) {
            if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
                EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString("System.Dialog.PreviewError.Title"), BaseMessages.getString("System.Dialog.PreviewError.Message"), loggingText, true);
                etd.setReadOnly();
                etd.open();
            }
        }
        PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, textStepName.getText(), progressDialog.getPreviewRowsMeta(textStepName.getText()), progressDialog.getPreviewRows(textStepName.getText()), loggingText);
        prd.open();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) PaloDimInputMeta(org.pentaho.di.trans.steps.palo.diminput.PaloDimInputMeta) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) Trans(org.pentaho.di.trans.Trans)

Example 58 with EnterTextDialog

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

the class JsonInputDialog method preview.

// Preview the data
private void preview() {
    try {
        JsonInputMeta oneMeta = new JsonInputMeta();
        getInfo(oneMeta);
        TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "JsonInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "JsonInputDialog.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, "JsonInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "JsonInputDialog.ErrorPreviewingData.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JsonInputMeta(org.pentaho.di.trans.steps.jsoninput.JsonInputMeta) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) 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 59 with EnterTextDialog

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

the class FixedInputDialog method getFirst.

// Grab the first x lines from the given file...
// 
private List<String> getFirst(FixedInputMeta meta, int limit) throws IOException, KettleValueException {
    List<String> lines = new ArrayList<String>();
    FixedInputMeta oneMeta = new FixedInputMeta();
    getInfo(oneMeta);
    // Add a single field with the width of the line...
    // 
    int lineWidth = Integer.parseInt(oneMeta.getLineWidth());
    if (lineWidth <= 0) {
        throw new IOException("The width of a line can not be 0 or less.");
    }
    oneMeta.allocate(1);
    FixedFileInputField field = new FixedFileInputField();
    field.setName("Field1");
    field.setType(ValueMetaInterface.TYPE_STRING);
    field.setWidth(lineWidth);
    // CHECKSTYLE:Indentation:OFF
    oneMeta.getFieldDefinition()[0] = field;
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
    TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { limit });
    progressDialog.open();
    Trans trans = progressDialog.getTrans();
    String loggingText = progressDialog.getLoggingText();
    if (!progressDialog.isCancelled()) {
        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();
        }
    }
    // The rows are in the transformation...
    // 
    RowMetaInterface previewRowsMeta = progressDialog.getPreviewRowsMeta(wStepname.getText());
    List<Object[]> previewRowsData = progressDialog.getPreviewRows(wStepname.getText());
    for (int i = 0; i < previewRowsData.size(); i++) {
        String line = previewRowsMeta.getString(previewRowsData.get(i), 0);
        lines.add(line);
    }
    return lines;
}
Also used : TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) ArrayList(java.util.ArrayList) TransMeta(org.pentaho.di.trans.TransMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) IOException(java.io.IOException) FixedFileInputField(org.pentaho.di.trans.steps.fixedinput.FixedFileInputField) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) FixedInputMeta(org.pentaho.di.trans.steps.fixedinput.FixedInputMeta) Trans(org.pentaho.di.trans.Trans)

Example 60 with EnterTextDialog

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

the class FixedInputDialog method preview.

// Preview the data
private void preview() {
    // execute a complete preview transformation in the background.
    // This is how we do it...
    // 
    FixedInputMeta oneMeta = new FixedInputMeta();
    getInfo(oneMeta);
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "FixedInputDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "FixedInputDialog.PreviewSize.DialogMessage"));
    int previewSize = numberDialog.open();
    if (previewSize > 0) {
        TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
        progressDialog.open();
        Trans trans = progressDialog.getTrans();
        String loggingText = progressDialog.getLoggingText();
        if (!progressDialog.isCancelled()) {
            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();
    }
}
Also used : TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) FixedInputMeta(org.pentaho.di.trans.steps.fixedinput.FixedInputMeta) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) Trans(org.pentaho.di.trans.Trans)

Aggregations

EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)70 EnterNumberDialog (org.pentaho.di.ui.core.dialog.EnterNumberDialog)48 Trans (org.pentaho.di.trans.Trans)47 TransMeta (org.pentaho.di.trans.TransMeta)47 PreviewRowsDialog (org.pentaho.di.ui.core.dialog.PreviewRowsDialog)47 TransPreviewProgressDialog (org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog)47 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)44 KettleException (org.pentaho.di.core.exception.KettleException)35 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)17 MessageBox (org.eclipse.swt.widgets.MessageBox)15 IOException (java.io.IOException)7 InputStream (java.io.InputStream)6 FileObject (org.apache.commons.vfs2.FileObject)6 InputStreamReader (java.io.InputStreamReader)5 Point (org.eclipse.swt.graphics.Point)5 TableItem (org.eclipse.swt.widgets.TableItem)5 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)5 FileDialog (org.eclipse.swt.widgets.FileDialog)4 KettleStepException (org.pentaho.di.core.exception.KettleStepException)4 DecimalFormat (java.text.DecimalFormat)3