Search in sources :

Example 1 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 2 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)

Example 3 with TableItemInsertListener

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

the class ConcatFieldsDialog method get.

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

                @Override
                public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
                    if (v.isNumber()) {
                        if (v.getLength() > 0) {
                            int le = v.getLength();
                            int pr = v.getPrecision();
                            if (v.getPrecision() <= 0) {
                                pr = 0;
                            }
                            String mask = "";
                            for (int m = 0; m < le - pr; m++) {
                                mask += "0";
                            }
                            if (pr > 0) {
                                mask += ".";
                            }
                            for (int m = 0; m < pr; m++) {
                                mask += "0";
                            }
                            tableItem.setText(3, mask);
                        }
                    }
                    return true;
                }
            };
            BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1 }, new int[] { 2 }, 4, 5, listener);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Title"), BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"), 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) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Point(org.eclipse.swt.graphics.Point) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 4 with TableItemInsertListener

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

the class PentahoReportingOutputDialog method get.

private void get() {
    Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
    // See if we need to boot the reporting engine. Since this takes time we do it in the background...
    // 
    Runnable runnable = new Runnable() {

        @Override
        public void run() {
            PentahoReportingOutput.performPentahoReportingBoot(log, input.getClass());
        }
    };
    Thread thread = new Thread(runnable);
    thread.start();
    try {
        // Browse for a PRPT...
        // 
        FileDialog dialog = new FileDialog(shell, SWT.OPEN);
        dialog.setText(BaseMessages.getString(PKG, "PentahoReportingOutputDialog.ExtractParameters.FileDialog"));
        dialog.setFilterExtensions(new String[] { "*.prpt;*.PRPT", "*" });
        if (lastFilename != null) {
            dialog.setFileName(lastFilename);
        }
        dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "PentahoReportingOutputDialog.PentahoReportingFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
        if (dialog.open() == null) {
            return;
        }
        thread.join();
        String sourceFilename = dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName();
        lastFilename = sourceFilename;
        shell.setCursor(busy);
        // Load the master report...
        // 
        MasterReport report = PentahoReportingOutput.loadMasterReport(sourceFilename);
        // Extract the definitions...
        // 
        ReportParameterDefinition definition = report.getParameterDefinition();
        RowMetaInterface r = new RowMeta();
        for (int i = 0; i < definition.getParameterCount(); i++) {
            ParameterDefinitionEntry entry = definition.getParameterDefinition(i);
            ValueMetaInterface valueMeta = new ValueMetaString(entry.getName());
            valueMeta.setComments(getParameterDefinitionEntryTypeDescription(entry));
            r.addValueMeta(valueMeta);
        }
        shell.setCursor(null);
        BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, new TableItemInsertListener() {

            @Override
            public boolean tableItemInserted(TableItem item, ValueMetaInterface valueMeta) {
                item.setText(2, valueMeta.getComments());
                return true;
            }
        });
    } catch (Exception e) {
        shell.setCursor(null);
        new ErrorDialog(shell, BaseMessages.getString(PKG, "PentahoReportingOutputDialog.ErrorReadingParameters.Title"), BaseMessages.getString(PKG, "PentahoReportingOutputDialog.ErrorReadingParameters.Message"), e);
    } finally {
        shell.setCursor(null);
        busy.dispose();
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) RowMeta(org.pentaho.di.core.row.RowMeta) TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Cursor(org.eclipse.swt.graphics.Cursor) KettleException(org.pentaho.di.core.exception.KettleException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) MasterReport(org.pentaho.reporting.engine.classic.core.MasterReport) ReportParameterDefinition(org.pentaho.reporting.engine.classic.core.parameters.ReportParameterDefinition) ParameterDefinitionEntry(org.pentaho.reporting.engine.classic.core.parameters.ParameterDefinitionEntry) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 5 with TableItemInsertListener

use of org.pentaho.di.ui.trans.step.TableItemInsertListener 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

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