Search in sources :

Example 71 with TextVar

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

the class S3CsvInputDialog method open.

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

        @Override
        public void modifyText(ModifyEvent e) {
            inputMeta.setChanged();
        }
    };
    changed = inputMeta.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    // $NON-NLS-1$
    shell.setText(Messages.getString("S3CsvInputDialog.Shell.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Step name line
    // 
    wlStepname = new Label(shell, SWT.RIGHT);
    // $NON-NLS-1$
    wlStepname.setText(Messages.getString("S3CsvInputDialog.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);
    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);
    Control lastControl = wStepname;
    // Access key
    Label wlAccessKey = new Label(shell, SWT.RIGHT);
    // $NON-NLS-1$
    wlAccessKey.setText(Messages.getString("S3CsvInputDialog.AccessKey.Label"));
    props.setLook(wlAccessKey);
    FormData fdlAccessKey = new FormData();
    fdlAccessKey.top = new FormAttachment(lastControl, margin);
    fdlAccessKey.left = new FormAttachment(0, 0);
    fdlAccessKey.right = new FormAttachment(middle, -margin);
    wlAccessKey.setLayoutData(fdlAccessKey);
    wAccessKey = new PasswordTextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wAccessKey);
    wAccessKey.addModifyListener(lsMod);
    FormData fdAccessKey = new FormData();
    fdAccessKey.top = new FormAttachment(lastControl, margin);
    fdAccessKey.left = new FormAttachment(middle, 0);
    fdAccessKey.right = new FormAttachment(100, 0);
    wAccessKey.setLayoutData(fdAccessKey);
    lastControl = wAccessKey;
    // Secret key
    Label wlSecretKey = new Label(shell, SWT.RIGHT);
    // $NON-NLS-1$
    wlSecretKey.setText(Messages.getString("S3CsvInputDialog.SecretKey.Label"));
    props.setLook(wlSecretKey);
    FormData fdlSecretKey = new FormData();
    fdlSecretKey.top = new FormAttachment(lastControl, margin);
    fdlSecretKey.left = new FormAttachment(0, 0);
    fdlSecretKey.right = new FormAttachment(middle, -margin);
    wlSecretKey.setLayoutData(fdlSecretKey);
    wSecretKey = new PasswordTextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wSecretKey);
    wSecretKey.addModifyListener(lsMod);
    FormData fdSecretKey = new FormData();
    fdSecretKey.top = new FormAttachment(lastControl, margin);
    fdSecretKey.left = new FormAttachment(middle, 0);
    fdSecretKey.right = new FormAttachment(100, 0);
    wSecretKey.setLayoutData(fdSecretKey);
    lastControl = wSecretKey;
    // Bucket name
    Label wlBucket = new Label(shell, SWT.RIGHT);
    // $NON-NLS-1$
    wlBucket.setText(Messages.getString("S3CsvInputDialog.Bucket.Label"));
    props.setLook(wlBucket);
    FormData fdlBucket = new FormData();
    fdlBucket.top = new FormAttachment(lastControl, margin);
    fdlBucket.left = new FormAttachment(0, 0);
    fdlBucket.right = new FormAttachment(middle, -margin);
    wlBucket.setLayoutData(fdlBucket);
    wbBucket = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbBucket);
    wbBucket.setText(Messages.getString("S3CsvInputDialog.Bucket.Button"));
    FormData fdbBucket = new FormData();
    fdbBucket.top = new FormAttachment(lastControl, margin);
    fdbBucket.right = new FormAttachment(100, 0);
    wbBucket.setLayoutData(fdbBucket);
    wBucket = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wBucket);
    wBucket.addModifyListener(lsMod);
    FormData fdBucket = new FormData();
    fdBucket.top = new FormAttachment(lastControl, margin);
    fdBucket.left = new FormAttachment(middle, 0);
    fdBucket.right = new FormAttachment(wbBucket, -margin);
    wBucket.setLayoutData(fdBucket);
    lastControl = wBucket;
    // See if the step receives input.  If so, we don't ask for the filename, but for the filename field.
    // 
    isReceivingInput = transMeta.findNrPrevSteps(stepMeta) > 0;
    if (isReceivingInput) {
        RowMetaInterface previousFields;
        try {
            previousFields = transMeta.getPrevStepFields(stepMeta);
        } catch (KettleStepException e) {
            new ErrorDialog(shell, Messages.getString("S3CsvInputDialog.ErrorDialog.UnableToGetInputFields.Title"), Messages.getString("S3CsvInputDialog.ErrorDialog.UnableToGetInputFields.Message"), e);
            previousFields = new RowMeta();
        }
        // The filename field ...
        // 
        Label wlFilename = new Label(shell, SWT.RIGHT);
        // $NON-NLS-1$
        wlFilename.setText(Messages.getString("S3CsvInputDialog.FilenameField.Label"));
        props.setLook(wlFilename);
        FormData fdlFilename = new FormData();
        fdlFilename.top = new FormAttachment(lastControl, margin);
        fdlFilename.left = new FormAttachment(0, 0);
        fdlFilename.right = new FormAttachment(middle, -margin);
        wlFilename.setLayoutData(fdlFilename);
        wFilenameField = new CCombo(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
        wFilenameField.setItems(previousFields.getFieldNames());
        props.setLook(wFilenameField);
        wFilenameField.addModifyListener(lsMod);
        FormData fdFilename = new FormData();
        fdFilename.top = new FormAttachment(lastControl, margin);
        fdFilename.left = new FormAttachment(middle, 0);
        fdFilename.right = new FormAttachment(100, 0);
        wFilenameField.setLayoutData(fdFilename);
        lastControl = wFilenameField;
        // Checkbox to include the filename in the output...
        // 
        Label wlIncludeFilename = new Label(shell, SWT.RIGHT);
        // $NON-NLS-1$
        wlIncludeFilename.setText(Messages.getString("S3CsvInputDialog.IncludeFilenameField.Label"));
        props.setLook(wlIncludeFilename);
        FormData fdlIncludeFilename = new FormData();
        fdlIncludeFilename.top = new FormAttachment(lastControl, margin);
        fdlIncludeFilename.left = new FormAttachment(0, 0);
        fdlIncludeFilename.right = new FormAttachment(middle, -margin);
        wlIncludeFilename.setLayoutData(fdlIncludeFilename);
        wIncludeFilename = new Button(shell, SWT.CHECK);
        props.setLook(wIncludeFilename);
        wFilenameField.addModifyListener(lsMod);
        FormData fdIncludeFilename = new FormData();
        fdIncludeFilename.top = new FormAttachment(lastControl, margin);
        fdIncludeFilename.left = new FormAttachment(middle, 0);
        fdIncludeFilename.right = new FormAttachment(100, 0);
        wIncludeFilename.setLayoutData(fdIncludeFilename);
        lastControl = wIncludeFilename;
    } else {
        // Filename...
        // 
        // The filename browse button
        // 
        wbbFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
        props.setLook(wbbFilename);
        wbbFilename.setText(Messages.getString("System.Button.Browse"));
        wbbFilename.setToolTipText(Messages.getString("System.Tooltip.BrowseForFileOrDirAndAdd"));
        FormData fdbFilename = new FormData();
        fdbFilename.top = new FormAttachment(lastControl, margin);
        fdbFilename.right = new FormAttachment(100, 0);
        wbbFilename.setLayoutData(fdbFilename);
        // The field itself...
        // 
        Label wlFilename = new Label(shell, SWT.RIGHT);
        // $NON-NLS-1$
        wlFilename.setText(Messages.getString("S3CsvInputDialog.Filename.Label"));
        props.setLook(wlFilename);
        FormData fdlFilename = new FormData();
        fdlFilename.top = new FormAttachment(lastControl, margin);
        fdlFilename.left = new FormAttachment(0, 0);
        fdlFilename.right = new FormAttachment(middle, -margin);
        wlFilename.setLayoutData(fdlFilename);
        wFilename = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
        props.setLook(wFilename);
        wFilename.addModifyListener(lsMod);
        FormData fdFilename = new FormData();
        fdFilename.top = new FormAttachment(lastControl, margin);
        fdFilename.left = new FormAttachment(middle, 0);
        fdFilename.right = new FormAttachment(wbbFilename, -margin);
        wFilename.setLayoutData(fdFilename);
        lastControl = wFilename;
    }
    // delimiter
    Label wlDelimiter = new Label(shell, SWT.RIGHT);
    // $NON-NLS-1$
    wlDelimiter.setText(Messages.getString("S3CsvInputDialog.Delimiter.Label"));
    props.setLook(wlDelimiter);
    FormData fdlDelimiter = new FormData();
    fdlDelimiter.top = new FormAttachment(lastControl, margin);
    fdlDelimiter.left = new FormAttachment(0, 0);
    fdlDelimiter.right = new FormAttachment(middle, -margin);
    wlDelimiter.setLayoutData(fdlDelimiter);
    wbDelimiter = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbDelimiter);
    wbDelimiter.setText(Messages.getString("S3CsvInputDialog.Delimiter.Button"));
    FormData fdbDelimiter = new FormData();
    fdbDelimiter.top = new FormAttachment(lastControl, margin);
    fdbDelimiter.right = new FormAttachment(100, 0);
    wbDelimiter.setLayoutData(fdbDelimiter);
    wDelimiter = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wDelimiter);
    wDelimiter.addModifyListener(lsMod);
    FormData fdDelimiter = new FormData();
    fdDelimiter.top = new FormAttachment(lastControl, margin);
    fdDelimiter.left = new FormAttachment(middle, 0);
    fdDelimiter.right = new FormAttachment(wbDelimiter, -margin);
    wDelimiter.setLayoutData(fdDelimiter);
    lastControl = wDelimiter;
    // enclosure
    Label wlEnclosure = new Label(shell, SWT.RIGHT);
    // $NON-NLS-1$
    wlEnclosure.setText(Messages.getString("S3CsvInputDialog.Enclosure.Label"));
    props.setLook(wlEnclosure);
    FormData fdlEnclosure = new FormData();
    fdlEnclosure.top = new FormAttachment(lastControl, margin);
    fdlEnclosure.left = new FormAttachment(0, 0);
    fdlEnclosure.right = new FormAttachment(middle, -margin);
    wlEnclosure.setLayoutData(fdlEnclosure);
    wEnclosure = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wEnclosure);
    wEnclosure.addModifyListener(lsMod);
    FormData fdEnclosure = new FormData();
    fdEnclosure.top = new FormAttachment(lastControl, margin);
    fdEnclosure.left = new FormAttachment(middle, 0);
    fdEnclosure.right = new FormAttachment(100, 0);
    wEnclosure.setLayoutData(fdEnclosure);
    lastControl = wEnclosure;
    // Max line size
    // 
    Label wlMaxLineSize = new Label(shell, SWT.RIGHT);
    // $NON-NLS-1$
    wlMaxLineSize.setText(Messages.getString("S3CsvInputDialog.MaxLineSize.Label"));
    props.setLook(wlMaxLineSize);
    FormData fdlMaxLineSize = new FormData();
    fdlMaxLineSize.top = new FormAttachment(lastControl, margin);
    fdlMaxLineSize.left = new FormAttachment(0, 0);
    fdlMaxLineSize.right = new FormAttachment(middle, -margin);
    wlMaxLineSize.setLayoutData(fdlMaxLineSize);
    wMaxLineSize = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wMaxLineSize);
    wMaxLineSize.addModifyListener(lsMod);
    FormData fdMaxLineSize = new FormData();
    fdMaxLineSize.top = new FormAttachment(lastControl, margin);
    fdMaxLineSize.left = new FormAttachment(middle, 0);
    fdMaxLineSize.right = new FormAttachment(100, 0);
    wMaxLineSize.setLayoutData(fdMaxLineSize);
    lastControl = wMaxLineSize;
    // performingLazyConversion?
    // 
    Label wlLazyConversion = new Label(shell, SWT.RIGHT);
    // $NON-NLS-1$
    wlLazyConversion.setText(Messages.getString("S3CsvInputDialog.LazyConversion.Label"));
    props.setLook(wlLazyConversion);
    FormData fdlLazyConversion = new FormData();
    fdlLazyConversion.top = new FormAttachment(lastControl, margin);
    fdlLazyConversion.left = new FormAttachment(0, 0);
    fdlLazyConversion.right = new FormAttachment(middle, -margin);
    wlLazyConversion.setLayoutData(fdlLazyConversion);
    wLazyConversion = new Button(shell, SWT.CHECK);
    props.setLook(wLazyConversion);
    FormData fdLazyConversion = new FormData();
    fdLazyConversion.top = new FormAttachment(lastControl, margin);
    fdLazyConversion.left = new FormAttachment(middle, 0);
    fdLazyConversion.right = new FormAttachment(100, 0);
    wLazyConversion.setLayoutData(fdLazyConversion);
    lastControl = wLazyConversion;
    // header row?
    // 
    Label wlHeaderPresent = new Label(shell, SWT.RIGHT);
    // $NON-NLS-1$
    wlHeaderPresent.setText(Messages.getString("S3CsvInputDialog.HeaderPresent.Label"));
    props.setLook(wlHeaderPresent);
    FormData fdlHeaderPresent = new FormData();
    fdlHeaderPresent.top = new FormAttachment(lastControl, margin);
    fdlHeaderPresent.left = new FormAttachment(0, 0);
    fdlHeaderPresent.right = new FormAttachment(middle, -margin);
    wlHeaderPresent.setLayoutData(fdlHeaderPresent);
    wHeaderPresent = new Button(shell, SWT.CHECK);
    props.setLook(wHeaderPresent);
    FormData fdHeaderPresent = new FormData();
    fdHeaderPresent.top = new FormAttachment(lastControl, margin);
    fdHeaderPresent.left = new FormAttachment(middle, 0);
    fdHeaderPresent.right = new FormAttachment(100, 0);
    wHeaderPresent.setLayoutData(fdHeaderPresent);
    lastControl = wHeaderPresent;
    // The field itself...
    // 
    Label wlRowNumField = new Label(shell, SWT.RIGHT);
    // $NON-NLS-1$
    wlRowNumField.setText(Messages.getString("S3CsvInputDialog.RowNumField.Label"));
    props.setLook(wlRowNumField);
    FormData fdlRowNumField = new FormData();
    fdlRowNumField.top = new FormAttachment(lastControl, margin);
    fdlRowNumField.left = new FormAttachment(0, 0);
    fdlRowNumField.right = new FormAttachment(middle, -margin);
    wlRowNumField.setLayoutData(fdlRowNumField);
    wRowNumField = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wRowNumField);
    wRowNumField.addModifyListener(lsMod);
    FormData fdRowNumField = new FormData();
    fdRowNumField.top = new FormAttachment(lastControl, margin);
    fdRowNumField.left = new FormAttachment(middle, 0);
    fdRowNumField.right = new FormAttachment(100, 0);
    wRowNumField.setLayoutData(fdRowNumField);
    lastControl = wRowNumField;
    // running in parallel?
    // 
    Label wlRunningInParallel = new Label(shell, SWT.RIGHT);
    // $NON-NLS-1$
    wlRunningInParallel.setText(Messages.getString("S3CsvInputDialog.RunningInParallel.Label"));
    props.setLook(wlRunningInParallel);
    FormData fdlRunningInParallel = new FormData();
    fdlRunningInParallel.top = new FormAttachment(lastControl, margin);
    fdlRunningInParallel.left = new FormAttachment(0, 0);
    fdlRunningInParallel.right = new FormAttachment(middle, -margin);
    wlRunningInParallel.setLayoutData(fdlRunningInParallel);
    wRunningInParallel = new Button(shell, SWT.CHECK);
    props.setLook(wRunningInParallel);
    FormData fdRunningInParallel = new FormData();
    fdRunningInParallel.top = new FormAttachment(lastControl, margin);
    fdRunningInParallel.left = new FormAttachment(middle, 0);
    wRunningInParallel.setLayoutData(fdRunningInParallel);
    lastControl = wRunningInParallel;
    // Some buttons first, so that the dialog scales nicely...
    // 
    wOK = new Button(shell, SWT.PUSH);
    // $NON-NLS-1$
    wOK.setText(Messages.getString("System.Button.OK"));
    wCancel = new Button(shell, SWT.PUSH);
    // $NON-NLS-1$
    wCancel.setText(Messages.getString("System.Button.Cancel"));
    wPreview = new Button(shell, SWT.PUSH);
    // $NON-NLS-1$
    wPreview.setText(Messages.getString("System.Button.Preview"));
    wPreview.setEnabled(!isReceivingInput);
    wGet = new Button(shell, SWT.PUSH);
    // $NON-NLS-1$
    wGet.setText(Messages.getString("System.Button.GetFields"));
    wGet.setEnabled(!isReceivingInput);
    setButtonPositions(new Button[] { wOK, wCancel, wPreview, wGet }, margin, null);
    // Fields
    ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(Messages.getString("S3CsvInputDialog.NameColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(Messages.getString("S3CsvInputDialog.TypeColumn.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMeta.getTypes(), true), new ColumnInfo(Messages.getString("S3CsvInputDialog.FormatColumn.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, Const.getConversionFormats()), new ColumnInfo(Messages.getString("S3CsvInputDialog.LengthColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(Messages.getString("S3CsvInputDialog.PrecisionColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(Messages.getString("S3CsvInputDialog.CurrencyColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(Messages.getString("S3CsvInputDialog.DecimalColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(Messages.getString("S3CsvInputDialog.GroupColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(Messages.getString("S3CsvInputDialog.TrimTypeColumn.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMeta.trimTypeDesc) };
    colinf[2].setComboValuesSelectionListener(new ComboValuesSelectionListener() {

        @Override
        public String[] getComboValues(TableItem tableItem, int rowNr, int colNr) {
            String[] comboValues = new String[] {};
            int type = ValueMeta.getType(tableItem.getText(colNr - 1));
            switch(type) {
                case ValueMetaInterface.TYPE_DATE:
                    comboValues = Const.getDateFormats();
                    break;
                case ValueMetaInterface.TYPE_INTEGER:
                case ValueMetaInterface.TYPE_BIGNUMBER:
                case ValueMetaInterface.TYPE_NUMBER:
                    comboValues = Const.getNumberFormats();
                    break;
                default:
                    break;
            }
            return comboValues;
        }
    });
    wFields = new TableView(transMeta, shell, SWT.FULL_SELECTION | SWT.MULTI, colinf, 1, lsMod, props);
    FormData fdFields = new FormData();
    fdFields.top = new FormAttachment(lastControl, margin * 2);
    fdFields.bottom = new FormAttachment(wOK, -margin * 2);
    fdFields.left = new FormAttachment(0, 0);
    fdFields.right = new FormAttachment(100, 0);
    wFields.setLayoutData(fdFields);
    // Add listeners
    lsCancel = new Listener() {

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

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

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

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

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wStepname.addSelectionListener(lsDef);
    if (wFilename != null) {
        wFilename.addSelectionListener(lsDef);
    }
    if (wFilenameField != null) {
        wFilenameField.addSelectionListener(lsDef);
    }
    wDelimiter.addSelectionListener(lsDef);
    wEnclosure.addSelectionListener(lsDef);
    wMaxLineSize.addSelectionListener(lsDef);
    wRowNumField.addSelectionListener(lsDef);
    // Allow the insertion of tabs as separator...
    wbDelimiter.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent se) {
            Text t = wDelimiter.getTextWidget();
            if (t != null) {
                t.insert("\t");
            }
        }
    });
    wbBucket.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            // 
            try {
                S3CsvInputMeta meta = new S3CsvInputMeta();
                getInfo(meta);
                S3ObjectsProvider s3ObjProvider = new S3ObjectsProvider(meta.getS3Service(transMeta));
                EnterSelectionDialog dialog = new EnterSelectionDialog(shell, s3ObjProvider.getBucketsNames(), Messages.getString("S3CsvInputDialog.Exception.SelectBucket.Title"), Messages.getString("S3CsvInputDialog.Exception.SelectBucket.Message"));
                dialog.setMulti(false);
                String bucketname = dialog.open();
                if (bucketname != null) {
                    wBucket.setText(bucketname);
                }
            } catch (Exception e) {
                new ErrorDialog(shell, Messages.getString("S3CsvInputDialog.Exception.UnableToGetBuckets.Title"), Messages.getString("S3CsvInputDialog.Exception.UnableToGetBuckets.Message"), e);
            }
        }
    });
    if (wbbFilename != null) {
        // Listen to the browse button next to the file name
        wbbFilename.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent event) {
                try {
                    S3CsvInputMeta meta = new S3CsvInputMeta();
                    getInfo(meta);
                    S3ObjectsProvider s3ObjProvider = new S3ObjectsProvider(meta.getS3Service(transMeta));
                    String[] objectnames = s3ObjProvider.getS3ObjectsNames(meta.getBucket());
                    EnterSelectionDialog dialog = new EnterSelectionDialog(shell, objectnames, Messages.getString("S3CsvInputDialog.Exception.SelectObject.Title"), Messages.getString("S3CsvInputDialog.Exception.SelectObject.Message"));
                    dialog.setMulti(false);
                    if (!Utils.isEmpty(wFilename.getText())) {
                        int index = Const.indexOfString(wFilename.getText(), objectnames);
                        if (index >= 0) {
                            dialog.setSelectedNrs(new int[] { index });
                        }
                    }
                    String objectname = dialog.open();
                    if (objectname != null) {
                        wFilename.setText(objectname);
                    }
                } catch (Exception e) {
                    new ErrorDialog(shell, Messages.getString("S3CsvInputDialog.Exception.UnableToGetFiles.Title"), Messages.getString("S3CsvInputDialog.Exception.UnableToGetFiles.Message"), e);
                }
            }
        });
    }
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        @Override
        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    // Set the shell size, based upon previous time...
    setSize();
    getData();
    inputMeta.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) Listener(org.eclipse.swt.widgets.Listener) ComboValuesSelectionListener(org.pentaho.di.ui.core.widget.ComboValuesSelectionListener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) RowMeta(org.pentaho.di.core.row.RowMeta) TableItem(org.eclipse.swt.widgets.TableItem) 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) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) 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) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Text(org.eclipse.swt.widgets.Text) KettleStepException(org.pentaho.di.core.exception.KettleStepException) IOException(java.io.IOException) TextVar(org.pentaho.di.ui.core.widget.TextVar) PasswordTextVar(org.pentaho.di.ui.core.widget.PasswordTextVar) PasswordTextVar(org.pentaho.di.ui.core.widget.PasswordTextVar) ComboValuesSelectionListener(org.pentaho.di.ui.core.widget.ComboValuesSelectionListener) CCombo(org.eclipse.swt.custom.CCombo) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Display(org.eclipse.swt.widgets.Display)

Example 72 with TextVar

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

the class ConnectionForm method layoutGenericConnectionFields.

private void layoutGenericConnectionFields(Control leftOf) {
    wlGenericUrl = new Label(wConnectionGroup, SWT.LEFT);
    props.setLook(wlGenericUrl);
    wlGenericUrl.setText(getString(PKG, "JmsDialog.JmsUrl"));
    FormData fdlJmsUrl = new FormData();
    fdlJmsUrl.left = new FormAttachment(leftOf, 15);
    fdlJmsUrl.top = new FormAttachment(0, 0);
    wlGenericUrl.setLayoutData(fdlJmsUrl);
    wGenericUrl = new TextVar(transMeta, wConnectionGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wGenericUrl.setToolTipText(JmsProvider.ConnectionType.JNDI.getUrlHint());
    props.setLook(wGenericUrl);
    wGenericUrl.addModifyListener(lsMod);
    FormData fdJmsUrl = new FormData();
    fdJmsUrl.left = new FormAttachment(leftOf, 15);
    fdJmsUrl.top = new FormAttachment(wlGenericUrl, 5);
    fdJmsUrl.right = new FormAttachment(100, 0);
    wGenericUrl.setLayoutData(fdJmsUrl);
}
Also used : FormData(org.eclipse.swt.layout.FormData) Label(org.eclipse.swt.widgets.Label) FormAttachment(org.eclipse.swt.layout.FormAttachment) PasswordTextVar(org.pentaho.di.ui.core.widget.PasswordTextVar) TextVar(org.pentaho.di.ui.core.widget.TextVar)

Example 73 with TextVar

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

the class ConnectionForm method layoutActiveMqConnectionFields.

private void layoutActiveMqConnectionFields(Control leftOf) {
    wlActiveUrl = new Label(wConnectionGroup, SWT.LEFT);
    props.setLook(wlActiveUrl);
    wlActiveUrl.setText(getString(PKG, "JmsDialog.JmsUrl"));
    FormData fdlJmsUrl = new FormData();
    fdlJmsUrl.left = new FormAttachment(leftOf, 15);
    fdlJmsUrl.top = new FormAttachment(0, 0);
    wlActiveUrl.setLayoutData(fdlJmsUrl);
    wActiveUrl = new TextVar(transMeta, wConnectionGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wActiveUrl.setToolTipText(JmsProvider.ConnectionType.ACTIVEMQ.getUrlHint());
    props.setLook(wActiveUrl);
    wActiveUrl.addModifyListener(lsMod);
    FormData fdJmsUrl = new FormData();
    fdJmsUrl.left = new FormAttachment(leftOf, 15);
    fdJmsUrl.top = new FormAttachment(wlActiveUrl, 5);
    fdJmsUrl.right = new FormAttachment(100, 0);
    wActiveUrl.setLayoutData(fdJmsUrl);
    wlActiveUser = new Label(wConnectionGroup, SWT.LEFT);
    props.setLook(wlActiveUser);
    wlActiveUser.setText(getString(PKG, "JmsDialog.JmsUser"));
    FormData fdlUser = new FormData();
    fdlUser.left = new FormAttachment(leftOf, 15);
    fdlUser.top = new FormAttachment(wActiveUrl, 10);
    wlActiveUser.setLayoutData(fdlUser);
    wActiveUser = new TextVar(transMeta, wConnectionGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wActiveUser);
    wActiveUser.addModifyListener(lsMod);
    FormData fdUser = new FormData();
    fdUser.left = new FormAttachment(leftOf, 15);
    fdUser.top = new FormAttachment(wlActiveUser, 5);
    fdUser.right = new FormAttachment(100, 0);
    wActiveUser.setLayoutData(fdUser);
    wlActivePassword = new Label(wConnectionGroup, SWT.LEFT);
    props.setLook(wlActivePassword);
    wlActivePassword.setText(getString(PKG, "JmsDialog.JmsPassword"));
    FormData fdlPassword = new FormData();
    fdlPassword.left = new FormAttachment(leftOf, 15);
    fdlPassword.top = new FormAttachment(wActiveUser, 10);
    wlActivePassword.setLayoutData(fdlPassword);
    wActivePassword = new PasswordTextVar(transMeta, wConnectionGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wActivePassword);
    wActivePassword.addModifyListener(lsMod);
    FormData fdPassword = new FormData();
    fdPassword.left = new FormAttachment(leftOf, 15);
    fdPassword.top = new FormAttachment(wlActivePassword, 5);
    fdPassword.right = new FormAttachment(100, 0);
    wActivePassword.setLayoutData(fdPassword);
}
Also used : FormData(org.eclipse.swt.layout.FormData) PasswordTextVar(org.pentaho.di.ui.core.widget.PasswordTextVar) Label(org.eclipse.swt.widgets.Label) FormAttachment(org.eclipse.swt.layout.FormAttachment) PasswordTextVar(org.pentaho.di.ui.core.widget.PasswordTextVar) TextVar(org.pentaho.di.ui.core.widget.TextVar)

Example 74 with TextVar

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

the class ConnectionForm method layoutIbmMqConnectionFields.

private void layoutIbmMqConnectionFields(Control leftOf) {
    wlIbmUrl = new Label(wConnectionGroup, SWT.LEFT);
    props.setLook(wlIbmUrl);
    wlIbmUrl.setText(getString(PKG, "JmsDialog.JmsUrl"));
    FormData fdlJmsUrl = new FormData();
    fdlJmsUrl.left = new FormAttachment(leftOf, 15);
    fdlJmsUrl.top = new FormAttachment(0, 0);
    wlIbmUrl.setLayoutData(fdlJmsUrl);
    wIbmUrl = new TextVar(transMeta, wConnectionGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wIbmUrl.setToolTipText(JmsProvider.ConnectionType.WEBSPHERE.getUrlHint());
    props.setLook(wIbmUrl);
    wIbmUrl.addModifyListener(lsMod);
    FormData fdUrl = new FormData();
    fdUrl.left = new FormAttachment(leftOf, 15);
    fdUrl.top = new FormAttachment(wlIbmUrl, 5);
    fdUrl.right = new FormAttachment(100, 0);
    wIbmUrl.setLayoutData(fdUrl);
    wlIbmUser = new Label(wConnectionGroup, SWT.LEFT);
    props.setLook(wlIbmUser);
    wlIbmUser.setText(getString(PKG, "JmsDialog.JmsUser"));
    FormData fdlUser = new FormData();
    fdlUser.left = new FormAttachment(leftOf, 15);
    fdlUser.top = new FormAttachment(wIbmUrl, 10);
    wlIbmUser.setLayoutData(fdlUser);
    wIbmUser = new TextVar(transMeta, wConnectionGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wIbmUser);
    wIbmUser.addModifyListener(lsMod);
    FormData fdUser = new FormData();
    fdUser.left = new FormAttachment(leftOf, 15);
    fdUser.top = new FormAttachment(wlIbmUser, 5);
    fdUser.right = new FormAttachment(100, 0);
    wIbmUser.setLayoutData(fdUser);
    wlIbmPassword = new Label(wConnectionGroup, SWT.LEFT);
    props.setLook(wlIbmPassword);
    wlIbmPassword.setText(getString(PKG, "JmsDialog.JmsPassword"));
    FormData fdlPassword = new FormData();
    fdlPassword.left = new FormAttachment(leftOf, 15);
    fdlPassword.top = new FormAttachment(wIbmUser, 10);
    wlIbmPassword.setLayoutData(fdlPassword);
    wIbmPassword = new PasswordTextVar(transMeta, wConnectionGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wIbmPassword);
    wIbmPassword.addModifyListener(lsMod);
    FormData fdPassword = new FormData();
    fdPassword.left = new FormAttachment(leftOf, 15);
    fdPassword.top = new FormAttachment(wlIbmPassword, 5);
    fdPassword.right = new FormAttachment(100, 0);
    wIbmPassword.setLayoutData(fdPassword);
}
Also used : FormData(org.eclipse.swt.layout.FormData) PasswordTextVar(org.pentaho.di.ui.core.widget.PasswordTextVar) Label(org.eclipse.swt.widgets.Label) FormAttachment(org.eclipse.swt.layout.FormAttachment) PasswordTextVar(org.pentaho.di.ui.core.widget.PasswordTextVar) TextVar(org.pentaho.di.ui.core.widget.TextVar)

Example 75 with TextVar

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

the class DestinationForm method layoutForm.

public Composite layoutForm() {
    Label lbDestType = new Label(parentComponent, SWT.LEFT);
    props.setLook(lbDestType);
    lbDestType.setText(getString(PKG, "JmsDialog.DestinationType"));
    FormData fdDest = new FormData();
    fdDest.left = new FormAttachment(0, 0);
    fdDest.top = new FormAttachment(aboveComposite, 15);
    fdDest.width = 140;
    lbDestType.setLayoutData(fdDest);
    destinationType = new ComboVar(transMeta, parentComponent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(destinationType);
    destinationType.addModifyListener(lsMod);
    FormData fdDestType = new FormData();
    fdDestType.left = new FormAttachment(0, 0);
    fdDestType.top = new FormAttachment(lbDestType, 5);
    fdDestType.width = 140;
    destinationType.setLayoutData(fdDestType);
    destinationType.add(getString(PKG, "JmsDialog.Dest.Topic"));
    destinationType.add(getString(PKG, "JmsDialog.Dest.Queue"));
    destinationType.addModifyListener(lsMod);
    Label lbDestName = new Label(parentComponent, SWT.LEFT);
    props.setLook(lbDestName);
    lbDestName.setText(getString(PKG, "JmsDialog.Dest.Name"));
    FormData fdlDestName = new FormData();
    fdlDestName.left = new FormAttachment(lbDestType, 15);
    fdlDestName.top = new FormAttachment(aboveComposite, 15);
    fdlDestName.right = new FormAttachment(100, 0);
    lbDestName.setLayoutData(fdlDestName);
    destinationName = new TextVar(transMeta, parentComponent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(destinationName);
    FormData fdDestName = new FormData();
    fdDestName.left = new FormAttachment(destinationType, 15);
    fdDestName.top = new FormAttachment(lbDestName, 5);
    fdDestName.right = new FormAttachment(100, 0);
    destinationName.setLayoutData(fdDestName);
    destinationName.addModifyListener(lsMod);
    setStartingValues();
    return destinationType;
}
Also used : FormData(org.eclipse.swt.layout.FormData) ComboVar(org.pentaho.di.ui.core.widget.ComboVar) Label(org.eclipse.swt.widgets.Label) FormAttachment(org.eclipse.swt.layout.FormAttachment) TextVar(org.pentaho.di.ui.core.widget.TextVar)

Aggregations

TextVar (org.pentaho.di.ui.core.widget.TextVar)240 Label (org.eclipse.swt.widgets.Label)237 FormAttachment (org.eclipse.swt.layout.FormAttachment)236 FormData (org.eclipse.swt.layout.FormData)236 FormLayout (org.eclipse.swt.layout.FormLayout)220 Button (org.eclipse.swt.widgets.Button)207 SelectionEvent (org.eclipse.swt.events.SelectionEvent)196 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)194 Text (org.eclipse.swt.widgets.Text)189 ModifyListener (org.eclipse.swt.events.ModifyListener)186 ModifyEvent (org.eclipse.swt.events.ModifyEvent)184 Listener (org.eclipse.swt.widgets.Listener)184 Shell (org.eclipse.swt.widgets.Shell)184 Event (org.eclipse.swt.widgets.Event)183 ShellAdapter (org.eclipse.swt.events.ShellAdapter)181 ShellEvent (org.eclipse.swt.events.ShellEvent)181 Display (org.eclipse.swt.widgets.Display)181 CCombo (org.eclipse.swt.custom.CCombo)113 Composite (org.eclipse.swt.widgets.Composite)112 CTabItem (org.eclipse.swt.custom.CTabItem)108