Search in sources :

Example 51 with ColumnInfo

use of org.pentaho.di.ui.core.widget.ColumnInfo in project pentaho-kettle by pentaho.

the class IfNullDialog method open.

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

        public void modifyText(ModifyEvent e) {
            input.setChanged();
        }
    };
    changed = input.hasChanged();
    oldlsMod = lsMod;
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    middle = props.getMiddlePct();
    margin = Const.MARGIN;
    fieldsRows = input.getFields().length;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "IfNullDialog.Shell.Title"));
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "IfNullDialog.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);
    // ///////////////////////////////
    // START OF All Fields GROUP //
    // ///////////////////////////////
    wAllFields = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(wAllFields);
    wAllFields.setText(BaseMessages.getString(PKG, "IfNullDialog.AllFields.Label"));
    FormLayout AllFieldsgroupLayout = new FormLayout();
    AllFieldsgroupLayout.marginWidth = 10;
    AllFieldsgroupLayout.marginHeight = 10;
    wAllFields.setLayout(AllFieldsgroupLayout);
    // Replace by Value
    wlReplaceByValue = new Label(wAllFields, SWT.RIGHT);
    wlReplaceByValue.setText(BaseMessages.getString(PKG, "IfNullDialog.ReplaceByValue.Label"));
    props.setLook(wlReplaceByValue);
    fdlReplaceByValue = new FormData();
    fdlReplaceByValue.left = new FormAttachment(0, 0);
    fdlReplaceByValue.right = new FormAttachment(middle, -margin);
    fdlReplaceByValue.top = new FormAttachment(wStepname, margin * 2);
    wlReplaceByValue.setLayoutData(fdlReplaceByValue);
    wReplaceByValue = new TextVar(transMeta, wAllFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wReplaceByValue.setToolTipText(BaseMessages.getString(PKG, "IfNullDialog.ReplaceByValue.Tooltip"));
    props.setLook(wReplaceByValue);
    fdReplaceByValue = new FormData();
    fdReplaceByValue.left = new FormAttachment(middle, 0);
    fdReplaceByValue.top = new FormAttachment(wStepname, 2 * margin);
    fdReplaceByValue.right = new FormAttachment(100, 0);
    wReplaceByValue.setLayoutData(fdReplaceByValue);
    // SetEmptyStringAll line
    wlSetEmptyStringAll = new Label(wAllFields, SWT.RIGHT);
    wlSetEmptyStringAll.setText(BaseMessages.getString(PKG, "IfNullDialog.SetEmptyStringAll.Label"));
    props.setLook(wlSetEmptyStringAll);
    fdlSetEmptyStringAll = new FormData();
    fdlSetEmptyStringAll.left = new FormAttachment(0, 0);
    fdlSetEmptyStringAll.top = new FormAttachment(wReplaceByValue, margin);
    fdlSetEmptyStringAll.right = new FormAttachment(middle, -margin);
    wlSetEmptyStringAll.setLayoutData(fdlSetEmptyStringAll);
    wSetEmptyStringAll = new Button(wAllFields, SWT.CHECK);
    wSetEmptyStringAll.setToolTipText(BaseMessages.getString(PKG, "IfNullDialog.SetEmptyStringAll.Tooltip"));
    props.setLook(wSetEmptyStringAll);
    fdSetEmptyStringAll = new FormData();
    fdSetEmptyStringAll.left = new FormAttachment(middle, 0);
    fdSetEmptyStringAll.top = new FormAttachment(wReplaceByValue, margin);
    fdSetEmptyStringAll.right = new FormAttachment(100, 0);
    wSetEmptyStringAll.setLayoutData(fdSetEmptyStringAll);
    wSetEmptyStringAll.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            enableSetEmptyStringAll();
        }
    });
    wlMask = new Label(wAllFields, SWT.RIGHT);
    wlMask.setText(BaseMessages.getString(PKG, "IfNullDialog.Mask.Label"));
    props.setLook(wlMask);
    fdlMask = new FormData();
    fdlMask.left = new FormAttachment(0, 0);
    fdlMask.top = new FormAttachment(wSetEmptyStringAll, margin);
    fdlMask.right = new FormAttachment(middle, -margin);
    wlMask.setLayoutData(fdlMask);
    wMask = new CCombo(wAllFields, SWT.BORDER | SWT.READ_ONLY);
    wMask.setEditable(true);
    wMask.setItems(Const.getDateFormats());
    props.setLook(wMask);
    wMask.addModifyListener(lsMod);
    fdMask = new FormData();
    fdMask.left = new FormAttachment(middle, 0);
    fdMask.top = new FormAttachment(wSetEmptyStringAll, margin);
    fdMask.right = new FormAttachment(100, 0);
    wMask.setLayoutData(fdMask);
    fdAllFields = new FormData();
    fdAllFields.left = new FormAttachment(0, margin);
    fdAllFields.top = new FormAttachment(wStepname, margin);
    fdAllFields.right = new FormAttachment(100, -margin);
    wAllFields.setLayoutData(fdAllFields);
    // ///////////////////////////////////////////////////////////
    // / END OF All Fields GROUP
    // ///////////////////////////////////////////////////////////
    // Select fields?
    wlSelectFields = new Label(shell, SWT.RIGHT);
    wlSelectFields.setText(BaseMessages.getString(PKG, "IfNullDialog.SelectFields.Label"));
    props.setLook(wlSelectFields);
    fdlSelectFields = new FormData();
    fdlSelectFields.left = new FormAttachment(0, 0);
    fdlSelectFields.top = new FormAttachment(wAllFields, margin);
    fdlSelectFields.right = new FormAttachment(middle, -margin);
    wlSelectFields.setLayoutData(fdlSelectFields);
    wSelectFields = new Button(shell, SWT.CHECK);
    wSelectFields.setToolTipText(BaseMessages.getString(PKG, "IfNullDialog.SelectFields.Tooltip"));
    props.setLook(wSelectFields);
    fdSelectFields = new FormData();
    fdSelectFields.left = new FormAttachment(middle, 0);
    fdSelectFields.top = new FormAttachment(wAllFields, margin);
    fdSelectFields.right = new FormAttachment(100, 0);
    wSelectFields.setLayoutData(fdSelectFields);
    // Select type?
    wlSelectValuesType = new Label(shell, SWT.RIGHT);
    wlSelectValuesType.setText(BaseMessages.getString(PKG, "IfNullDialog.SelectValuesType.Label"));
    props.setLook(wlSelectValuesType);
    fdlSelectValuesType = new FormData();
    fdlSelectValuesType.left = new FormAttachment(0, 0);
    fdlSelectValuesType.top = new FormAttachment(wSelectFields, margin);
    fdlSelectValuesType.right = new FormAttachment(middle, -margin);
    wlSelectValuesType.setLayoutData(fdlSelectValuesType);
    wSelectValuesType = new Button(shell, SWT.CHECK);
    wSelectValuesType.setToolTipText(BaseMessages.getString(PKG, "IfNullDialog.SelectValuesType.Tooltip"));
    props.setLook(wSelectValuesType);
    fdSelectValuesType = new FormData();
    fdSelectValuesType.left = new FormAttachment(middle, 0);
    fdSelectValuesType.top = new FormAttachment(wSelectFields, margin);
    fdSelectValuesType.right = new FormAttachment(100, 0);
    wSelectValuesType.setLayoutData(fdSelectValuesType);
    wlValueTypes = new Label(shell, SWT.NONE);
    wlValueTypes.setText(BaseMessages.getString(PKG, "IfNullDialog.ValueTypes.Label"));
    props.setLook(wlValueTypes);
    fdlValueTypes = new FormData();
    fdlValueTypes.left = new FormAttachment(0, 0);
    fdlValueTypes.top = new FormAttachment(wSelectValuesType, margin);
    wlValueTypes.setLayoutData(fdlValueTypes);
    int valueTypesRows = input.getValueTypes().length;
    int FieldsCols = 4;
    ColumnInfo[] colval = new ColumnInfo[FieldsCols];
    colval[0] = new ColumnInfo(BaseMessages.getString(PKG, "IfNullDialog.ValueType.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaInterface.typeCodes);
    colval[1] = new ColumnInfo(BaseMessages.getString(PKG, "IfNullDialog.Value.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false);
    colval[2] = new ColumnInfo(BaseMessages.getString(PKG, "IfNullDialog.Value.ConversionMask"), ColumnInfo.COLUMN_TYPE_CCOMBO, Const.getDateFormats());
    colval[3] = new ColumnInfo(BaseMessages.getString(PKG, "IfNullDialog.Value.SetEmptyString"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { BaseMessages.getString(PKG, "System.Combo.Yes"), BaseMessages.getString(PKG, "System.Combo.No") });
    colval[1].setUsingVariables(true);
    wValueTypes = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colval, valueTypesRows, oldlsMod, props);
    fdValueTypes = new FormData();
    fdValueTypes.left = new FormAttachment(0, 0);
    fdValueTypes.top = new FormAttachment(wlValueTypes, margin);
    fdValueTypes.right = new FormAttachment(100, 0);
    fdValueTypes.bottom = new FormAttachment(wlValueTypes, 190);
    wValueTypes.setLayoutData(fdValueTypes);
    getFirstData();
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wGet = new Button(shell, SWT.PUSH);
    wGet.setText(BaseMessages.getString(PKG, "System.Button.GetFields"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    setButtonPositions(new Button[] { wOK, wGet, wCancel }, margin, null);
    addFields();
    wSelectValuesType.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            activeSelectValuesType();
            input.setChanged();
        }
    });
    wSelectFields.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            activeSelectFields();
            input.setChanged();
        }
    });
    // Add listeners
    lsCancel = new Listener() {

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

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

        public void handleEvent(Event e) {
            ok();
        }
    };
    wCancel.addListener(SWT.Selection, lsCancel);
    wOK.addListener(SWT.Selection, lsOK);
    wGet.addListener(SWT.Selection, lsGet);
    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();
    enableSetEmptyStringAll();
    // setComboValues();
    activeSelectFields();
    activeSelectValuesType();
    input.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) ShellAdapter(org.eclipse.swt.events.ShellAdapter) 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) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) ShellEvent(org.eclipse.swt.events.ShellEvent) Text(org.eclipse.swt.widgets.Text) TextVar(org.pentaho.di.ui.core.widget.TextVar) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 52 with ColumnInfo

use of org.pentaho.di.ui.core.widget.ColumnInfo in project pentaho-kettle by pentaho.

the class InsertUpdateDialog method setTableFieldCombo.

private void setTableFieldCombo() {
    Runnable fieldLoader = new Runnable() {

        public void run() {
            if (!wTable.isDisposed() && !wConnection.isDisposed() && !wSchema.isDisposed()) {
                final String tableName = wTable.getText(), connectionName = wConnection.getText(), schemaName = wSchema.getText();
                // clear
                for (ColumnInfo colInfo : tableFieldColumns) {
                    colInfo.setComboValues(new String[] {});
                }
                if (!Utils.isEmpty(tableName)) {
                    DatabaseMeta ci = transMeta.findDatabase(connectionName);
                    if (ci != null) {
                        Database db = new Database(loggingObject, ci);
                        try {
                            db.connect();
                            String schemaTable = ci.getQuotedSchemaTableCombination(transMeta.environmentSubstitute(schemaName), transMeta.environmentSubstitute(tableName));
                            RowMetaInterface r = db.getTableFields(schemaTable);
                            if (null != r) {
                                String[] fieldNames = r.getFieldNames();
                                if (null != fieldNames) {
                                    for (ColumnInfo colInfo : tableFieldColumns) {
                                        colInfo.setComboValues(fieldNames);
                                    }
                                }
                            }
                        } catch (Exception e) {
                            for (ColumnInfo colInfo : tableFieldColumns) {
                                colInfo.setComboValues(new String[] {});
                            }
                        // ignore any errors here. drop downs will not be
                        // filled, but no problem for the user
                        } finally {
                            try {
                                if (db != null) {
                                    db.disconnect();
                                }
                            } catch (Exception ignored) {
                                // ignore any errors here.
                                db = null;
                            }
                        }
                    }
                }
            }
        }
    };
    shell.getDisplay().asyncExec(fieldLoader);
}
Also used : Database(org.pentaho.di.core.database.Database) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) KettleException(org.pentaho.di.core.exception.KettleException)

Example 53 with ColumnInfo

use of org.pentaho.di.ui.core.widget.ColumnInfo in project pentaho-kettle by pentaho.

the class IngresVectorwiseLoaderDialog method addFieldSelection.

private Control addFieldSelection(Control lastControl) {
    // The fields table
    Label wlFields = new Label(shell, SWT.NONE);
    wlFields.setText(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.InsertFields.Label"));
    props.setLook(wlFields);
    FormData fdlUpIns = new FormData();
    fdlUpIns.left = new FormAttachment(0, 0);
    fdlUpIns.top = new FormAttachment(lastControl, 2 * margin);
    wlFields.setLayoutData(fdlUpIns);
    int tableCols = 2;
    int UpInsRows = (input.getFieldStream() != null ? input.getFieldStream().length : 1);
    ColumnInfo[] ciFields = new ColumnInfo[tableCols];
    ciFields[0] = new ColumnInfo(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.ColumnInfo.TableField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
    ciFields[1] = new ColumnInfo(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.ColumnInfo.StreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
    tableFieldColumns.add(ciFields[0]);
    wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciFields, UpInsRows, lsMod, props);
    Button wGetFields = new Button(shell, SWT.PUSH);
    wGetFields.setText(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.GetFields.Button"));
    FormData fdGetFields = new FormData();
    fdGetFields.top = new FormAttachment(wlFields, margin);
    fdGetFields.right = new FormAttachment(100, 0);
    wGetFields.setLayoutData(fdGetFields);
    Button wDoMapping = new Button(shell, SWT.PUSH);
    wDoMapping.setText(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.DoMapping.Button"));
    FormData fdDoMapping = new FormData();
    fdDoMapping.top = new FormAttachment(wGetFields, margin);
    fdDoMapping.right = new FormAttachment(100, 0);
    wDoMapping.setLayoutData(fdDoMapping);
    wGetFields.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            get();
        }
    });
    wDoMapping.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event arg0) {
            generateMappings();
        }
    });
    FormData fdFields = new FormData();
    fdFields.left = new FormAttachment(0, 0);
    fdFields.top = new FormAttachment(wlFields, margin);
    fdFields.right = new FormAttachment(wDoMapping, -margin);
    fdFields.bottom = new FormAttachment(wOK, -2 * margin);
    wFields.setLayoutData(fdFields);
    return wFields;
}
Also used : FormData(org.eclipse.swt.layout.FormData) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) Button(org.eclipse.swt.widgets.Button) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 54 with ColumnInfo

use of org.pentaho.di.ui.core.widget.ColumnInfo in project pentaho-kettle by pentaho.

the class JaninoDialog method open.

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

        public void modifyText(ModifyEvent e) {
            currentMeta.setChanged();
        }
    };
    changed = currentMeta.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "JaninoDialog.DialogTitle"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "System.Label.StepName"));
    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);
    wlFields = new Label(shell, SWT.NONE);
    wlFields.setText(BaseMessages.getString(PKG, "JaninoDialog.Fields.Label"));
    props.setLook(wlFields);
    fdlFields = new FormData();
    fdlFields.left = new FormAttachment(0, 0);
    fdlFields.top = new FormAttachment(wStepname, margin);
    wlFields.setLayoutData(fdlFields);
    final int FieldsRows = currentMeta.getFormula() != null ? currentMeta.getFormula().length : 1;
    colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "JaninoDialog.NewField.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "JaninoDialog.Janino.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "JaninoDialog.ValueType.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames()), new ColumnInfo(BaseMessages.getString(PKG, "JaninoDialog.Length.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "JaninoDialog.Precision.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "JaninoDialog.Replace.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] {}) };
    wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
    fdFields = new FormData();
    fdFields.left = new FormAttachment(0, 0);
    fdFields.top = new FormAttachment(wlFields, margin);
    fdFields.right = new FormAttachment(100, 0);
    fdFields.bottom = new FormAttachment(100, -50);
    wFields.setLayoutData(fdFields);
    // 
    // 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);
                    // Remember these fields...
                    for (int i = 0; i < row.size(); i++) {
                        inputFields.put(row.getValueMeta(i).getName(), new Integer(i));
                    }
                    setComboBoxes();
                } catch (KettleException e) {
                    logError(BaseMessages.getString(PKG, "JaninoDialog.Log.UnableToFindInput"));
                }
            }
        }
    };
    new Thread(runnable).start();
    wFields.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent arg0) {
            // Now set the combo's
            shell.getDisplay().asyncExec(new Runnable() {

                public void run() {
                    setComboBoxes();
                }
            });
        }
    });
    // Some 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"));
    setButtonPositions(new Button[] { wOK, wCancel }, margin, null);
    // Add listeners
    lsCancel = new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    };
    lsOK = new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    };
    wCancel.addListener(SWT.Selection, lsCancel);
    wOK.addListener(SWT.Selection, lsOK);
    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();
    currentMeta.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) 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 55 with ColumnInfo

use of org.pentaho.di.ui.core.widget.ColumnInfo in project pentaho-kettle by pentaho.

the class JobExecutorDialog method addExecutionResultTab.

private void addExecutionResultTab() {
    final CTabItem wTab = new CTabItem(wTabFolder, SWT.NONE);
    wTab.setText(BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionResults.Title"));
    wTab.setToolTipText(BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionResults.Tooltip"));
    ScrolledComposite scrolledComposite = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL);
    scrolledComposite.setLayout(new FillLayout());
    Composite wInputComposite = new Composite(scrolledComposite, SWT.NONE);
    props.setLook(wInputComposite);
    FormLayout tabLayout = new FormLayout();
    tabLayout.marginWidth = 15;
    tabLayout.marginHeight = 15;
    wInputComposite.setLayout(tabLayout);
    wlExecutionResultTarget = new Label(wInputComposite, SWT.RIGHT);
    props.setLook(wlExecutionResultTarget);
    wlExecutionResultTarget.setText(BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionResultTarget.Label"));
    FormData fdlExecutionResultTarget = new FormData();
    fdlExecutionResultTarget.top = new FormAttachment(0, 0);
    // First one in the left
    fdlExecutionResultTarget.left = new FormAttachment(0, 0);
    wlExecutionResultTarget.setLayoutData(fdlExecutionResultTarget);
    wExecutionResultTarget = new CCombo(wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wExecutionResultTarget);
    wExecutionResultTarget.addModifyListener(lsMod);
    FormData fdExecutionResultTarget = new FormData();
    fdExecutionResultTarget.width = 250;
    fdExecutionResultTarget.top = new FormAttachment(wlExecutionResultTarget, 5);
    // To the right
    fdExecutionResultTarget.left = new FormAttachment(0, 0);
    wExecutionResultTarget.setLayoutData(fdExecutionResultTarget);
    ColumnInfo[] executionResultColumns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "JobExecutorMeta.ExecutionResults.FieldDescription.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "JobExecutorMeta.ExecutionResults.FieldName.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false, false) };
    executionResultColumns[1].setUsingVariables(true);
    TableView wExectionResults = new TableView(transMeta, wInputComposite, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER, executionResultColumns, 14, false, lsMod, props, false);
    props.setLook(wExectionResults);
    FormData fdExecutionResults = new FormData();
    fdExecutionResults.left = new FormAttachment(0);
    fdExecutionResults.right = new FormAttachment(100);
    fdExecutionResults.top = new FormAttachment(wExecutionResultTarget, 10);
    fdExecutionResults.bottom = new FormAttachment(100);
    wExectionResults.setLayoutData(fdExecutionResults);
    wExectionResults.getTable().addListener(SWT.Resize, new ColumnsResizer(0, 50, 50));
    int index = 0;
    tiExecutionTimeField = wExectionResults.table.getItem(index++);
    tiExecutionResultField = wExectionResults.table.getItem(index++);
    tiExecutionNrErrorsField = wExectionResults.table.getItem(index++);
    tiExecutionLinesReadField = wExectionResults.table.getItem(index++);
    tiExecutionLinesWrittenField = wExectionResults.table.getItem(index++);
    tiExecutionLinesInputField = wExectionResults.table.getItem(index++);
    tiExecutionLinesOutputField = wExectionResults.table.getItem(index++);
    tiExecutionLinesRejectedField = wExectionResults.table.getItem(index++);
    tiExecutionLinesUpdatedField = wExectionResults.table.getItem(index++);
    tiExecutionLinesDeletedField = wExectionResults.table.getItem(index++);
    tiExecutionFilesRetrievedField = wExectionResults.table.getItem(index++);
    tiExecutionExitStatusField = wExectionResults.table.getItem(index++);
    tiExecutionLogTextField = wExectionResults.table.getItem(index++);
    tiExecutionLogChannelIdField = wExectionResults.table.getItem(index++);
    tiExecutionTimeField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionTimeField.Label"));
    tiExecutionResultField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionResultField.Label"));
    tiExecutionNrErrorsField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionNrErrorsField.Label"));
    tiExecutionLinesReadField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionLinesReadField.Label"));
    tiExecutionLinesWrittenField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionLinesWrittenField.Label"));
    tiExecutionLinesInputField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionLinesInputField.Label"));
    tiExecutionLinesOutputField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionLinesOutputField.Label"));
    tiExecutionLinesRejectedField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionLinesRejectedField.Label"));
    tiExecutionLinesUpdatedField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionLinesUpdatedField.Label"));
    tiExecutionLinesDeletedField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionLinesDeletedField.Label"));
    tiExecutionFilesRetrievedField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionFilesRetrievedField.Label"));
    tiExecutionExitStatusField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionExitStatusField.Label"));
    tiExecutionLogTextField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionLogTextField.Label"));
    tiExecutionLogChannelIdField.setText(FIELD_DESCRIPTION, BaseMessages.getString(PKG, "JobExecutorDialog.ExecutionLogChannelIdField.Label"));
    wJobExecutorParameters.setRowNums();
    wJobExecutorParameters.optWidth(true);
    wInputComposite.pack();
    Rectangle bounds = wInputComposite.getBounds();
    scrolledComposite.setContent(wInputComposite);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setMinWidth(bounds.width);
    scrolledComposite.setMinHeight(bounds.height);
    wTab.setControl(scrolledComposite);
    wTabFolder.setSelection(wTab);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ColumnsResizer(org.pentaho.di.ui.core.widget.ColumnsResizer) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) FillLayout(org.eclipse.swt.layout.FillLayout) CTabItem(org.eclipse.swt.custom.CTabItem) CCombo(org.eclipse.swt.custom.CCombo) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView)

Aggregations

ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)258 FormAttachment (org.eclipse.swt.layout.FormAttachment)220 FormData (org.eclipse.swt.layout.FormData)220 TableView (org.pentaho.di.ui.core.widget.TableView)216 FormLayout (org.eclipse.swt.layout.FormLayout)200 Label (org.eclipse.swt.widgets.Label)190 Button (org.eclipse.swt.widgets.Button)183 SelectionEvent (org.eclipse.swt.events.SelectionEvent)173 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)168 ShellEvent (org.eclipse.swt.events.ShellEvent)155 Event (org.eclipse.swt.widgets.Event)155 Listener (org.eclipse.swt.widgets.Listener)154 Shell (org.eclipse.swt.widgets.Shell)154 Display (org.eclipse.swt.widgets.Display)152 Text (org.eclipse.swt.widgets.Text)152 ModifyEvent (org.eclipse.swt.events.ModifyEvent)151 ModifyListener (org.eclipse.swt.events.ModifyListener)151 ShellAdapter (org.eclipse.swt.events.ShellAdapter)150 Composite (org.eclipse.swt.widgets.Composite)105 CTabItem (org.eclipse.swt.custom.CTabItem)100