Search in sources :

Example 26 with TableItemInsertListener

use of org.pentaho.di.ui.trans.step.TableItemInsertListener in project pentaho-kettle by pentaho.

the class SalesforceUpsertDialog method getUpdate.

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

                public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
                    tableItem.setText(3, "Y");
                    return true;
                }
            };
            BaseStepDialog.getFieldsFromPrevious(r, wReturn, 1, new int[] { 1, 2 }, new int[] {}, -1, -1, listener);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SalesforceUpsertDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "SalesforceUpsertDialog.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)

Example 27 with TableItemInsertListener

use of org.pentaho.di.ui.trans.step.TableItemInsertListener in project pentaho-kettle by pentaho.

the class SapInputDialog method get.

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

                public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
                    tableItem.setText(2, "=");
                    return true;
                }
            };
            BaseStepDialog.getFieldsFromPrevious(r, wInput, 1, new int[] { 1, 3 }, new int[] {}, -1, -1, listener);
        }
        DatabaseMeta databaseMeta = transMeta.findDatabase(wConnection.getText());
        if (databaseMeta == null) {
            showDatabaseWarning(false);
            return;
        }
        // 
        if (function != null) {
            wFunction.setText(function.getName());
            if (wInput.nrNonEmpty() != 0 || wOutput.nrNonEmpty() != 0) {
                MessageBox mb = new MessageBox(shell, SWT.YES | SWT.NO | SWT.ICON_QUESTION);
                mb.setMessage(BaseMessages.getString(PKG, "SapInputDialog.ClearInputOutput.DialogMessage"));
                mb.setText(BaseMessages.getString(PKG, "SapInputDialog.ClearInputOutput.DialogTitle"));
                int answer = mb.open();
                if (answer == SWT.NO) {
                    return;
                }
            }
            wInput.clearAll(false);
            wOutput.clearAll(false);
            Cursor hourGlass = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
            SAPConnection sc = SAPConnectionFactory.create();
            try {
                shell.setCursor(hourGlass);
                sc.open(databaseMeta);
                SAPFunctionSignature signature = sc.getFunctionSignature(function);
                // Populate the input view
                // TODO: clean this up a bit, feels a bit messy
                // 
                int rownr = 0;
                for (SAPField field : signature.getInput()) {
                    TableItem item;
                    if (rownr == 0) {
                        item = wInput.table.getItem(0);
                    } else {
                        item = new TableItem(wInput.table, SWT.NONE);
                    }
                    rownr++;
                    SapType type = getSapType(field);
                    int colnr = 1;
                    item.setText(colnr++, Const.NVL(field.getName(), ""));
                    item.setText(colnr++, type == null ? "" : type.getDescription());
                    item.setText(colnr++, Const.NVL(field.getTable(), ""));
                    item.setText(colnr++, Const.NVL(field.getName(), ""));
                    item.setText(colnr++, field.getTypePentaho());
                }
                wInput.setRowNums();
                wInput.optWidth(true);
                // Get the output rows
                // 
                rownr = 0;
                for (SAPField field : signature.getOutput()) {
                    TableItem item;
                    if (rownr == 0) {
                        item = wOutput.table.getItem(0);
                    } else {
                        item = new TableItem(wOutput.table, SWT.NONE);
                    }
                    rownr++;
                    SapType type = getSapType(field);
                    int colnr = 1;
                    item.setText(colnr++, Const.NVL(field.getName(), ""));
                    item.setText(colnr++, type == null ? "" : type.getDescription());
                    item.setText(colnr++, Const.NVL(field.getTable(), ""));
                    item.setText(colnr++, Const.NVL(field.getName(), ""));
                    item.setText(colnr++, field.getTypePentaho());
                }
                wOutput.setRowNums();
                wOutput.optWidth(true);
            } catch (Exception e) {
                throw new KettleException(e);
            } finally {
                sc.close();
                shell.setCursor(null);
                hourGlass.dispose();
            }
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SapInputDialog.GetFieldsFailed.DialogTitle"), BaseMessages.getString(PKG, "SapInputDialog.GetFieldsFailed.DialogMessage"), ke);
    }
}
Also used : SAPFunctionSignature(org.pentaho.di.trans.steps.sapinput.sap.SAPFunctionSignature) KettleException(org.pentaho.di.core.exception.KettleException) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) SAPConnection(org.pentaho.di.trans.steps.sapinput.sap.SAPConnection) TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Cursor(org.eclipse.swt.graphics.Cursor) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) SAPR3DatabaseMeta(org.pentaho.di.core.database.sap.SAPR3DatabaseMeta) KettleException(org.pentaho.di.core.exception.KettleException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) MessageBox(org.eclipse.swt.widgets.MessageBox) SAPField(org.pentaho.di.trans.steps.sapinput.sap.SAPField)

Example 28 with TableItemInsertListener

use of org.pentaho.di.ui.trans.step.TableItemInsertListener in project pentaho-kettle by pentaho.

the class GPLoadDialog method getUpdate.

private void getUpdate() {
    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_DATE) {
                        // The default is date mask.
                        tableItem.setText(3, BaseMessages.getString(PKG, "GPLoadDialog.DateMask.Label"));
                    } else {
                        tableItem.setText(3, "");
                    }
                    return true;
                }
            };
            BaseStepDialog.getFieldsFromPrevious(r, wReturn, 1, new int[] { 1, 2 }, new int[] {}, -1, -1, listener);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "GPLoadDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "GPLoadDialog.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)

Example 29 with TableItemInsertListener

use of org.pentaho.di.ui.trans.step.TableItemInsertListener in project pentaho-kettle by pentaho.

the class LucidDBBulkLoaderDialog method getUpdate.

private void getUpdate() {
    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_DATE) {
                        // The default is : format is OK for dates, see if this sticks later on...
                        // 
                        tableItem.setText(3, "Y");
                    } else {
                        // default is OK too...
                        tableItem.setText(3, "Y");
                    }
                    return true;
                }
            };
            BaseStepDialog.getFieldsFromPrevious(r, wReturn, 1, new int[] { 1, 2 }, new int[] {}, -1, -1, listener);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "LucidDBBulkLoaderDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "LucidDBBulkLoaderDialog.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)

Example 30 with TableItemInsertListener

use of org.pentaho.di.ui.trans.step.TableItemInsertListener in project pentaho-kettle by pentaho.

the class GetPreviousRowFieldDialog 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) {
                    return true;
                }
            };
            BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, listener);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "GetPreviousRowFieldDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "GetPreviousRowFieldDialog.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

TableItem (org.eclipse.swt.widgets.TableItem)43 KettleException (org.pentaho.di.core.exception.KettleException)43 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)43 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)43 TableItemInsertListener (org.pentaho.di.ui.trans.step.TableItemInsertListener)43 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)42 Point (org.eclipse.swt.graphics.Point)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)3 Cursor (org.eclipse.swt.graphics.Cursor)2 MessageBox (org.eclipse.swt.widgets.MessageBox)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 FileDialog (org.eclipse.swt.widgets.FileDialog)1 Table (org.eclipse.swt.widgets.Table)1 Database (org.pentaho.di.core.database.Database)1 SAPR3DatabaseMeta (org.pentaho.di.core.database.sap.SAPR3DatabaseMeta)1 RowMeta (org.pentaho.di.core.row.RowMeta)1 SAPConnection (org.pentaho.di.trans.steps.sapinput.sap.SAPConnection)1 SAPField (org.pentaho.di.trans.steps.sapinput.sap.SAPField)1 SAPFunctionSignature (org.pentaho.di.trans.steps.sapinput.sap.SAPFunctionSignature)1 MasterReport (org.pentaho.reporting.engine.classic.core.MasterReport)1