Search in sources :

Example 51 with EnterNumberDialog

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

the class LDIFInputDialog method preview.

// Preview the data
private void preview() {
    try {
        // Create the LDIF input step
        LDIFInputMeta oneMeta = new LDIFInputMeta();
        getInfo(oneMeta);
        TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "LDIFInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "LDIFInputDialog.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, "LDIFInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "LDIFInputDialog.ErrorPreviewingData.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) LDIFInputMeta(org.pentaho.di.trans.steps.ldifinput.LDIFInputMeta) 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 52 with EnterNumberDialog

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

the class LoadFileInputDialog method preview.

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

EnterNumberDialog (org.pentaho.di.ui.core.dialog.EnterNumberDialog)52 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)48 PreviewRowsDialog (org.pentaho.di.ui.core.dialog.PreviewRowsDialog)44 TransMeta (org.pentaho.di.trans.TransMeta)43 TransPreviewProgressDialog (org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog)43 Trans (org.pentaho.di.trans.Trans)42 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)31 KettleException (org.pentaho.di.core.exception.KettleException)28 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)13 MessageBox (org.eclipse.swt.widgets.MessageBox)9 TableItem (org.eclipse.swt.widgets.TableItem)6 IOException (java.io.IOException)5 InputStream (java.io.InputStream)5 InputStreamReader (java.io.InputStreamReader)5 FileObject (org.apache.commons.vfs2.FileObject)4 KettleStepException (org.pentaho.di.core.exception.KettleStepException)4 DecimalFormat (java.text.DecimalFormat)3 FileInputList (org.pentaho.di.core.fileinput.FileInputList)3 TextFileInputMeta (org.pentaho.di.trans.steps.fileinput.text.TextFileInputMeta)3 EncodingType (org.pentaho.di.trans.steps.textfileinput.EncodingType)3