Search in sources :

Example 36 with ColumnInfo

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

the class ReplaceStringDialog 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, "ReplaceStringDialog.Shell.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "ReplaceStringDialog.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, "ReplaceStringDialog.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 = 10;
    int nrFieldRows = (input.getFieldInStream() != null ? input.getFieldInStream().length : 1);
    ciKey = new ColumnInfo[nrFieldCols];
    ciKey[0] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.InStreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
    ciKey[1] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.OutStreamField"), ColumnInfo.COLUMN_TYPE_TEXT, false);
    ciKey[2] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.useRegEx"), ColumnInfo.COLUMN_TYPE_CCOMBO, ReplaceStringMeta.useRegExDesc);
    ciKey[3] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.Replace"), ColumnInfo.COLUMN_TYPE_TEXT, false);
    ciKey[4] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.By"), ColumnInfo.COLUMN_TYPE_TEXT, false);
    ciKey[5] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.SetEmptyString"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { BaseMessages.getString(PKG, "System.Combo.Yes"), BaseMessages.getString(PKG, "System.Combo.No") });
    ciKey[6] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.FieldReplaceBy"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
    ciKey[7] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.WholeWord"), ColumnInfo.COLUMN_TYPE_CCOMBO, ReplaceStringMeta.wholeWordDesc);
    ciKey[8] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.CaseSensitive"), ColumnInfo.COLUMN_TYPE_CCOMBO, ReplaceStringMeta.caseSensitiveDesc);
    ciKey[9] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.IsUnicode"), ColumnInfo.COLUMN_TYPE_CCOMBO, ReplaceStringMeta.isUnicodeDesc);
    ciKey[1].setToolTip(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.OutStreamField.Tooltip"));
    ciKey[1].setUsingVariables(true);
    ciKey[3].setUsingVariables(true);
    ciKey[4].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);
    // 
    // 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, "ReplaceString.Error.CanNotGetFields"));
                }
            }
        }
    };
    new Thread(runnable).start();
    // 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, "ReplaceStringDialog.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();
    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) 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 37 with ColumnInfo

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

the class RestDialog 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, "RestDialog.Shell.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "RestDialog.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);
    wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, PropsUI.WIDGET_STYLE_TAB);
    // ////////////////////////
    // START OF GENERAL TAB ///
    // ////////////////////////
    wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
    wGeneralTab.setText(BaseMessages.getString(PKG, "RestDialog.GeneralTab.Title"));
    wGeneralComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wGeneralComp);
    FormLayout fileLayout = new FormLayout();
    fileLayout.marginWidth = 3;
    fileLayout.marginHeight = 3;
    wGeneralComp.setLayout(fileLayout);
    // ////////////////////////
    // START Settings GROUP
    Group gSettings = new Group(wGeneralComp, SWT.SHADOW_ETCHED_IN);
    gSettings.setText(BaseMessages.getString(PKG, "RestDialog.SettingsGroup.Label"));
    FormLayout SettingsLayout = new FormLayout();
    SettingsLayout.marginWidth = 3;
    SettingsLayout.marginHeight = 3;
    gSettings.setLayout(SettingsLayout);
    props.setLook(gSettings);
    wlUrl = new Label(gSettings, SWT.RIGHT);
    wlUrl.setText(BaseMessages.getString(PKG, "RestDialog.URL.Label"));
    props.setLook(wlUrl);
    fdlUrl = new FormData();
    fdlUrl.left = new FormAttachment(0, 0);
    fdlUrl.right = new FormAttachment(middle, -margin);
    fdlUrl.top = new FormAttachment(wGeneralComp, margin * 2);
    wlUrl.setLayoutData(fdlUrl);
    wUrl = new TextVar(transMeta, gSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wUrl);
    wUrl.addModifyListener(lsMod);
    fdUrl = new FormData();
    fdUrl.left = new FormAttachment(middle, 0);
    fdUrl.top = new FormAttachment(wGeneralComp, margin * 2);
    fdUrl.right = new FormAttachment(100, 0);
    wUrl.setLayoutData(fdUrl);
    // UrlInField line
    wlUrlInField = new Label(gSettings, SWT.RIGHT);
    wlUrlInField.setText(BaseMessages.getString(PKG, "RestDialog.UrlInField.Label"));
    props.setLook(wlUrlInField);
    fdlUrlInField = new FormData();
    fdlUrlInField.left = new FormAttachment(0, 0);
    fdlUrlInField.top = new FormAttachment(wUrl, margin);
    fdlUrlInField.right = new FormAttachment(middle, -margin);
    wlUrlInField.setLayoutData(fdlUrlInField);
    wUrlInField = new Button(gSettings, SWT.CHECK);
    props.setLook(wUrlInField);
    fdUrlInField = new FormData();
    fdUrlInField.left = new FormAttachment(middle, 0);
    fdUrlInField.top = new FormAttachment(wUrl, margin);
    fdUrlInField.right = new FormAttachment(100, 0);
    wUrlInField.setLayoutData(fdUrlInField);
    wUrlInField.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            activeUrlInfield();
        }
    });
    // UrlField Line
    wlUrlField = new Label(gSettings, SWT.RIGHT);
    wlUrlField.setText(BaseMessages.getString(PKG, "RestDialog.UrlField.Label"));
    props.setLook(wlUrlField);
    fdlUrlField = new FormData();
    fdlUrlField.left = new FormAttachment(0, 0);
    fdlUrlField.right = new FormAttachment(middle, -margin);
    fdlUrlField.top = new FormAttachment(wUrlInField, margin);
    wlUrlField.setLayoutData(fdlUrlField);
    wUrlField = new ComboVar(transMeta, gSettings, SWT.BORDER | SWT.READ_ONLY);
    wUrlField.setEditable(true);
    props.setLook(wUrlField);
    wUrlField.addModifyListener(lsMod);
    fdUrlField = new FormData();
    fdUrlField.left = new FormAttachment(middle, 0);
    fdUrlField.top = new FormAttachment(wUrlInField, margin);
    fdUrlField.right = new FormAttachment(100, -margin);
    wUrlField.setLayoutData(fdUrlField);
    wUrlField.addFocusListener(new FocusListener() {

        public void focusLost(org.eclipse.swt.events.FocusEvent e) {
        }

        public void focusGained(org.eclipse.swt.events.FocusEvent e) {
            Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
            shell.setCursor(busy);
            setStreamFields();
            shell.setCursor(null);
            busy.dispose();
        }
    });
    // Method Line
    wlMethod = new Label(gSettings, SWT.RIGHT);
    wlMethod.setText(BaseMessages.getString(PKG, "RestDialog.Method.Label"));
    props.setLook(wlMethod);
    fdlMethod = new FormData();
    fdlMethod.left = new FormAttachment(0, 0);
    fdlMethod.right = new FormAttachment(middle, -margin);
    fdlMethod.top = new FormAttachment(wUrlField, 2 * margin);
    wlMethod.setLayoutData(fdlMethod);
    wMethod = new ComboVar(transMeta, gSettings, SWT.BORDER | SWT.READ_ONLY);
    wMethod.setEditable(true);
    props.setLook(wMethod);
    wMethod.addModifyListener(lsMod);
    fdMethod = new FormData();
    fdMethod.left = new FormAttachment(middle, 0);
    fdMethod.top = new FormAttachment(wUrlField, 2 * margin);
    fdMethod.right = new FormAttachment(100, -margin);
    wMethod.setLayoutData(fdMethod);
    wMethod.setItems(RestMeta.HTTP_METHODS);
    wMethod.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            setMethod();
        }
    });
    // MethodInField line
    wlMethodInField = new Label(gSettings, SWT.RIGHT);
    wlMethodInField.setText(BaseMessages.getString(PKG, "RestDialog.MethodInField.Label"));
    props.setLook(wlMethodInField);
    fdlMethodInField = new FormData();
    fdlMethodInField.left = new FormAttachment(0, 0);
    fdlMethodInField.top = new FormAttachment(wMethod, margin);
    fdlMethodInField.right = new FormAttachment(middle, -margin);
    wlMethodInField.setLayoutData(fdlMethodInField);
    wMethodInField = new Button(gSettings, SWT.CHECK);
    props.setLook(wMethodInField);
    fdMethodInField = new FormData();
    fdMethodInField.left = new FormAttachment(middle, 0);
    fdMethodInField.top = new FormAttachment(wMethod, margin);
    fdMethodInField.right = new FormAttachment(100, 0);
    wMethodInField.setLayoutData(fdMethodInField);
    wMethodInField.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            activeMethodInfield();
        }
    });
    // MethodField Line
    wlMethodField = new Label(gSettings, SWT.RIGHT);
    wlMethodField.setText(BaseMessages.getString(PKG, "RestDialog.MethodField.Label"));
    props.setLook(wlMethodField);
    fdlMethodField = new FormData();
    fdlMethodField.left = new FormAttachment(0, 0);
    fdlMethodField.right = new FormAttachment(middle, -margin);
    fdlMethodField.top = new FormAttachment(wMethodInField, margin);
    wlMethodField.setLayoutData(fdlMethodField);
    wMethodField = new ComboVar(transMeta, gSettings, SWT.BORDER | SWT.READ_ONLY);
    wMethodField.setEditable(true);
    props.setLook(wMethodField);
    wMethodField.addModifyListener(lsMod);
    fdMethodField = new FormData();
    fdMethodField.left = new FormAttachment(middle, 0);
    fdMethodField.top = new FormAttachment(wMethodInField, margin);
    fdMethodField.right = new FormAttachment(100, -margin);
    wMethodField.setLayoutData(fdMethodField);
    wMethodField.addFocusListener(new FocusListener() {

        public void focusLost(org.eclipse.swt.events.FocusEvent e) {
        }

        public void focusGained(org.eclipse.swt.events.FocusEvent e) {
            Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
            shell.setCursor(busy);
            setStreamFields();
            shell.setCursor(null);
            busy.dispose();
        }
    });
    // Body Line
    wlBody = new Label(gSettings, SWT.RIGHT);
    wlBody.setText(BaseMessages.getString(PKG, "RestDialog.Body.Label"));
    props.setLook(wlBody);
    fdlBody = new FormData();
    fdlBody.left = new FormAttachment(0, 0);
    fdlBody.right = new FormAttachment(middle, -margin);
    fdlBody.top = new FormAttachment(wMethodField, 2 * margin);
    wlBody.setLayoutData(fdlBody);
    wBody = new ComboVar(transMeta, gSettings, SWT.BORDER | SWT.READ_ONLY);
    wBody.setEditable(true);
    props.setLook(wBody);
    wBody.addModifyListener(lsMod);
    fdBody = new FormData();
    fdBody.left = new FormAttachment(middle, 0);
    fdBody.top = new FormAttachment(wMethodField, 2 * margin);
    fdBody.right = new FormAttachment(100, -margin);
    wBody.setLayoutData(fdBody);
    wBody.addFocusListener(new FocusListener() {

        public void focusLost(org.eclipse.swt.events.FocusEvent e) {
        }

        public void focusGained(org.eclipse.swt.events.FocusEvent e) {
            Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
            shell.setCursor(busy);
            setStreamFields();
            shell.setCursor(null);
            busy.dispose();
        }
    });
    // ApplicationType Line
    wlApplicationType = new Label(gSettings, SWT.RIGHT);
    wlApplicationType.setText(BaseMessages.getString(PKG, "RestDialog.ApplicationType.Label"));
    props.setLook(wlApplicationType);
    fdlApplicationType = new FormData();
    fdlApplicationType.left = new FormAttachment(0, 0);
    fdlApplicationType.right = new FormAttachment(middle, -margin);
    fdlApplicationType.top = new FormAttachment(wBody, 2 * margin);
    wlApplicationType.setLayoutData(fdlApplicationType);
    wApplicationType = new ComboVar(transMeta, gSettings, SWT.BORDER | SWT.READ_ONLY);
    wApplicationType.setEditable(true);
    props.setLook(wApplicationType);
    wApplicationType.addModifyListener(lsMod);
    fdApplicationType = new FormData();
    fdApplicationType.left = new FormAttachment(middle, 0);
    fdApplicationType.top = new FormAttachment(wBody, 2 * margin);
    fdApplicationType.right = new FormAttachment(100, -margin);
    wApplicationType.setLayoutData(fdApplicationType);
    wApplicationType.setItems(RestMeta.APPLICATION_TYPES);
    wApplicationType.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });
    FormData fdSettings = new FormData();
    fdSettings.left = new FormAttachment(0, 0);
    fdSettings.right = new FormAttachment(100, 0);
    fdSettings.top = new FormAttachment(wStepname, margin);
    gSettings.setLayoutData(fdSettings);
    // END Output Settings GROUP
    // ////////////////////////
    // ////////////////////////
    // START Output Fields GROUP
    Group gOutputFields = new Group(wGeneralComp, SWT.SHADOW_ETCHED_IN);
    gOutputFields.setText(BaseMessages.getString(PKG, "RestDialog.OutputFieldsGroup.Label"));
    FormLayout OutputFieldsLayout = new FormLayout();
    OutputFieldsLayout.marginWidth = 3;
    OutputFieldsLayout.marginHeight = 3;
    gOutputFields.setLayout(OutputFieldsLayout);
    props.setLook(gOutputFields);
    // Result line...
    wlResult = new Label(gOutputFields, SWT.RIGHT);
    wlResult.setText(BaseMessages.getString(PKG, "RestDialog.Result.Label"));
    props.setLook(wlResult);
    fdlResult = new FormData();
    fdlResult.left = new FormAttachment(0, 0);
    fdlResult.right = new FormAttachment(middle, -margin);
    fdlResult.top = new FormAttachment(gSettings, margin);
    wlResult.setLayoutData(fdlResult);
    wResult = new TextVar(transMeta, gOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wResult);
    wResult.addModifyListener(lsMod);
    fdResult = new FormData();
    fdResult.left = new FormAttachment(middle, 0);
    fdResult.top = new FormAttachment(gSettings, margin * 2);
    fdResult.right = new FormAttachment(100, -margin);
    wResult.setLayoutData(fdResult);
    // Resultcode line...
    wlResultCode = new Label(gOutputFields, SWT.RIGHT);
    wlResultCode.setText(BaseMessages.getString(PKG, "RestDialog.ResultCode.Label"));
    props.setLook(wlResultCode);
    fdlResultCode = new FormData();
    fdlResultCode.left = new FormAttachment(0, 0);
    fdlResultCode.right = new FormAttachment(middle, -margin);
    fdlResultCode.top = new FormAttachment(wResult, margin);
    wlResultCode.setLayoutData(fdlResultCode);
    wResultCode = new TextVar(transMeta, gOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wResultCode);
    wResultCode.addModifyListener(lsMod);
    fdResultCode = new FormData();
    fdResultCode.left = new FormAttachment(middle, 0);
    fdResultCode.top = new FormAttachment(wResult, margin);
    fdResultCode.right = new FormAttachment(100, -margin);
    wResultCode.setLayoutData(fdResultCode);
    // Response time line...
    wlResponseTime = new Label(gOutputFields, SWT.RIGHT);
    wlResponseTime.setText(BaseMessages.getString(PKG, "RestDialog.ResponseTime.Label"));
    props.setLook(wlResponseTime);
    fdlResponseTime = new FormData();
    fdlResponseTime.left = new FormAttachment(0, 0);
    fdlResponseTime.right = new FormAttachment(middle, -margin);
    fdlResponseTime.top = new FormAttachment(wResultCode, margin);
    wlResponseTime.setLayoutData(fdlResponseTime);
    wResponseTime = new TextVar(transMeta, gOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wResponseTime);
    wResponseTime.addModifyListener(lsMod);
    fdResponseTime = new FormData();
    fdResponseTime.left = new FormAttachment(middle, 0);
    fdResponseTime.top = new FormAttachment(wResultCode, margin);
    fdResponseTime.right = new FormAttachment(100, 0);
    wResponseTime.setLayoutData(fdResponseTime);
    // Response header line...
    wlResponseHeader = new Label(gOutputFields, SWT.RIGHT);
    wlResponseHeader.setText(BaseMessages.getString(PKG, "RestDialog.ResponseHeader.Label"));
    props.setLook(wlResponseHeader);
    fdlResponseHeader = new FormData();
    fdlResponseHeader.left = new FormAttachment(0, 0);
    fdlResponseHeader.right = new FormAttachment(middle, -margin);
    fdlResponseHeader.top = new FormAttachment(wResponseTime, margin);
    wlResponseHeader.setLayoutData(fdlResponseHeader);
    wResponseHeader = new TextVar(transMeta, gOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wResponseHeader);
    wResponseHeader.addModifyListener(lsMod);
    fdResponseHeader = new FormData();
    fdResponseHeader.left = new FormAttachment(middle, 0);
    fdResponseHeader.top = new FormAttachment(wResponseTime, margin);
    fdResponseHeader.right = new FormAttachment(100, 0);
    wResponseHeader.setLayoutData(fdResponseHeader);
    FormData fdOutputFields = new FormData();
    fdOutputFields.left = new FormAttachment(0, 0);
    fdOutputFields.right = new FormAttachment(100, 0);
    fdOutputFields.top = new FormAttachment(gSettings, margin);
    gOutputFields.setLayoutData(fdOutputFields);
    // END Output Fields GROUP
    // ////////////////////////
    fdGeneralComp = new FormData();
    fdGeneralComp.left = new FormAttachment(0, 0);
    fdGeneralComp.top = new FormAttachment(wStepname, margin);
    fdGeneralComp.right = new FormAttachment(100, 0);
    fdGeneralComp.bottom = new FormAttachment(100, 0);
    wGeneralComp.setLayoutData(fdGeneralComp);
    wGeneralComp.layout();
    wGeneralTab.setControl(wGeneralComp);
    // ///////////////////////////////////////////////////////////
    // / END OF GENERAL TAB
    // ///////////////////////////////////////////////////////////
    // Auth tab...
    // 
    wAuthTab = new CTabItem(wTabFolder, SWT.NONE);
    wAuthTab.setText(BaseMessages.getString(PKG, "RestDialog.Auth.Title"));
    FormLayout alayout = new FormLayout();
    alayout.marginWidth = Const.FORM_MARGIN;
    alayout.marginHeight = Const.FORM_MARGIN;
    wAuthComp = new Composite(wTabFolder, SWT.NONE);
    wAuthComp.setLayout(alayout);
    props.setLook(wAuthComp);
    // ////////////////////////
    // START HTTP AUTH GROUP
    Group gHttpAuth = new Group(wAuthComp, SWT.SHADOW_ETCHED_IN);
    gHttpAuth.setText(BaseMessages.getString(PKG, "RestDialog.HttpAuthGroup.Label"));
    FormLayout httpAuthLayout = new FormLayout();
    httpAuthLayout.marginWidth = 3;
    httpAuthLayout.marginHeight = 3;
    gHttpAuth.setLayout(httpAuthLayout);
    props.setLook(gHttpAuth);
    // HTTP Login
    wlHttpLogin = new Label(gHttpAuth, SWT.RIGHT);
    wlHttpLogin.setText(BaseMessages.getString(PKG, "RestDialog.HttpLogin.Label"));
    props.setLook(wlHttpLogin);
    FormData fdlHttpLogin = new FormData();
    fdlHttpLogin.top = new FormAttachment(0, margin);
    fdlHttpLogin.left = new FormAttachment(0, 0);
    fdlHttpLogin.right = new FormAttachment(middle, -margin);
    wlHttpLogin.setLayoutData(fdlHttpLogin);
    wHttpLogin = new TextVar(transMeta, gHttpAuth, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wHttpLogin.addModifyListener(lsMod);
    wHttpLogin.setToolTipText(BaseMessages.getString(PKG, "RestDialog.HttpLogin.Tooltip"));
    props.setLook(wHttpLogin);
    FormData fdHttpLogin = new FormData();
    fdHttpLogin.top = new FormAttachment(0, margin);
    fdHttpLogin.left = new FormAttachment(middle, 0);
    fdHttpLogin.right = new FormAttachment(100, 0);
    wHttpLogin.setLayoutData(fdHttpLogin);
    // HTTP Password
    wlHttpPassword = new Label(gHttpAuth, SWT.RIGHT);
    wlHttpPassword.setText(BaseMessages.getString(PKG, "RestDialog.HttpPassword.Label"));
    props.setLook(wlHttpPassword);
    FormData fdlHttpPassword = new FormData();
    fdlHttpPassword.top = new FormAttachment(wHttpLogin, margin);
    fdlHttpPassword.left = new FormAttachment(0, 0);
    fdlHttpPassword.right = new FormAttachment(middle, -margin);
    wlHttpPassword.setLayoutData(fdlHttpPassword);
    wHttpPassword = new PasswordTextVar(transMeta, gHttpAuth, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wHttpPassword.addModifyListener(lsMod);
    wHttpPassword.setToolTipText(BaseMessages.getString(PKG, "RestDialog.HttpPassword.Tooltip"));
    props.setLook(wHttpPassword);
    FormData fdHttpPassword = new FormData();
    fdHttpPassword.top = new FormAttachment(wHttpLogin, margin);
    fdHttpPassword.left = new FormAttachment(middle, 0);
    fdHttpPassword.right = new FormAttachment(100, 0);
    wHttpPassword.setLayoutData(fdHttpPassword);
    // Preemptive line
    wlPreemptive = new Label(gHttpAuth, SWT.RIGHT);
    wlPreemptive.setText(BaseMessages.getString(PKG, "RestDialog.Preemptive.Label"));
    props.setLook(wlPreemptive);
    fdlPreemptive = new FormData();
    fdlPreemptive.left = new FormAttachment(0, 0);
    fdlPreemptive.top = new FormAttachment(wHttpPassword, margin);
    fdlPreemptive.right = new FormAttachment(middle, -margin);
    wlPreemptive.setLayoutData(fdlPreemptive);
    wPreemptive = new Button(gHttpAuth, SWT.CHECK);
    props.setLook(wPreemptive);
    fdPreemptive = new FormData();
    fdPreemptive.left = new FormAttachment(middle, 0);
    fdPreemptive.top = new FormAttachment(wHttpPassword, margin);
    fdPreemptive.right = new FormAttachment(100, 0);
    wPreemptive.setLayoutData(fdPreemptive);
    wPreemptive.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });
    FormData fdHttpAuth = new FormData();
    fdHttpAuth.left = new FormAttachment(0, 0);
    fdHttpAuth.right = new FormAttachment(100, 0);
    fdHttpAuth.top = new FormAttachment(gOutputFields, margin);
    gHttpAuth.setLayoutData(fdHttpAuth);
    // END HTTP AUTH GROUP
    // ////////////////////////
    // ////////////////////////
    // START PROXY GROUP
    Group gProxy = new Group(wAuthComp, SWT.SHADOW_ETCHED_IN);
    gProxy.setText(BaseMessages.getString(PKG, "RestDialog.ProxyGroup.Label"));
    FormLayout proxyLayout = new FormLayout();
    proxyLayout.marginWidth = 3;
    proxyLayout.marginHeight = 3;
    gProxy.setLayout(proxyLayout);
    props.setLook(gProxy);
    // HTTP Login
    wlProxyHost = new Label(gProxy, SWT.RIGHT);
    wlProxyHost.setText(BaseMessages.getString(PKG, "RestDialog.ProxyHost.Label"));
    props.setLook(wlProxyHost);
    FormData fdlProxyHost = new FormData();
    fdlProxyHost.top = new FormAttachment(0, margin);
    fdlProxyHost.left = new FormAttachment(0, 0);
    fdlProxyHost.right = new FormAttachment(middle, -margin);
    wlProxyHost.setLayoutData(fdlProxyHost);
    wProxyHost = new TextVar(transMeta, gProxy, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wProxyHost.addModifyListener(lsMod);
    wProxyHost.setToolTipText(BaseMessages.getString(PKG, "RestDialog.ProxyHost.Tooltip"));
    props.setLook(wProxyHost);
    FormData fdProxyHost = new FormData();
    fdProxyHost.top = new FormAttachment(0, margin);
    fdProxyHost.left = new FormAttachment(middle, 0);
    fdProxyHost.right = new FormAttachment(100, 0);
    wProxyHost.setLayoutData(fdProxyHost);
    // HTTP Password
    wlProxyPort = new Label(gProxy, SWT.RIGHT);
    wlProxyPort.setText(BaseMessages.getString(PKG, "RestDialog.ProxyPort.Label"));
    props.setLook(wlProxyPort);
    FormData fdlProxyPort = new FormData();
    fdlProxyPort.top = new FormAttachment(wProxyHost, margin);
    fdlProxyPort.left = new FormAttachment(0, 0);
    fdlProxyPort.right = new FormAttachment(middle, -margin);
    wlProxyPort.setLayoutData(fdlProxyPort);
    wProxyPort = new TextVar(transMeta, gProxy, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wProxyPort.addModifyListener(lsMod);
    wProxyPort.setToolTipText(BaseMessages.getString(PKG, "RestDialog.ProxyPort.Tooltip"));
    props.setLook(wProxyPort);
    FormData fdProxyPort = new FormData();
    fdProxyPort.top = new FormAttachment(wProxyHost, margin);
    fdProxyPort.left = new FormAttachment(middle, 0);
    fdProxyPort.right = new FormAttachment(100, 0);
    wProxyPort.setLayoutData(fdProxyPort);
    FormData fdProxy = new FormData();
    fdProxy.left = new FormAttachment(0, 0);
    fdProxy.right = new FormAttachment(100, 0);
    fdProxy.top = new FormAttachment(gHttpAuth, margin);
    gProxy.setLayoutData(fdProxy);
    // END HTTP AUTH GROUP
    // ////////////////////////
    fdAuthComp = new FormData();
    fdAuthComp.left = new FormAttachment(0, 0);
    fdAuthComp.top = new FormAttachment(wStepname, margin);
    fdAuthComp.right = new FormAttachment(100, 0);
    fdAuthComp.bottom = new FormAttachment(100, 0);
    wAuthComp.setLayoutData(fdAuthComp);
    wAuthComp.layout();
    wAuthTab.setControl(wAuthComp);
    // ////// END of Auth Tab
    // SSL tab...
    // 
    wSSLTab = new CTabItem(wTabFolder, SWT.NONE);
    wSSLTab.setText(BaseMessages.getString(PKG, "RestDialog.SSL.Title"));
    FormLayout ssll = new FormLayout();
    ssll.marginWidth = Const.FORM_MARGIN;
    ssll.marginHeight = Const.FORM_MARGIN;
    wSSLComp = new Composite(wTabFolder, SWT.NONE);
    wSSLComp.setLayout(ssll);
    props.setLook(wSSLComp);
    // ////////////////////////
    // START SSLTrustStore GROUP
    Group gSSLTrustStore = new Group(wSSLComp, SWT.SHADOW_ETCHED_IN);
    gSSLTrustStore.setText(BaseMessages.getString(PKG, "RestDialog.SSLTrustStoreGroup.Label"));
    FormLayout SSLTrustStoreLayout = new FormLayout();
    SSLTrustStoreLayout.marginWidth = 3;
    SSLTrustStoreLayout.marginHeight = 3;
    gSSLTrustStore.setLayout(SSLTrustStoreLayout);
    props.setLook(gSSLTrustStore);
    // TrustStoreFile line
    wlTrustStoreFile = new Label(gSSLTrustStore, SWT.RIGHT);
    wlTrustStoreFile.setText(BaseMessages.getString(PKG, "RestDialog.TrustStoreFile.Label"));
    props.setLook(wlTrustStoreFile);
    fdlTrustStoreFile = new FormData();
    fdlTrustStoreFile.left = new FormAttachment(0, 0);
    fdlTrustStoreFile.top = new FormAttachment(0, margin);
    fdlTrustStoreFile.right = new FormAttachment(middle, -margin);
    wlTrustStoreFile.setLayoutData(fdlTrustStoreFile);
    wbTrustStoreFile = new Button(gSSLTrustStore, SWT.PUSH | SWT.CENTER);
    props.setLook(wbTrustStoreFile);
    wbTrustStoreFile.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    fdbTrustStoreFile = new FormData();
    fdbTrustStoreFile.right = new FormAttachment(100, 0);
    fdbTrustStoreFile.top = new FormAttachment(0, 0);
    wbTrustStoreFile.setLayoutData(fdbTrustStoreFile);
    wbTrustStoreFile.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.SAVE);
            dialog.setFilterExtensions(new String[] { "*.*" });
            if (wTrustStoreFile.getText() != null) {
                dialog.setFileName(transMeta.environmentSubstitute(wTrustStoreFile.getText()));
            }
            dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.AllFiles") });
            if (dialog.open() != null) {
                wTrustStoreFile.setText(dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName());
            }
        }
    });
    wTrustStoreFile = new TextVar(transMeta, gSSLTrustStore, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wTrustStoreFile);
    wTrustStoreFile.addModifyListener(lsMod);
    fdTrustStoreFile = new FormData();
    fdTrustStoreFile.left = new FormAttachment(middle, 0);
    fdTrustStoreFile.top = new FormAttachment(0, margin);
    fdTrustStoreFile.right = new FormAttachment(wbTrustStoreFile, -margin);
    wTrustStoreFile.setLayoutData(fdTrustStoreFile);
    // TrustStorePassword line
    wlTrustStorePassword = new Label(gSSLTrustStore, SWT.RIGHT);
    wlTrustStorePassword.setText(BaseMessages.getString(PKG, "RestDialog.TrustStorePassword.Label"));
    props.setLook(wlTrustStorePassword);
    fdlTrustStorePassword = new FormData();
    fdlTrustStorePassword.left = new FormAttachment(0, 0);
    fdlTrustStorePassword.top = new FormAttachment(wbTrustStoreFile, margin);
    fdlTrustStorePassword.right = new FormAttachment(middle, -margin);
    wlTrustStorePassword.setLayoutData(fdlTrustStorePassword);
    wTrustStorePassword = new PasswordTextVar(transMeta, gSSLTrustStore, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wTrustStorePassword);
    wTrustStorePassword.addModifyListener(lsMod);
    fdTrustStorePassword = new FormData();
    fdTrustStorePassword.left = new FormAttachment(middle, 0);
    fdTrustStorePassword.top = new FormAttachment(wbTrustStoreFile, margin);
    fdTrustStorePassword.right = new FormAttachment(100, 0);
    wTrustStorePassword.setLayoutData(fdTrustStorePassword);
    FormData fdSSLTrustStore = new FormData();
    fdSSLTrustStore.left = new FormAttachment(0, 0);
    fdSSLTrustStore.right = new FormAttachment(100, 0);
    fdSSLTrustStore.top = new FormAttachment(gHttpAuth, margin);
    gSSLTrustStore.setLayoutData(fdSSLTrustStore);
    // END HTTP AUTH GROUP
    // ////////////////////////
    fdSSLComp = new FormData();
    fdSSLComp.left = new FormAttachment(0, 0);
    fdSSLComp.top = new FormAttachment(wStepname, margin);
    fdSSLComp.right = new FormAttachment(100, 0);
    fdSSLComp.bottom = new FormAttachment(100, 0);
    wSSLComp.setLayoutData(fdSSLComp);
    wSSLComp.layout();
    wSSLTab.setControl(wSSLComp);
    // ////// END of SSL Tab
    // Additional tab...
    // 
    wAdditionalTab = new CTabItem(wTabFolder, SWT.NONE);
    wAdditionalTab.setText(BaseMessages.getString(PKG, "RestDialog.Headers.Title"));
    FormLayout addLayout = new FormLayout();
    addLayout.marginWidth = Const.FORM_MARGIN;
    addLayout.marginHeight = Const.FORM_MARGIN;
    wAdditionalComp = new Composite(wTabFolder, SWT.NONE);
    wAdditionalComp.setLayout(addLayout);
    props.setLook(wAdditionalComp);
    wlFields = new Label(wAdditionalComp, SWT.NONE);
    wlFields.setText(BaseMessages.getString(PKG, "RestDialog.Headers.Label"));
    props.setLook(wlFields);
    fdlFields = new FormData();
    fdlFields.left = new FormAttachment(0, 0);
    fdlFields.top = new FormAttachment(wStepname, margin);
    wlFields.setLayoutData(fdlFields);
    wGetHeaders = new Button(wAdditionalComp, SWT.PUSH);
    wGetHeaders.setText(BaseMessages.getString(PKG, "RestDialog.GetHeaders.Button"));
    FormData fdGetHeaders = new FormData();
    fdGetHeaders.top = new FormAttachment(wlFields, margin);
    fdGetHeaders.right = new FormAttachment(100, 0);
    wGetHeaders.setLayoutData(fdGetHeaders);
    final int FieldsRows = input.getHeaderName().length;
    colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "RestDialog.ColumnInfo.Field"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false), new ColumnInfo(BaseMessages.getString(PKG, "RestDialog.ColumnInfo.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
    colinf[1].setUsingVariables(true);
    wFields = new TableView(transMeta, wAdditionalComp, 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(wGetHeaders, -margin);
    fdFields.bottom = new FormAttachment(100, -margin);
    wFields.setLayoutData(fdFields);
    fdAdditionalComp = new FormData();
    fdAdditionalComp.left = new FormAttachment(0, 0);
    fdAdditionalComp.top = new FormAttachment(wStepname, margin);
    fdAdditionalComp.right = new FormAttachment(100, -margin);
    fdAdditionalComp.bottom = new FormAttachment(100, 0);
    wAdditionalComp.setLayoutData(fdAdditionalComp);
    wAdditionalComp.layout();
    wAdditionalTab.setControl(wAdditionalComp);
    // ////// END of Additional Tab
    // Query Parameters tab...
    // 
    wParametersTab = new CTabItem(wTabFolder, SWT.NONE);
    wParametersTab.setText(BaseMessages.getString(PKG, "RestDialog.Parameters.Title"));
    FormLayout playout = new FormLayout();
    playout.marginWidth = Const.FORM_MARGIN;
    playout.marginHeight = Const.FORM_MARGIN;
    wParametersComp = new Composite(wTabFolder, SWT.NONE);
    wParametersComp.setLayout(playout);
    props.setLook(wParametersComp);
    wlParameters = new Label(wParametersComp, SWT.NONE);
    wlParameters.setText(BaseMessages.getString(PKG, "RestDialog.Parameters.Label"));
    props.setLook(wlParameters);
    fdlParameters = new FormData();
    fdlParameters.left = new FormAttachment(0, 0);
    fdlParameters.top = new FormAttachment(wStepname, margin);
    wlParameters.setLayoutData(fdlParameters);
    wGet = new Button(wParametersComp, SWT.PUSH);
    wGet.setText(BaseMessages.getString(PKG, "RestDialog.GetParameters.Button"));
    FormData fdGet = new FormData();
    fdGet.top = new FormAttachment(wlParameters, margin);
    fdGet.right = new FormAttachment(100, 0);
    wGet.setLayoutData(fdGet);
    final int ParametersRows = input.getParameterField().length;
    colinfoparams = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "RestDialog.ColumnInfo.ParameterField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false), new ColumnInfo(BaseMessages.getString(PKG, "RestDialog.ColumnInfo.ParameterName"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
    wParameters = new TableView(transMeta, wParametersComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinfoparams, ParametersRows, lsMod, props);
    fdParameters = new FormData();
    fdParameters.left = new FormAttachment(0, 0);
    fdParameters.top = new FormAttachment(wlParameters, margin);
    fdParameters.right = new FormAttachment(wGet, -margin);
    fdParameters.bottom = new FormAttachment(100, -margin);
    wParameters.setLayoutData(fdParameters);
    fdParametersComp = new FormData();
    fdParametersComp.left = new FormAttachment(0, 0);
    fdParametersComp.top = new FormAttachment(wStepname, margin);
    fdParametersComp.right = new FormAttachment(100, 0);
    fdParametersComp.bottom = new FormAttachment(100, 0);
    wParametersComp.setLayoutData(fdParametersComp);
    wParametersComp.layout();
    wParametersTab.setControl(wParametersComp);
    // ////// END of Query Parameters Tab
    // Matrix Parameters tab
    wMatrixParametersTab = new CTabItem(wTabFolder, SWT.NONE);
    wMatrixParametersTab.setText(BaseMessages.getString(PKG, "RestDialog.MatrixParameters.Title"));
    FormLayout pl = new FormLayout();
    pl.marginWidth = Const.FORM_MARGIN;
    pl.marginHeight = Const.FORM_MARGIN;
    wMatrixParametersComp = new Composite(wTabFolder, SWT.NONE);
    wMatrixParametersComp.setLayout(pl);
    props.setLook(wMatrixParametersComp);
    wlMatrixParameters = new Label(wMatrixParametersComp, SWT.NONE);
    wlMatrixParameters.setText(BaseMessages.getString(PKG, "RestDialog.Parameters.Label"));
    props.setLook(wlMatrixParameters);
    fdlMatrixParameters = new FormData();
    fdlMatrixParameters.left = new FormAttachment(0, 0);
    fdlMatrixParameters.top = new FormAttachment(wStepname, margin);
    wlMatrixParameters.setLayoutData(fdlMatrixParameters);
    wMatrixGet = new Button(wMatrixParametersComp, SWT.PUSH);
    wMatrixGet.setText(BaseMessages.getString(PKG, "RestDialog.GetParameters.Button"));
    FormData fdMatrixGet = new FormData();
    fdMatrixGet.top = new FormAttachment(wlMatrixParameters, margin);
    fdMatrixGet.right = new FormAttachment(100, 0);
    wMatrixGet.setLayoutData(fdMatrixGet);
    int matrixParametersRows = input.getMatrixParameterField().length;
    colinfoparams = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "RestDialog.ColumnInfo.ParameterField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false), new ColumnInfo(BaseMessages.getString(PKG, "RestDialog.ColumnInfo.ParameterName"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
    wMatrixParameters = new TableView(transMeta, wMatrixParametersComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinfoparams, matrixParametersRows, lsMod, props);
    fdMatrixParameters = new FormData();
    fdMatrixParameters.left = new FormAttachment(0, 0);
    fdMatrixParameters.top = new FormAttachment(wlMatrixParameters, margin);
    fdMatrixParameters.right = new FormAttachment(wMatrixGet, -margin);
    fdMatrixParameters.bottom = new FormAttachment(100, -margin);
    wMatrixParameters.setLayoutData(fdMatrixParameters);
    fdMatrixParametersComp = new FormData();
    fdMatrixParametersComp.left = new FormAttachment(0, 0);
    fdMatrixParametersComp.top = new FormAttachment(wStepname, margin);
    fdMatrixParametersComp.right = new FormAttachment(100, 0);
    fdMatrixParametersComp.bottom = new FormAttachment(100, 0);
    wMatrixParametersComp.setLayoutData(fdMatrixParametersComp);
    wMatrixParametersComp.layout();
    wMatrixParametersTab.setControl(wMatrixParametersComp);
    // END of Matrix Parameters Tab
    fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(wStepname, margin);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.bottom = new FormAttachment(100, -50);
    wTabFolder.setLayoutData(fdTabFolder);
    // 
    // 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(), Integer.valueOf(i));
                    }
                    setComboBoxes();
                } catch (KettleException e) {
                    log.logError(toString(), BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
                }
            }
        }
    };
    new Thread(runnable).start();
    // 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"));
    setButtonPositions(new Button[] { wOK, wCancel }, margin, wTabFolder);
    // Add listeners
    lsOK = new Listener() {

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

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

        public void handleEvent(Event e) {
            getParametersFields(wParameters);
        }
    };
    lsMatrixGet = new Listener() {

        public void handleEvent(Event e) {
            getParametersFields(wMatrixParameters);
        }
    };
    Listener lsGetHeaders = new Listener() {

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

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

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    lsResize = new Listener() {

        public void handleEvent(Event event) {
            Point size = shell.getSize();
            wFields.setSize(size.x - 10, size.y - 50);
            wFields.table.setSize(size.x - 10, size.y - 50);
            wFields.redraw();
        }
    };
    shell.addListener(SWT.Resize, lsResize);
    // Set the shell size, based upon previous time...
    setSize();
    wTabFolder.setSelection(0);
    getData();
    activeUrlInfield();
    activeMethodInfield();
    setMethod();
    input.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : Group(org.eclipse.swt.widgets.Group) KettleException(org.pentaho.di.core.exception.KettleException) ComboVar(org.pentaho.di.ui.core.widget.ComboVar) CTabFolder(org.eclipse.swt.custom.CTabFolder) FocusListener(org.eclipse.swt.events.FocusListener) 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) Cursor(org.eclipse.swt.graphics.Cursor) CTabItem(org.eclipse.swt.custom.CTabItem) 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) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Point(org.eclipse.swt.graphics.Point) TextVar(org.pentaho.di.ui.core.widget.TextVar) PasswordTextVar(org.pentaho.di.ui.core.widget.PasswordTextVar) PasswordTextVar(org.pentaho.di.ui.core.widget.PasswordTextVar) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) FileDialog(org.eclipse.swt.widgets.FileDialog) Display(org.eclipse.swt.widgets.Display)

Example 38 with ColumnInfo

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

the class DatabaseLookupDialog 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();
        }
    };
    ModifyListener lsConnectionMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            input.setChanged();
            setTableFieldCombo();
        }
    };
    ModifyListener lsTableMod = new ModifyListener() {

        public void modifyText(ModifyEvent arg0) {
            input.setChanged();
            setTableFieldCombo();
        }
    };
    SelectionListener lsSelection = new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            setTableFieldCombo();
        }
    };
    backupChanged = input.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.shell.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.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);
    // Connection line
    wConnection = addConnectionLine(shell, wStepname, middle, margin);
    if (input.getDatabaseMeta() == null && transMeta.nrDatabases() == 1) {
        wConnection.select(0);
    }
    wConnection.addModifyListener(lsConnectionMod);
    wConnection.addSelectionListener(lsSelection);
    // Schema line...
    wlSchema = new Label(shell, SWT.RIGHT);
    wlSchema.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.TargetSchema.Label"));
    props.setLook(wlSchema);
    fdlSchema = new FormData();
    fdlSchema.left = new FormAttachment(0, 0);
    fdlSchema.right = new FormAttachment(middle, -margin);
    fdlSchema.top = new FormAttachment(wConnection, margin * 2);
    wlSchema.setLayoutData(fdlSchema);
    wbSchema = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbSchema);
    wbSchema.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    fdbSchema = new FormData();
    fdbSchema.top = new FormAttachment(wConnection, 2 * margin);
    fdbSchema.right = new FormAttachment(100, 0);
    wbSchema.setLayoutData(fdbSchema);
    wSchema = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wSchema);
    wSchema.addModifyListener(lsTableMod);
    fdSchema = new FormData();
    fdSchema.left = new FormAttachment(middle, 0);
    fdSchema.top = new FormAttachment(wConnection, margin * 2);
    fdSchema.right = new FormAttachment(wbSchema, -margin);
    wSchema.setLayoutData(fdSchema);
    // Table line...
    wlTable = new Label(shell, SWT.RIGHT);
    wlTable.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.Lookuptable.Label"));
    props.setLook(wlTable);
    fdlTable = new FormData();
    fdlTable.left = new FormAttachment(0, 0);
    fdlTable.right = new FormAttachment(middle, -margin);
    fdlTable.top = new FormAttachment(wbSchema, margin);
    wlTable.setLayoutData(fdlTable);
    wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbTable);
    wbTable.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.Browse.Button"));
    fdbTable = new FormData();
    fdbTable.right = new FormAttachment(100, 0);
    fdbTable.top = new FormAttachment(wbSchema, margin);
    wbTable.setLayoutData(fdbTable);
    wTable = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wTable);
    wTable.addModifyListener(lsTableMod);
    fdTable = new FormData();
    fdTable.left = new FormAttachment(middle, 0);
    fdTable.top = new FormAttachment(wbSchema, margin);
    fdTable.right = new FormAttachment(wbTable, -margin);
    wTable.setLayoutData(fdTable);
    // Cache?
    wlCache = new Label(shell, SWT.RIGHT);
    wlCache.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.Cache.Label"));
    props.setLook(wlCache);
    fdlCache = new FormData();
    fdlCache.left = new FormAttachment(0, 0);
    fdlCache.right = new FormAttachment(middle, -margin);
    fdlCache.top = new FormAttachment(wTable, margin);
    wlCache.setLayoutData(fdlCache);
    wCache = new Button(shell, SWT.CHECK);
    props.setLook(wCache);
    fdCache = new FormData();
    fdCache.left = new FormAttachment(middle, 0);
    fdCache.top = new FormAttachment(wTable, margin);
    wCache.setLayoutData(fdCache);
    wCache.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            enableFields();
        }
    });
    // Cache size line
    wlCachesize = new Label(shell, SWT.RIGHT);
    wlCachesize.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.Cachesize.Label"));
    props.setLook(wlCachesize);
    wlCachesize.setEnabled(input.isCached());
    fdlCachesize = new FormData();
    fdlCachesize.left = new FormAttachment(0, 0);
    fdlCachesize.right = new FormAttachment(middle, -margin);
    fdlCachesize.top = new FormAttachment(wCache, margin);
    wlCachesize.setLayoutData(fdlCachesize);
    wCachesize = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wCachesize);
    wCachesize.setEnabled(input.isCached());
    wCachesize.addModifyListener(lsMod);
    fdCachesize = new FormData();
    fdCachesize.left = new FormAttachment(middle, 0);
    fdCachesize.right = new FormAttachment(100, 0);
    fdCachesize.top = new FormAttachment(wCache, margin);
    wCachesize.setLayoutData(fdCachesize);
    // Cache : Load all?
    wlCacheLoadAll = new Label(shell, SWT.RIGHT);
    wlCacheLoadAll.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.CacheLoadAll.Label"));
    props.setLook(wlCacheLoadAll);
    fdlCacheLoadAll = new FormData();
    fdlCacheLoadAll.left = new FormAttachment(0, 0);
    fdlCacheLoadAll.right = new FormAttachment(middle, -margin);
    fdlCacheLoadAll.top = new FormAttachment(wCachesize, margin);
    wlCacheLoadAll.setLayoutData(fdlCacheLoadAll);
    wCacheLoadAll = new Button(shell, SWT.CHECK);
    props.setLook(wCacheLoadAll);
    fdCacheLoadAll = new FormData();
    fdCacheLoadAll.left = new FormAttachment(middle, 0);
    fdCacheLoadAll.top = new FormAttachment(wCachesize, margin);
    wCacheLoadAll.setLayoutData(fdCacheLoadAll);
    wCacheLoadAll.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            enableFields();
        }
    });
    wlKey = new Label(shell, SWT.NONE);
    wlKey.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.Keys.Label"));
    props.setLook(wlKey);
    fdlKey = new FormData();
    fdlKey.left = new FormAttachment(0, 0);
    fdlKey.top = new FormAttachment(wCacheLoadAll, margin);
    wlKey.setLayoutData(fdlKey);
    int nrKeyCols = 4;
    int nrKeyRows = (input.getStreamKeyField1() != null ? input.getStreamKeyField1().length : 1);
    ColumnInfo[] ciKey = new ColumnInfo[nrKeyCols];
    ciKey[0] = new ColumnInfo(BaseMessages.getString(PKG, "DatabaseLookupDialog.ColumnInfo.Tablefield"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
    ciKey[1] = new ColumnInfo(BaseMessages.getString(PKG, "DatabaseLookupDialog.ColumnInfo.Comparator"), ColumnInfo.COLUMN_TYPE_CCOMBO, DatabaseLookupMeta.conditionStrings);
    ciKey[2] = new ColumnInfo(BaseMessages.getString(PKG, "DatabaseLookupDialog.ColumnInfo.Field1"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
    ciKey[3] = new ColumnInfo(BaseMessages.getString(PKG, "DatabaseLookupDialog.ColumnInfo.Field2"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
    tableFieldColumns.add(ciKey[0]);
    fieldColumns.add(ciKey[2]);
    fieldColumns.add(ciKey[3]);
    wKey = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciKey, nrKeyRows, lsMod, props);
    fdKey = new FormData();
    fdKey.left = new FormAttachment(0, 0);
    fdKey.top = new FormAttachment(wlKey, margin);
    fdKey.right = new FormAttachment(100, 0);
    fdKey.bottom = new FormAttachment(wlKey, 250);
    wKey.setLayoutData(fdKey);
    // THE BUTTONS
    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, "DatabaseLookupDialog.GetFields.Button"));
    wGetLU = new Button(shell, SWT.PUSH);
    wGetLU.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.GetLookupFields.Button"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    setButtonPositions(new Button[] { wOK, wCancel, wGet, wGetLU }, margin, null);
    // OderBy line
    wlOrderBy = new Label(shell, SWT.RIGHT);
    wlOrderBy.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.Orderby.Label"));
    props.setLook(wlOrderBy);
    fdlOrderBy = new FormData();
    fdlOrderBy.left = new FormAttachment(0, 0);
    fdlOrderBy.right = new FormAttachment(middle, -margin);
    fdlOrderBy.bottom = new FormAttachment(wOK, -2 * margin);
    wlOrderBy.setLayoutData(fdlOrderBy);
    wOrderBy = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wOrderBy);
    fdOrderBy = new FormData();
    fdOrderBy.left = new FormAttachment(middle, 0);
    fdOrderBy.bottom = new FormAttachment(wOK, -2 * margin);
    fdOrderBy.right = new FormAttachment(100, 0);
    wOrderBy.setLayoutData(fdOrderBy);
    wOrderBy.addModifyListener(lsMod);
    // FailMultiple?
    wlFailMultiple = new Label(shell, SWT.RIGHT);
    wlFailMultiple.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.FailMultiple.Label"));
    props.setLook(wlFailMultiple);
    fdlFailMultiple = new FormData();
    fdlFailMultiple.left = new FormAttachment(0, 0);
    fdlFailMultiple.right = new FormAttachment(middle, -margin);
    fdlFailMultiple.bottom = new FormAttachment(wOrderBy, -margin);
    wlFailMultiple.setLayoutData(fdlFailMultiple);
    wFailMultiple = new Button(shell, SWT.CHECK);
    props.setLook(wFailMultiple);
    fdFailMultiple = new FormData();
    fdFailMultiple.left = new FormAttachment(middle, 0);
    fdFailMultiple.bottom = new FormAttachment(wOrderBy, -margin);
    wFailMultiple.setLayoutData(fdFailMultiple);
    wFailMultiple.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            enableFields();
        }
    });
    // EatRows?
    wlEatRows = new Label(shell, SWT.RIGHT);
    wlEatRows.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.EatRows.Label"));
    props.setLook(wlEatRows);
    fdlEatRows = new FormData();
    fdlEatRows.left = new FormAttachment(0, 0);
    fdlEatRows.right = new FormAttachment(middle, -margin);
    fdlEatRows.bottom = new FormAttachment(wFailMultiple, -margin);
    wlEatRows.setLayoutData(fdlEatRows);
    wEatRows = new Button(shell, SWT.CHECK);
    props.setLook(wEatRows);
    fdEatRows = new FormData();
    fdEatRows.left = new FormAttachment(middle, 0);
    fdEatRows.bottom = new FormAttachment(wFailMultiple, -margin);
    wEatRows.setLayoutData(fdEatRows);
    wEatRows.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            enableFields();
        }
    });
    // THE UPDATE/INSERT TABLE
    wlReturn = new Label(shell, SWT.NONE);
    wlReturn.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.Return.Label"));
    props.setLook(wlReturn);
    fdlReturn = new FormData();
    fdlReturn.left = new FormAttachment(0, 0);
    fdlReturn.top = new FormAttachment(wKey, margin);
    wlReturn.setLayoutData(fdlReturn);
    int UpInsCols = 4;
    int UpInsRows = (input.getReturnValueField() != null ? input.getReturnValueField().length : 1);
    ColumnInfo[] ciReturn = new ColumnInfo[UpInsCols];
    ciReturn[0] = new ColumnInfo(BaseMessages.getString(PKG, "DatabaseLookupDialog.ColumnInfo.Field"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] {}, false);
    ciReturn[1] = new ColumnInfo(BaseMessages.getString(PKG, "DatabaseLookupDialog.ColumnInfo.Newname"), ColumnInfo.COLUMN_TYPE_TEXT, false);
    ciReturn[2] = new ColumnInfo(BaseMessages.getString(PKG, "DatabaseLookupDialog.ColumnInfo.Default"), ColumnInfo.COLUMN_TYPE_TEXT, false);
    ciReturn[3] = new ColumnInfo(BaseMessages.getString(PKG, "DatabaseLookupDialog.ColumnInfo.Type"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames());
    tableFieldColumns.add(ciReturn[0]);
    wReturn = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciReturn, UpInsRows, lsMod, props);
    fdReturn = new FormData();
    fdReturn.left = new FormAttachment(0, 0);
    fdReturn.top = new FormAttachment(wlReturn, margin);
    fdReturn.right = new FormAttachment(100, 0);
    fdReturn.bottom = new FormAttachment(wEatRows, -margin);
    wReturn.setLayoutData(fdReturn);
    // Add listeners
    lsOK = new Listener() {

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

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

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

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

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

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    wbSchema.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            getSchemaNames();
        }
    });
    wbTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            getTableName();
        }
    });
    shell.pack();
    shell.setMinimumSize(shell.getSize());
    getData();
    input.setChanged(backupChanged);
    setComboValues();
    setTableFieldCombo();
    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) 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) SelectionListener(org.eclipse.swt.events.SelectionListener) 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) 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) SelectionListener(org.eclipse.swt.events.SelectionListener) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 39 with ColumnInfo

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

the class DataGridDialog method open.

@Override
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);
    lsMod = new ModifyListener() {

        @Override
        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, "DataGridDialog.DialogTitle"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Filename 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);
    wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
    // //////////////////////
    // START OF META TAB ///
    // //////////////////////
    wMetaTab = new CTabItem(wTabFolder, SWT.NONE);
    wMetaTab.setText(BaseMessages.getString(PKG, "DataGridDialog.Meta.Label"));
    wMetaComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wMetaComp);
    FormLayout fileLayout = new FormLayout();
    fileLayout.marginWidth = 3;
    fileLayout.marginHeight = 3;
    wMetaComp.setLayout(fileLayout);
    final int FieldsRows = input.getFieldName().length;
    ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "DataGridDialog.Name.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "DataGridDialog.Type.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames()), new ColumnInfo(BaseMessages.getString(PKG, "DataGridDialog.Format.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, Const.getDateFormats()), new ColumnInfo(BaseMessages.getString(PKG, "DataGridDialog.Length.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "DataGridDialog.Precision.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "DataGridDialog.Currency.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "DataGridDialog.Decimal.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "DataGridDialog.Group.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "DataGridDialog.Value.SetEmptyString"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { BaseMessages.getString(PKG, "System.Combo.Yes"), BaseMessages.getString(PKG, "System.Combo.No") }) };
    wFields = new TableView(transMeta, wMetaComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
    FormData fdFields = new FormData();
    fdFields.left = new FormAttachment(0, 0);
    fdFields.top = new FormAttachment(0, 0);
    fdFields.right = new FormAttachment(100, 0);
    fdFields.bottom = new FormAttachment(100, 0);
    wFields.setLayoutData(fdFields);
    wMetaComp.layout();
    wMetaTab.setControl(wMetaComp);
    // //////////////////////
    // START OF DATA TAB ///
    // //////////////////////
    wDataTab = new CTabItem(wTabFolder, SWT.NONE);
    wDataTab.setText(BaseMessages.getString(PKG, "DataGridDialog.Data.Label"));
    wDataComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wDataComp);
    FormLayout filesettingLayout = new FormLayout();
    filesettingLayout.marginWidth = 3;
    filesettingLayout.marginHeight = 3;
    wDataComp.setLayout(fileLayout);
    addDataGrid(false);
    FormData fdDataComp = new FormData();
    fdDataComp.left = new FormAttachment(0, 0);
    fdDataComp.top = new FormAttachment(0, 0);
    fdDataComp.right = new FormAttachment(100, 0);
    fdDataComp.bottom = new FormAttachment(100, 0);
    wDataComp.setLayoutData(fdDataComp);
    wDataComp.layout();
    wDataTab.setControl(wDataComp);
    FormData fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(wStepname, margin);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.bottom = new FormAttachment(100, -50);
    wTabFolder.setLayoutData(fdTabFolder);
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wPreview = new Button(shell, SWT.PUSH);
    wPreview.setText(BaseMessages.getString(PKG, "System.Button.Preview"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    setButtonPositions(new Button[] { wOK, wPreview, wCancel }, margin, wTabFolder);
    // Add listeners
    lsOK = new Listener() {

        @Override
        public void handleEvent(Event e) {
            ok();
        }
    };
    lsPreview = new Listener() {

        @Override
        public void handleEvent(Event e) {
            preview();
        }
    };
    lsCancel = new Listener() {

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

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

        @Override
        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    lsResize = new Listener() {

        @Override
        public void handleEvent(Event event) {
            Point size = shell.getSize();
            wFields.setSize(size.x - 10, size.y - 50);
            wFields.table.setSize(size.x - 10, size.y - 50);
            wFields.redraw();
        }
    };
    shell.addListener(SWT.Resize, lsResize);
    getData();
    wTabFolder.setSelection(0);
    wTabFolder.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            addDataGrid(true);
        }
    });
    // Set the shell size, based upon previous time...
    setSize();
    input.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) 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) CTabItem(org.eclipse.swt.custom.CTabItem) 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) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) 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 40 with ColumnInfo

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

the class DataGridDialog method addDataGrid.

private void addDataGrid(boolean refresh) {
    if (refresh) {
        // retain changes made in the dialog...
        // 
        getMetaInfo(dataGridMeta);
    }
    if (refresh) {
        // Retain the data edited in the dialog...
        // 
        getDataInfo(dataGridMeta);
        // 
        for (Control control : wDataComp.getChildren()) {
            control.dispose();
        }
    }
    ColumnInfo[] columns = new ColumnInfo[dataGridMeta.getFieldName().length];
    for (int i = 0; i < columns.length; i++) {
        columns[i] = new ColumnInfo(dataGridMeta.getFieldName()[i], ColumnInfo.COLUMN_TYPE_TEXT, false, false);
    }
    List<List<String>> lines = dataGridMeta.getDataLines();
    wData = new TableView(transMeta, wDataComp, SWT.NONE, columns, lines.size(), lsMod, props);
    wData.setSortable(false);
    for (int i = 0; i < lines.size(); i++) {
        List<String> line = lines.get(i);
        TableItem item = wData.table.getItem(i);
        for (int f = 0; f < line.size(); f++) {
            item.setText(f + 1, Const.NVL(line.get(f), ""));
        }
    }
    wData.setRowNums();
    wData.optWidth(true);
    FormData fdData = new FormData();
    fdData.left = new FormAttachment(0, 0);
    fdData.top = new FormAttachment(0, 0);
    fdData.right = new FormAttachment(100, 0);
    fdData.bottom = new FormAttachment(100, 0);
    wData.setLayoutData(fdData);
    wTabFolder.layout(true, true);
    wFields.nrNonEmpty();
    wFields.setTableViewModifyListener(new TableView.TableViewModifyListener() {

        private Integer getIdxByValue(List<Integer> list, Integer value) {
            for (int i = 0; i < list.size(); i++) {
                if (list.get(i).equals(value)) {
                    return i;
                }
            }
            return null;
        }

        @Override
        public void moveRow(int position1, int position2) {
            // if one of rows is empty -- don't move data
            if (!wFields.getNonEmptyIndexes().contains(position1) || !wFields.getNonEmptyIndexes().contains(position2)) {
                wFields.nrNonEmpty();
                return;
            }
            Integer fieldRealPosition1 = getIdxByValue(wFields.getNonEmptyIndexes(), position1);
            Integer fieldRealPosition2 = getIdxByValue(wFields.getNonEmptyIndexes(), position2);
            if (fieldRealPosition1 == null || fieldRealPosition2 == null) {
                // can not happen (prevent warnings)
                return;
            }
            // data table have one technical column
            int dataPosition1 = fieldRealPosition1 + 1;
            int dataPosition2 = fieldRealPosition2 + 1;
            for (TableItem item : wData.table.getItems()) {
                String value1 = item.getText(dataPosition1);
                String value2 = item.getText(dataPosition2);
                item.setText(dataPosition2, value1);
                item.setText(dataPosition1, value2);
            }
            wFields.nrNonEmpty();
        }

        @Override
        public void insertRow(int rowIndex) {
            wFields.nrNonEmpty();
        }

        @Override
        public void cellFocusLost(int rowIndex) {
            List<Integer> nonEmptyIndexesBeforeChanges = wFields.getNonEmptyIndexes();
            wFields.nrNonEmpty();
            List<Integer> nonEmptyIndexesAfterChanges = wFields.getNonEmptyIndexes();
            if (CollectionUtils.isEqualCollection(nonEmptyIndexesBeforeChanges, nonEmptyIndexesAfterChanges)) {
                // count of fields rows didn't change
                return;
            }
            Collection<Integer> disjunction = CollectionUtils.disjunction(nonEmptyIndexesBeforeChanges, nonEmptyIndexesAfterChanges);
            Integer disjunctionIdx = (Integer) disjunction.toArray()[0];
            if (nonEmptyIndexesAfterChanges.contains(disjunctionIdx)) {
                // new Field was added
                Integer idxByValue = getIdxByValue(nonEmptyIndexesAfterChanges, disjunctionIdx);
                if (idxByValue == null) {
                    // can not happen (preventing warnings)
                    return;
                }
                // data table have one technical column
                idxByValue++;
                TableColumn column = new TableColumn(wData.table, SWT.NONE, idxByValue);
                column.pack();
            } else {
                // Field was deleted
                Integer removeColumn = getIdxByValue(nonEmptyIndexesBeforeChanges, disjunctionIdx);
                if (removeColumn == null) {
                    // can not happen (preventing warnings)
                    return;
                }
                // data table have one technical column
                removeColumn++;
                wData.table.getColumn(removeColumn).dispose();
                wFields.nrNonEmpty();
            }
        }

        @Override
        public void delete(int[] items) {
            for (int index : items) {
                if (!wFields.getNonEmptyIndexes().contains(index)) {
                    continue;
                }
                Integer removeColumn = getIdxByValue(wFields.getNonEmptyIndexes(), index);
                if (removeColumn == null) {
                    // can not happen (preventing warnings)
                    return;
                }
                // data table have one technical column
                removeColumn++;
                wData.table.getColumn(removeColumn).dispose();
            }
            wFields.nrNonEmpty();
        }
    });
    wFields.setContentListener(modifyEvent -> wFields.nrNonEmpty());
}
Also used : FormData(org.eclipse.swt.layout.FormData) TableItem(org.eclipse.swt.widgets.TableItem) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) TableColumn(org.eclipse.swt.widgets.TableColumn) Point(org.eclipse.swt.graphics.Point) Control(org.eclipse.swt.widgets.Control) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) 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