Search in sources :

Example 91 with KettleException

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

the class ProcessFilesDialog method get.

private void get() {
    if (!gotPreviousFields) {
        gotPreviousFields = true;
        try {
            String source = wSourceFileNameField.getText();
            String target = wTargetFileNameField.getText();
            wSourceFileNameField.removeAll();
            wTargetFileNameField.removeAll();
            RowMetaInterface r = transMeta.getPrevStepFields(stepname);
            if (r != null) {
                wSourceFileNameField.setItems(r.getFieldNames());
                wTargetFileNameField.setItems(r.getFieldNames());
                if (source != null) {
                    wSourceFileNameField.setText(source);
                }
                if (target != null) {
                    wTargetFileNameField.setText(target);
                }
            }
        } catch (KettleException ke) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "ProcessFilesDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "ProcessFilesDialog.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 92 with KettleException

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

the class PropertyInputDialog method setFileField.

private void setFileField() {
    try {
        String value = wFilenameField.getText();
        wFilenameField.removeAll();
        RowMetaInterface r = transMeta.getPrevStepFields(stepname);
        if (r != null) {
            r.getFieldNames();
            for (int i = 0; i < r.getFieldNames().length; i++) {
                wFilenameField.add(r.getFieldNames()[i]);
            }
        }
        if (value != null) {
            wFilenameField.setText(value);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "PropertyInputDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "PropertyInputDialog.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) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 93 with KettleException

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

the class PropertyInputDialog method getSections.

private void getSections() {
    Wini wini = new Wini();
    PropertyInputMeta meta = new PropertyInputMeta();
    try {
        getInfo(meta);
        FileInputList fileInputList = meta.getFiles(transMeta);
        if (fileInputList.nrOfFiles() > 0) {
            // Check the first file
            if (fileInputList.getFile(0).exists()) {
                // Open the file (only first file) in readOnly ...
                // 
                wini = new Wini(KettleVFS.getInputStream(fileInputList.getFile(0)));
                Iterator<String> itSection = wini.keySet().iterator();
                String[] sectionsList = new String[wini.keySet().size()];
                int i = 0;
                while (itSection.hasNext()) {
                    sectionsList[i] = itSection.next().toString();
                    i++;
                }
                Const.sortStrings(sectionsList);
                EnterSelectionDialog dialog = new EnterSelectionDialog(shell, sectionsList, BaseMessages.getString(PKG, "PropertyInputDialog.Dialog.SelectASection.Title"), BaseMessages.getString(PKG, "PropertyInputDialog.Dialog.SelectASection.Message"));
                String sectionname = dialog.open();
                if (sectionname != null) {
                    wSection.setText(sectionname);
                }
            } else {
                // The file not exists !
                throw new KettleException(BaseMessages.getString(PKG, "PropertyInputDialog.Exception.FileDoesNotExist", KettleVFS.getFilename(fileInputList.getFile(0))));
            }
        } else {
            // No file specified
            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
            mb.setMessage(BaseMessages.getString(PKG, "PropertyInputDialog.FilesMissing.DialogMessage"));
            mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
            mb.open();
        }
    } catch (Throwable e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "PropertyInputDialog.UnableToGetListOfSections.Title"), BaseMessages.getString(PKG, "PropertyInputDialog.UnableToGetListOfSections.Message"), e);
    } finally {
        if (wini != null) {
            wini.clear();
        }
        wini = null;
        meta = null;
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) Wini(org.ini4j.Wini) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) PropertyInputMeta(org.pentaho.di.trans.steps.propertyinput.PropertyInputMeta) FileInputList(org.pentaho.di.core.fileinput.FileInputList) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 94 with KettleException

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

the class RegexEvalDialog method getPreviousFields.

private void getPreviousFields() {
    // Save user-selected value, if applicable
    String selectedValue = wfieldevaluate.getText();
    // Clear the existing list, and reload
    wfieldevaluate.removeAll();
    try {
        RowMetaInterface r = transMeta.getPrevStepFields(stepname);
        if (r != null) {
            for (String item : r.getFieldNames()) {
                wfieldevaluate.add(item);
            }
        }
        // Re-select the user-selected value, if applicable
        if (!Utils.isEmpty(selectedValue)) {
            wfieldevaluate.select(wfieldevaluate.indexOf(selectedValue));
        } else {
            wfieldevaluate.select(0);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RegexEvalDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "RegexEvalDialog.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) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 95 with KettleException

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

the class ReplaceStringDialog 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) {
                    if (v.getType() == ValueMetaInterface.TYPE_STRING) {
                        // Only process strings
                        tableItem.setText(3, BaseMessages.getString(PKG, "System.Combo.No"));
                        tableItem.setText(6, BaseMessages.getString(PKG, "System.Combo.No"));
                        tableItem.setText(8, BaseMessages.getString(PKG, "System.Combo.No"));
                        tableItem.setText(9, BaseMessages.getString(PKG, "System.Combo.No"));
                        tableItem.setText(10, BaseMessages.getString(PKG, "System.Combo.No"));
                        return true;
                    } else {
                        return false;
                    }
                }
            };
            BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, listener);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "ReplaceStringDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "ReplaceStringDialog.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