Search in sources :

Example 36 with EnterTextDialog

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

the class SlaveServerDialog method test.

public void test() {
    try {
        getInfo();
        String xml = "<sample/>";
        String reply = slaveServer.sendXML(xml, RegisterTransServlet.CONTEXT_PATH);
        String message = BaseMessages.getString(PKG, "SlaveServer.Replay.Info1") + slaveServer.constructUrl(RegisterTransServlet.CONTEXT_PATH) + Const.CR + BaseMessages.getString(PKG, "SlaveServer.Replay.Info2") + Const.CR + Const.CR;
        message += xml;
        message += Const.CR + Const.CR;
        message += "Reply was:" + Const.CR + Const.CR;
        message += reply + Const.CR;
        EnterTextDialog dialog = new EnterTextDialog(shell, "XML", BaseMessages.getString(PKG, "SlaveServer.RetournedXMLInfo"), message);
        dialog.open();
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SlaveServer.ExceptionError"), BaseMessages.getString(PKG, "SlaveServer.ExceptionUnableGetReplay.Error1") + slaveServer.getHostname() + BaseMessages.getString(PKG, "SlaveServer.ExceptionUnableGetReplay.Error2"), e);
    }
}
Also used : EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog)

Example 37 with EnterTextDialog

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

the class GetXMLDataDialog method preview.

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

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

the class ScriptDialog method newTest.

private boolean newTest() {
    PluginRegistry registry = PluginRegistry.getInstance();
    String scriptStepName = wStepname.getText();
    try {
        // What fields are coming into the step?
        // 
        RowMetaInterface rowMeta = transMeta.getPrevStepFields(stepname).clone();
        if (rowMeta != null) {
            // 
            if (genMeta == null) {
                genMeta = new RowGeneratorMeta();
                genMeta.setRowLimit("10");
                genMeta.allocate(rowMeta.size());
                // CHECKSTYLE:Indentation:OFF
                for (int i = 0; i < rowMeta.size(); i++) {
                    ValueMetaInterface valueMeta = rowMeta.getValueMeta(i);
                    if (valueMeta.isStorageBinaryString()) {
                        valueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
                    }
                    genMeta.getFieldName()[i] = valueMeta.getName();
                    genMeta.getFieldType()[i] = valueMeta.getTypeDesc();
                    genMeta.getFieldLength()[i] = valueMeta.getLength();
                    genMeta.getFieldPrecision()[i] = valueMeta.getPrecision();
                    genMeta.getCurrency()[i] = valueMeta.getCurrencySymbol();
                    genMeta.getDecimal()[i] = valueMeta.getDecimalSymbol();
                    genMeta.getGroup()[i] = valueMeta.getGroupingSymbol();
                    String string = null;
                    switch(valueMeta.getType()) {
                        case ValueMetaInterface.TYPE_DATE:
                            genMeta.getFieldFormat()[i] = "yyyy/MM/dd HH:mm:ss";
                            valueMeta.setConversionMask(genMeta.getFieldFormat()[i]);
                            string = valueMeta.getString(new Date());
                            break;
                        case ValueMetaInterface.TYPE_STRING:
                            string = "test value test value";
                            break;
                        case ValueMetaInterface.TYPE_INTEGER:
                            genMeta.getFieldFormat()[i] = "#";
                            valueMeta.setConversionMask(genMeta.getFieldFormat()[i]);
                            string = valueMeta.getString(Long.valueOf(0L));
                            break;
                        case ValueMetaInterface.TYPE_NUMBER:
                            genMeta.getFieldFormat()[i] = "#.#";
                            valueMeta.setConversionMask(genMeta.getFieldFormat()[i]);
                            string = valueMeta.getString(Double.valueOf(0.0D));
                            break;
                        case ValueMetaInterface.TYPE_BIGNUMBER:
                            genMeta.getFieldFormat()[i] = "#.#";
                            valueMeta.setConversionMask(genMeta.getFieldFormat()[i]);
                            string = valueMeta.getString(BigDecimal.ZERO);
                            break;
                        case ValueMetaInterface.TYPE_BOOLEAN:
                            string = valueMeta.getString(Boolean.TRUE);
                            break;
                        case ValueMetaInterface.TYPE_BINARY:
                            string = valueMeta.getString(new byte[] { 65, 66, 67, 68, 69, 70, 71, 72, 73, 74 });
                            break;
                        default:
                            break;
                    }
                    genMeta.getValue()[i] = string;
                }
            }
            StepMeta genStep = new StepMeta(registry.getPluginId(StepPluginType.class, genMeta), "## TEST DATA ##", genMeta);
            genStep.setLocation(50, 50);
            // Now create a JavaScript step with the information in this dialog
            // 
            ScriptMeta scriptMeta = new ScriptMeta();
            getInfo(scriptMeta);
            StepMeta scriptStep = new StepMeta(registry.getPluginId(StepPluginType.class, scriptMeta), Const.NVL(scriptStepName, "## SCRIPT ##"), scriptMeta);
            scriptStepName = scriptStep.getName();
            scriptStep.setLocation(150, 50);
            // Create a hop between both steps...
            // 
            TransHopMeta hop = new TransHopMeta(genStep, scriptStep);
            // Generate a new test transformation...
            // 
            TransMeta transMeta = new TransMeta();
            transMeta.setName(wStepname.getText() + " - PREVIEW");
            transMeta.addStep(genStep);
            transMeta.addStep(scriptStep);
            transMeta.addTransHop(hop);
            // 
            if (Spoon.getInstance().editStep(transMeta, genStep) != null) {
                // Now run this transformation and grab the results...
                // 
                TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, transMeta, new String[] { scriptStepName }, new int[] { Const.toInt(genMeta.getRowLimit(), 10) });
                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();
                    }
                }
                RowMetaInterface previewRowsMeta = progressDialog.getPreviewRowsMeta(wStepname.getText());
                List<Object[]> previewRows = progressDialog.getPreviewRows(wStepname.getText());
                if (previewRowsMeta != null && previewRows != null && previewRows.size() > 0) {
                    PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), previewRowsMeta, previewRows, loggingText);
                    prd.open();
                }
            }
            return true;
        } else {
            throw new KettleException(BaseMessages.getString(PKG, "ScriptDialog.Exception.CouldNotGetFields"));
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "ScriptDialog.TestFailed.DialogTitle"), BaseMessages.getString(PKG, "ScriptDialog.TestFailed.DialogMessage"), e);
        return false;
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) RowGeneratorMeta(org.pentaho.di.trans.steps.rowgenerator.RowGeneratorMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Point(org.eclipse.swt.graphics.Point) Date(java.util.Date) EvaluatorException(org.mozilla.javascript.EvaluatorException) JavaScriptException(org.mozilla.javascript.JavaScriptException) KettleException(org.pentaho.di.core.exception.KettleException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) ScriptMeta(org.pentaho.di.trans.steps.script.ScriptMeta) StepPluginType(org.pentaho.di.core.plugins.StepPluginType) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) TransHopMeta(org.pentaho.di.trans.TransHopMeta) Trans(org.pentaho.di.trans.Trans)

Example 39 with EnterTextDialog

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

the class ScriptValuesModDialog method newTest.

private boolean newTest() {
    PluginRegistry registry = PluginRegistry.getInstance();
    String scriptStepName = wStepname.getText();
    try {
        // What fields are coming into the step?
        // 
        RowMetaInterface rowMeta = transMeta.getPrevStepFields(stepname).clone();
        if (rowMeta != null) {
            // 
            if (genMeta == null) {
                genMeta = new RowGeneratorMeta();
                genMeta.setRowLimit("10");
                genMeta.allocate(rowMeta.size());
                // CHECKSTYLE:Indentation:OFF
                for (int i = 0; i < rowMeta.size(); i++) {
                    ValueMetaInterface valueMeta = rowMeta.getValueMeta(i);
                    if (valueMeta.isStorageBinaryString()) {
                        valueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
                    }
                    genMeta.getFieldName()[i] = valueMeta.getName();
                    genMeta.getFieldType()[i] = valueMeta.getTypeDesc();
                    genMeta.getFieldLength()[i] = valueMeta.getLength();
                    genMeta.getFieldPrecision()[i] = valueMeta.getPrecision();
                    genMeta.getCurrency()[i] = valueMeta.getCurrencySymbol();
                    genMeta.getDecimal()[i] = valueMeta.getDecimalSymbol();
                    genMeta.getGroup()[i] = valueMeta.getGroupingSymbol();
                    String string = null;
                    switch(valueMeta.getType()) {
                        case ValueMetaInterface.TYPE_DATE:
                            genMeta.getFieldFormat()[i] = "yyyy/MM/dd HH:mm:ss";
                            valueMeta.setConversionMask(genMeta.getFieldFormat()[i]);
                            string = valueMeta.getString(new Date());
                            break;
                        case ValueMetaInterface.TYPE_STRING:
                            string = "test value test value";
                            break;
                        case ValueMetaInterface.TYPE_INTEGER:
                            genMeta.getFieldFormat()[i] = "#";
                            valueMeta.setConversionMask(genMeta.getFieldFormat()[i]);
                            string = valueMeta.getString(Long.valueOf(0L));
                            break;
                        case ValueMetaInterface.TYPE_NUMBER:
                            genMeta.getFieldFormat()[i] = "#.#";
                            valueMeta.setConversionMask(genMeta.getFieldFormat()[i]);
                            string = valueMeta.getString(Double.valueOf(0.0D));
                            break;
                        case ValueMetaInterface.TYPE_BIGNUMBER:
                            genMeta.getFieldFormat()[i] = "#.#";
                            valueMeta.setConversionMask(genMeta.getFieldFormat()[i]);
                            string = valueMeta.getString(BigDecimal.ZERO);
                            break;
                        case ValueMetaInterface.TYPE_BOOLEAN:
                            string = valueMeta.getString(Boolean.TRUE);
                            break;
                        case ValueMetaInterface.TYPE_BINARY:
                            string = valueMeta.getString(new byte[] { 65, 66, 67, 68, 69, 70, 71, 72, 73, 74 });
                            break;
                        default:
                            break;
                    }
                    genMeta.getValue()[i] = string;
                }
            }
            StepMeta genStep = new StepMeta(registry.getPluginId(StepPluginType.class, genMeta), "## TEST DATA ##", genMeta);
            genStep.setLocation(50, 50);
            // Now create a JavaScript step with the information in this dialog
            // 
            ScriptValuesMetaMod scriptMeta = new ScriptValuesMetaMod();
            getInfo(scriptMeta);
            StepMeta scriptStep = new StepMeta(registry.getPluginId(StepPluginType.class, scriptMeta), Const.NVL(scriptStepName, "## SCRIPT ##"), scriptMeta);
            scriptStepName = scriptStep.getName();
            scriptStep.setLocation(150, 50);
            // Create a hop between both steps...
            // 
            TransHopMeta hop = new TransHopMeta(genStep, scriptStep);
            // Generate a new test transformation...
            // 
            TransMeta transMeta = new TransMeta();
            transMeta.setName(wStepname.getText() + " - PREVIEW");
            transMeta.addStep(genStep);
            transMeta.addStep(scriptStep);
            transMeta.addTransHop(hop);
            // 
            if (Spoon.getInstance().editStep(transMeta, genStep) != null) {
                // Now run this transformation and grab the results...
                // 
                TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, transMeta, new String[] { scriptStepName }, new int[] { Const.toInt(genMeta.getRowLimit(), 10) });
                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();
                    }
                }
                RowMetaInterface previewRowsMeta = progressDialog.getPreviewRowsMeta(wStepname.getText());
                List<Object[]> previewRows = progressDialog.getPreviewRows(wStepname.getText());
                if (previewRowsMeta != null && previewRows != null && previewRows.size() > 0) {
                    PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), previewRowsMeta, previewRows, loggingText);
                    prd.open();
                }
            }
            return true;
        } else {
            throw new KettleException(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Exception.CouldNotGetFields"));
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "ScriptValuesDialogMod.TestFailed.DialogTitle"), BaseMessages.getString(PKG, "ScriptValuesDialogMod.TestFailed.DialogMessage"), e);
        return false;
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) RowGeneratorMeta(org.pentaho.di.trans.steps.rowgenerator.RowGeneratorMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Point(org.eclipse.swt.graphics.Point) Date(java.util.Date) EvaluatorException(org.mozilla.javascript.EvaluatorException) JavaScriptException(org.mozilla.javascript.JavaScriptException) KettleException(org.pentaho.di.core.exception.KettleException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) StepPluginType(org.pentaho.di.core.plugins.StepPluginType) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) TransHopMeta(org.pentaho.di.trans.TransHopMeta) Trans(org.pentaho.di.trans.Trans) ScriptValuesMetaMod(org.pentaho.di.trans.steps.scriptvalues_mod.ScriptValuesMetaMod)

Example 40 with EnterTextDialog

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

the class SSHDialog method preview.

/**
 * Preview the data generated by this step. This generates a transformation using this step & a dummy and previews it.
 */
private void preview() {
    try {
        // Create the Access input step
        SSHMeta oneMeta = new SSHMeta();
        getInfo(oneMeta);
        TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, 1, BaseMessages.getString(PKG, "SSHDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "SSHDialog.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, "Error", "Error while previewing data", 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) Trans(org.pentaho.di.trans.Trans) SSHMeta(org.pentaho.di.trans.steps.ssh.SSHMeta)

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