Search in sources :

Example 31 with EnterNumberDialog

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

the class GaInputStepDialog method preview.

// Preview the data
private void preview() {
    // Create the XML input step
    GaInputStepMeta oneMeta = new GaInputStepMeta();
    getInfo(oneMeta);
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "GoogleAnalyticsDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "GoogleAnalyticsDialog.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 : GaInputStepMeta(org.pentaho.di.trans.steps.googleanalytics.GaInputStepMeta) 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) Trans(org.pentaho.di.trans.Trans)

Example 32 with EnterNumberDialog

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

the class SapInputDialog method preview.

// Preview the data
// unused
// preserve for later
private void preview() {
    // Create the XML input step
    SapInputMeta oneMeta = new SapInputMeta();
    getInfo(oneMeta);
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
    transMeta.getVariable("Internal.Transformation.Filename.Directory");
    previewMeta.getVariable("Internal.Transformation.Filename.Directory");
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "CsvInputDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "CsvInputDialog.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) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) Trans(org.pentaho.di.trans.Trans)

Example 33 with EnterNumberDialog

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

the class XMLInputDialog method get.

private void get() {
    boolean finished = false;
    int elementsFound = 0;
    try {
        XMLInputMeta meta = new XMLInputMeta();
        getInfo(meta);
        // check if the path is given
        if (!checkInputPositionsFilled(meta)) {
            return;
        }
        EnterNumberDialog dialog = new EnterNumberDialog(shell, 1000, "Number of elements to scan", "Enter the number of elements to scan (0=all)");
        int maxElements = dialog.open();
        // OK, let's try to walk through the complete tree
        // no fields found...
        RowMetaInterface row = new RowMeta();
        // Keep the list of positions
        // ArrayList of XMLInputFieldPosition
        List<XMLInputFieldPosition> path = new ArrayList<XMLInputFieldPosition>();
        FileInputList inputList = meta.getFiles(transMeta);
        for (int f = 0; f < inputList.getFiles().size() && !finished; f++) {
            // Open the file...
            Node rootNode = XMLHandler.loadXMLFile(inputList.getFile(f), transMeta.environmentSubstitute(meta.getFileBaseURI()), meta.isIgnoreEntities(), meta.isNamespaceAware());
            // Position to the repeating item
            for (int p = 0; rootNode != null && p < meta.getInputPosition().length - 1; p++) {
                rootNode = XMLHandler.getSubNode(rootNode, meta.getInputPosition()[p]);
            }
            if (rootNode == null) {
                // Specified node not found: return!
                return;
            }
            if (meta.getInputPosition().length > 1) {
                // Count the number of rootnodes
                String itemElement = meta.getInputPosition()[meta.getInputPosition().length - 1];
                int nrItems = XMLHandler.countNodes(rootNode, itemElement);
                for (int i = 0; i < nrItems && !finished; i++) {
                    Node itemNode = XMLHandler.getSubNodeByNr(rootNode, itemElement, i, false);
                    if (i >= meta.getNrRowsToSkip()) {
                        getValues(itemNode, row, path, 0);
                        elementsFound++;
                        if (elementsFound >= maxElements && maxElements > 0) {
                            finished = true;
                        }
                    }
                }
            } else {
                // Only search the root node
                // 
                getValues(rootNode, row, path, 0);
                elementsFound++;
                if (elementsFound >= maxElements && maxElements > 0) {
                    finished = true;
                }
            }
        }
        // add the values to the grid...
        for (int i = 0; i < row.size(); i++) {
            ValueMetaInterface v = row.getValueMeta(i);
            TableItem item = new TableItem(wFields.table, SWT.NONE);
            item.setText(1, v.getName());
            item.setText(2, v.getTypeDesc());
            item.setText(11, v.getOrigin());
        }
        wFields.removeEmptyRows();
        wFields.setRowNums();
        wFields.optWidth(true);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "XMLInputDialog.ErrorParsingData.DialogTitle"), BaseMessages.getString(PKG, "XMLInputDialog.ErrorParsingData.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) XMLInputFieldPosition(org.pentaho.di.trans.steps.xmlinput.XMLInputFieldPosition) RowMeta(org.pentaho.di.core.row.RowMeta) Node(org.w3c.dom.Node) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) XMLInputMeta(org.pentaho.di.trans.steps.xmlinput.XMLInputMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) FileInputList(org.pentaho.di.core.fileinput.FileInputList)

Example 34 with EnterNumberDialog

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

the class XMLInputDialog method preview.

// Preview the data
private void preview() {
    try {
        // Create the XML input step
        XMLInputMeta oneMeta = new XMLInputMeta();
        getInfo(oneMeta);
        // check if the path is given
        if (!checkInputPositionsFilled(oneMeta)) {
            return;
        }
        TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "XMLInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "XMLInputDialog.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, "XMLInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "XMLInputDialog.ErrorPreviewingData.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) 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) XMLInputMeta(org.pentaho.di.trans.steps.xmlinput.XMLInputMeta) Trans(org.pentaho.di.trans.Trans)

Example 35 with EnterNumberDialog

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

the class SpoonSlave method sniff.

protected void sniff() {
    TreeItem[] ti = wTree.getSelection();
    if (ti.length == 1) {
        TreeItem treeItem = ti[0];
        String[] path = ConstUI.getTreeStrings(treeItem);
        // Make sure we're positioned on a step
        if (path.length <= 2) {
            return;
        }
        String name = path[1];
        String step = path[2];
        String copy = treeItem.getText(1);
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, PropsUI.getInstance().getDefaultPreviewSize(), BaseMessages.getString(PKG, "SpoonSlave.SniffSizeQuestion.Title"), BaseMessages.getString(PKG, "SpoonSlave.SniffSizeQuestion.Message"));
        int lines = numberDialog.open();
        if (lines <= 0) {
            return;
        }
        EnterSelectionDialog selectionDialog = new EnterSelectionDialog(shell, new String[] { SniffStepServlet.TYPE_INPUT, SniffStepServlet.TYPE_OUTPUT }, BaseMessages.getString(PKG, "SpoonSlave.SniffTypeQuestion.Title"), BaseMessages.getString(PKG, "SpoonSlave.SniffTypeQuestion.Message"));
        String type = selectionDialog.open(1);
        if (type == null) {
            return;
        }
        try {
            String xml = slaveServer.sniffStep(name, step, copy, lines, type);
            Document doc = XMLHandler.loadXMLString(xml);
            Node node = XMLHandler.getSubNode(doc, SniffStepServlet.XML_TAG);
            Node metaNode = XMLHandler.getSubNode(node, RowMeta.XML_META_TAG);
            RowMetaInterface rowMeta = new RowMeta(metaNode);
            int nrRows = Const.toInt(XMLHandler.getTagValue(node, "nr_rows"), 0);
            List<Object[]> rowBuffer = new ArrayList<Object[]>();
            for (int i = 0; i < nrRows; i++) {
                Node dataNode = XMLHandler.getSubNodeByNr(node, RowMeta.XML_DATA_TAG, i);
                Object[] row = rowMeta.getRow(dataNode);
                rowBuffer.add(row);
            }
            PreviewRowsDialog prd = new PreviewRowsDialog(shell, new Variables(), SWT.NONE, step, rowMeta, rowBuffer);
            prd.open();
        } catch (Exception e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorSniffingStep.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorSniffingStep.Message"), e);
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) RowMeta(org.pentaho.di.core.row.RowMeta) Node(org.w3c.dom.Node) 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) Document(org.w3c.dom.Document) Variables(org.pentaho.di.core.variables.Variables) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog)

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