Search in sources :

Example 16 with PreviewRowsDialog

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

the class GetSubFoldersDialog method preview.

// Preview the data
private void preview() {
    // Create the XML input step
    GetSubFoldersMeta oneMeta = new GetSubFoldersMeta();
    getInfo(oneMeta);
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "GetSubFoldersDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "GetSubFoldersDialog.PreviewSize.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.Error.Title"), BaseMessages.getString(PKG, "GetSubFoldersDialog.ErrorInPreview.DialogMessage"), 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) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) GetSubFoldersMeta(org.pentaho.di.trans.steps.getsubfolders.GetSubFoldersMeta) Trans(org.pentaho.di.trans.Trans)

Example 17 with PreviewRowsDialog

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

the class TextFileInputDialog method preview.

// Preview the data
private void preview() {
    // Create the XML input step
    TextFileInputMeta oneMeta = new TextFileInputMeta();
    getInfo(oneMeta, true);
    if (oneMeta.inputFiles.acceptingFilenames) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
        mb.setMessage(BaseMessages.getString(PKG, "TextFileInputDialog.Dialog.SpecifyASampleFile.Message"));
        mb.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Dialog.SpecifyASampleFile.Title"));
        mb.open();
        return;
    }
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "TextFileInputDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "TextFileInputDialog.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 : TextFileInputMeta(org.pentaho.di.trans.steps.fileinput.text.TextFileInputMeta) 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 18 with PreviewRowsDialog

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

the class TransGraph method sniff.

public void sniff(final boolean input, final boolean output, final boolean error) {
    StepMeta stepMeta = getCurrentStep();
    if (stepMeta == null || trans == null) {
        return;
    }
    final StepInterface runThread = trans.findRunThread(stepMeta.getName());
    if (runThread != null) {
        List<Object[]> rows = new ArrayList<>();
        final PreviewRowsDialog dialog = new PreviewRowsDialog(shell, trans, SWT.NONE, stepMeta.getName(), null, rows);
        dialog.setDynamic(true);
        // Add a row listener that sends the rows over to the dialog...
        // 
        final RowListener rowListener = new RowListener() {

            @Override
            public void rowReadEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
                if (input) {
                    try {
                        dialog.addDataRow(rowMeta, rowMeta.cloneRow(row));
                    } catch (KettleValueException e) {
                        throw new KettleStepException(e);
                    }
                }
            }

            @Override
            public void rowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
                if (output) {
                    try {
                        dialog.addDataRow(rowMeta, rowMeta.cloneRow(row));
                    } catch (KettleValueException e) {
                        throw new KettleStepException(e);
                    }
                }
            }

            @Override
            public void errorRowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
                if (error) {
                    try {
                        dialog.addDataRow(rowMeta, rowMeta.cloneRow(row));
                    } catch (KettleValueException e) {
                        throw new KettleStepException(e);
                    }
                }
            }
        };
        // When the dialog is closed, make sure to remove the listener!
        // 
        dialog.addDialogClosedListener(new DialogClosedListener() {

            @Override
            public void dialogClosed() {
                runThread.removeRowListener(rowListener);
            }
        });
        // Open the dialog in a separate thread to make sure it doesn't block
        // 
        getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                dialog.open();
            }
        });
        runThread.addRowListener(rowListener);
    }
}
Also used : StepInterface(org.pentaho.di.trans.step.StepInterface) KettleStepException(org.pentaho.di.core.exception.KettleStepException) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) EnterPreviewRowsDialog(org.pentaho.di.ui.spoon.dialog.EnterPreviewRowsDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) KettleValueException(org.pentaho.di.core.exception.KettleValueException) StepMeta(org.pentaho.di.trans.step.StepMeta) RowListener(org.pentaho.di.trans.step.RowListener) DialogClosedListener(org.pentaho.di.ui.core.dialog.DialogClosedListener)

Example 19 with PreviewRowsDialog

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

the class DataOverrideHandler method showFeatureList.

public void showFeatureList() {
    Shell parent = getShell();
    DatabaseMeta dbinfo = new DatabaseMeta();
    getInfo(dbinfo);
    try {
        java.util.List<RowMetaAndData> buffer = dbinfo.getFeatureSummary();
        if (buffer.size() > 0) {
            RowMetaInterface rowMeta = buffer.get(0).getRowMeta();
            java.util.List<Object[]> rowData = new ArrayList<Object[]>();
            for (RowMetaAndData row : buffer) {
                rowData.add(row.getData());
            }
            PreviewRowsDialog prd = new PreviewRowsDialog(parent, dbinfo, SWT.NONE, null, rowMeta, rowData);
            prd.setTitleMessage(BaseMessages.getString(PKG, "DatabaseDialog.FeatureList.title"), BaseMessages.getString(PKG, "DatabaseDialog.FeatureList.title"));
            prd.open();
        }
    } catch (Exception e) {
        new ErrorDialog(parent, BaseMessages.getString(PKG, "DatabaseDialog.FeatureListError.title"), BaseMessages.getString(PKG, "DatabaseDialog.FeatureListError.description"), e);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ArrayList(java.util.ArrayList) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 20 with PreviewRowsDialog

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

the class XulDatabaseExplorerController method preview.

public void preview(boolean askLimit) {
    if (model.getTable() == null) {
        return;
    }
    try {
        PromptCallback theCallback = new PromptCallback();
        @SuppressWarnings("unused") boolean execute = true;
        int limit = 100;
        if (askLimit) {
            XulPromptBox thePromptBox = (XulPromptBox) this.document.createElement("promptbox");
            thePromptBox.setModalParent(this.dbExplorerDialog.getShell());
            thePromptBox.setTitle("Enter Max Rows");
            thePromptBox.setMessage("Max Rows:");
            thePromptBox.addDialogCallback(theCallback);
            thePromptBox.open();
            execute = theCallback.getLimit() != -1;
            limit = theCallback.getLimit();
        }
        // if (execute) {
        // XulPreviewRowsDialog thePreviewRowsDialog = new XulPreviewRowsDialog(this.shell, SWT.NONE,
        // this.model.getDatabaseMeta(), this.model.getTable(), theCallback.getLimit());
        // thePreviewRowsDialog.open();
        // }
        GetPreviewTableProgressDialog pd = new GetPreviewTableProgressDialog(this.dbExplorerDialog.getShell(), this.model.getDatabaseMeta(), model.getSchema(), model.getTable(), limit);
        List<Object[]> rows = pd.open();
        if (rows != null) {
            if (rows.size() > 0) {
                PreviewRowsDialog prd = new PreviewRowsDialog(this.dbExplorerDialog.getShell(), this.model.getDatabaseMeta(), SWT.None, this.model.getTable(), pd.getRowMeta(), rows);
                prd.open();
            } else {
                MessageBox mb = new MessageBox(this.dbExplorerDialog.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mb.setMessage(BaseMessages.getString(PKG, "DatabaseExplorerDialog.NoRows.Message"));
                mb.setText(BaseMessages.getString(PKG, "DatabaseExplorerDialog.NoRows.Title"));
                mb.open();
            }
        }
    } catch (Exception e) {
        LogChannel.GENERAL.logError("Error previewing rows", e);
    }
}
Also used : XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) XulException(org.pentaho.ui.xul.XulException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

PreviewRowsDialog (org.pentaho.di.ui.core.dialog.PreviewRowsDialog)56 TransMeta (org.pentaho.di.trans.TransMeta)49 TransPreviewProgressDialog (org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog)48 Trans (org.pentaho.di.trans.Trans)47 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)47 EnterNumberDialog (org.pentaho.di.ui.core.dialog.EnterNumberDialog)44 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)30 KettleException (org.pentaho.di.core.exception.KettleException)25 MessageBox (org.eclipse.swt.widgets.MessageBox)10 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)9 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)9 ArrayList (java.util.ArrayList)5 Point (org.eclipse.swt.graphics.Point)5 StepMeta (org.pentaho.di.trans.step.StepMeta)4 Date (java.util.Date)3 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)3 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)3 StepPluginType (org.pentaho.di.core.plugins.StepPluginType)3 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)3 TransHopMeta (org.pentaho.di.trans.TransHopMeta)3