Search in sources :

Example 1 with XBaseInputMeta

use of org.pentaho.di.trans.steps.xbaseinput.XBaseInputMeta in project pentaho-kettle by pentaho.

the class XBaseInputDialog method preview.

// Preview the data
private void preview() {
    // Create the XML input step
    try {
        XBaseInputMeta oneMeta = new XBaseInputMeta();
        getInfo(oneMeta);
        if (oneMeta.isAcceptingFilenames()) {
            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
            mb.setMessage(BaseMessages.getString(PKG, "XBaseInputDialog.Dialog.SpecifyASampleFile.Message"));
            mb.setText(BaseMessages.getString(PKG, "XBaseInputDialog.Dialog.SpecifyASampleFile.Title"));
            mb.open();
            return;
        }
        TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "XBaseInputDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "XBaseInputDialog.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();
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), e);
    }
}
Also used : XBaseInputMeta(org.pentaho.di.trans.steps.xbaseinput.XBaseInputMeta) 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) KettleStepException(org.pentaho.di.core.exception.KettleStepException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

MessageBox (org.eclipse.swt.widgets.MessageBox)1 KettleStepException (org.pentaho.di.core.exception.KettleStepException)1 Trans (org.pentaho.di.trans.Trans)1 TransMeta (org.pentaho.di.trans.TransMeta)1 XBaseInputMeta (org.pentaho.di.trans.steps.xbaseinput.XBaseInputMeta)1 EnterNumberDialog (org.pentaho.di.ui.core.dialog.EnterNumberDialog)1 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1 PreviewRowsDialog (org.pentaho.di.ui.core.dialog.PreviewRowsDialog)1 TransPreviewProgressDialog (org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog)1