Search in sources :

Example 66 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class StringOperationsDialog method open.

public String open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    setShellImage(shell, input);
    ModifyListener lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            input.setChanged();
        }
    };
    changed = input.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "StringOperationsDialog.Shell.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "StringOperationsDialog.Stepname.Label"));
    props.setLook(wlStepname);
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment(0, 0);
    fdlStepname.right = new FormAttachment(middle, -margin);
    fdlStepname.top = new FormAttachment(0, margin);
    wlStepname.setLayoutData(fdlStepname);
    wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wStepname.setText(stepname);
    props.setLook(wStepname);
    wStepname.addModifyListener(lsMod);
    fdStepname = new FormData();
    fdStepname.left = new FormAttachment(middle, 0);
    fdStepname.top = new FormAttachment(0, margin);
    fdStepname.right = new FormAttachment(100, 0);
    wStepname.setLayoutData(fdStepname);
    wlKey = new Label(shell, SWT.NONE);
    wlKey.setText(BaseMessages.getString(PKG, "StringOperationsDialog.Fields.Label"));
    props.setLook(wlKey);
    fdlKey = new FormData();
    fdlKey.left = new FormAttachment(0, 0);
    fdlKey.top = new FormAttachment(wStepname, 2 * margin);
    wlKey.setLayoutData(fdlKey);
    int nrFieldCols = 11;
    int nrFieldRows = (input.getFieldInStream() != null ? input.getFieldInStream().length : 1);
    ciKey = new ColumnInfo[nrFieldCols];
    ciKey[0] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.InStreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
    ciKey[1] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.OutStreamField"), ColumnInfo.COLUMN_TYPE_TEXT, false);
    ciKey[2] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.Trim"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.trimTypeDesc, true);
    ciKey[3] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.LowerUpper"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.lowerUpperDesc, true);
    ciKey[4] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.Padding"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.paddingDesc, true);
    ciKey[5] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.CharPad"), ColumnInfo.COLUMN_TYPE_TEXT, false);
    ciKey[6] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.LenPad"), ColumnInfo.COLUMN_TYPE_TEXT, false);
    ciKey[7] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.InitCap"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.initCapDesc);
    ciKey[8] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.MaskXML"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.maskXMLDesc);
    ciKey[9] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.Digits"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.digitsDesc);
    ciKey[10] = new ColumnInfo(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.RemoveSpecialCharacters"), ColumnInfo.COLUMN_TYPE_CCOMBO, StringOperationsMeta.removeSpecialCharactersDesc);
    ciKey[1].setToolTip(BaseMessages.getString(PKG, "StringOperationsDialog.ColumnInfo.OutStreamField.Tooltip"));
    ciKey[1].setUsingVariables(true);
    ciKey[4].setUsingVariables(true);
    ciKey[5].setUsingVariables(true);
    ciKey[6].setUsingVariables(true);
    ciKey[7].setUsingVariables(true);
    wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciKey, nrFieldRows, lsMod, props);
    fdKey = new FormData();
    fdKey.left = new FormAttachment(0, 0);
    fdKey.top = new FormAttachment(wlKey, margin);
    fdKey.right = new FormAttachment(100, -margin);
    fdKey.bottom = new FormAttachment(100, -30);
    wFields.setLayoutData(fdKey);
    // THE BUTTONS
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    wGet = new Button(shell, SWT.PUSH);
    wGet.setText(BaseMessages.getString(PKG, "StringOperationsDialog.GetFields.Button"));
    fdGet = new FormData();
    fdGet.right = new FormAttachment(100, 0);
    fdGet.top = new FormAttachment(wStepname, 3 * middle);
    wGet.setLayoutData(fdGet);
    setButtonPositions(new Button[] { wOK, wGet, wCancel }, margin, null);
    // Add listeners
    lsOK = new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    };
    lsGet = new Listener() {

        public void handleEvent(Event e) {
            get();
        }
    };
    lsCancel = new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    };
    wOK.addListener(SWT.Selection, lsOK);
    wGet.addListener(SWT.Selection, lsGet);
    wCancel.addListener(SWT.Selection, lsCancel);
    lsDef = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wStepname.addSelectionListener(lsDef);
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    // Set the shell size, based upon previous time...
    setSize();
    getData();
    // 
    // Search the fields in the background
    // 
    final Runnable runnable = new Runnable() {

        public void run() {
            StepMeta stepMeta = transMeta.findStep(stepname);
            if (stepMeta != null) {
                try {
                    RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
                    if (row != null) {
                        // Remember these fields...
                        for (int i = 0; i < row.size(); i++) {
                            inputFields.put(row.getValueMeta(i).getName(), new Integer(i));
                        }
                        setComboBoxes();
                    }
                    // Dislay in red missing field names
                    Display.getDefault().asyncExec(new Runnable() {

                        public void run() {
                            if (!wFields.isDisposed()) {
                                for (int i = 0; i < wFields.table.getItemCount(); i++) {
                                    TableItem it = wFields.table.getItem(i);
                                    if (!Utils.isEmpty(it.getText(1))) {
                                        if (!inputFields.containsKey(it.getText(1))) {
                                            it.setBackground(GUIResource.getInstance().getColorRed());
                                        }
                                    }
                                }
                            }
                        }
                    });
                } catch (KettleException e) {
                    logError("Error getting fields from incoming stream!", e);
                }
            }
        }
    };
    new Thread(runnable).start();
    input.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) ShellEvent(org.eclipse.swt.events.ShellEvent) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Display(org.eclipse.swt.widgets.Display)

Example 67 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class SecretKeyGeneratorDialog method preview.

// Preview the data
private void preview() {
    try {
        // Create the SecretKeyGeneratorMeta input step
        SecretKeyGeneratorMeta oneMeta = new SecretKeyGeneratorMeta();
        getInfo(oneMeta);
        TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "SecretKeyGeneratorDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "SecretKeyGeneratorDialog.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, "SecretKeyGeneratorDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "SecretKeyGeneratorDialog.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) SecretKeyGeneratorMeta(org.pentaho.di.trans.steps.symmetriccrypto.secretkeygenerator.SecretKeyGeneratorMeta) 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 68 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class SymmetricCryptoTransDialog method setSecretKeyFieldname.

private void setSecretKeyFieldname() {
    try {
        String field = wSecretKeyField.getText();
        wSecretKeyField.removeAll();
        RowMetaInterface r = transMeta.getPrevStepFields(stepname);
        if (r != null) {
            wSecretKeyField.setItems(r.getFieldNames());
        }
        if (field != null) {
            wSecretKeyField.setText(field);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SymmetricCryptoTransDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "SymmetricCryptoTransDialogMod.FailedToGetFields.DialogMessage"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Example 69 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class SymmetricCryptoTransDialog method setFieldname.

private void setFieldname() {
    try {
        String field = wMessage.getText();
        wMessage.removeAll();
        RowMetaInterface r = transMeta.getPrevStepFields(stepname);
        wMessage.setItems(r.getFieldNames());
        if (field != null) {
            wMessage.setText(field);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SymmetricCryptoTransDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "SymmetricCryptoTransDialogMod.FailedToGetFields.DialogMessage"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Example 70 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class SynchronizeAfterMergeDialog method get.

private void get() {
    try {
        RowMetaInterface r = transMeta.getPrevStepFields(stepname);
        if (r != null) {
            TableItemInsertListener listener = new TableItemInsertListener() {

                public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
                    tableItem.setText(2, "=");
                    return true;
                }
            };
            BaseStepDialog.getFieldsFromPrevious(r, wKey, 1, new int[] { 1, 3 }, new int[] {}, -1, -1, listener);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SynchronizeAfterMergeDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "SynchronizeAfterMergeDialog.FailedToGetFields.DialogMessage"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)1977 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)449 KettleStepException (org.pentaho.di.core.exception.KettleStepException)438 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)317 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)316 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)233 IOException (java.io.IOException)208 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)195 FileObject (org.apache.commons.vfs2.FileObject)150 StepMeta (org.pentaho.di.trans.step.StepMeta)150 ArrayList (java.util.ArrayList)149 KettleFileException (org.pentaho.di.core.exception.KettleFileException)124 TransMeta (org.pentaho.di.trans.TransMeta)119 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)113 Test (org.junit.Test)111 KettleValueException (org.pentaho.di.core.exception.KettleValueException)100 Database (org.pentaho.di.core.database.Database)97 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)95 ObjectId (org.pentaho.di.repository.ObjectId)91 Shell (org.eclipse.swt.widgets.Shell)90