Search in sources :

Example 86 with ColumnInfo

use of org.pentaho.di.ui.core.widget.ColumnInfo 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 87 with ColumnInfo

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

the class FieldsTab method getFieldColumns.

private ColumnInfo[] getFieldColumns() {
    ColumnInfo referenceName = new ColumnInfo(BaseMessages.getString(PKG, "JmsConsumerDialog.Column.Ref"), ColumnInfo.COLUMN_TYPE_TEXT, false, true);
    ColumnInfo name = new ColumnInfo(BaseMessages.getString(PKG, "JmsConsumerDialog.Column.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, false);
    ColumnInfo type = new ColumnInfo(BaseMessages.getString(PKG, "JmsConsumerDialog.Column.Type"), ColumnInfo.COLUMN_TYPE_TEXT, false, true);
    return new ColumnInfo[] { referenceName, name, type };
}
Also used : ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo)

Example 88 with ColumnInfo

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

the class MQTTConsumerDialog method getFieldColumns.

private ColumnInfo[] getFieldColumns() {
    ColumnInfo referenceName = new ColumnInfo(BaseMessages.getString(PKG, "MQTTConsumerDialog.Column.Ref"), ColumnInfo.COLUMN_TYPE_TEXT, false, true);
    ColumnInfo name = new ColumnInfo(BaseMessages.getString(PKG, "MQTTConsumerDialog.Column.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, false);
    ColumnInfo type = new ColumnInfo(BaseMessages.getString(PKG, "MQTTConsumerDialog.Column.Type"), ColumnInfo.COLUMN_TYPE_TEXT, false, true);
    return new ColumnInfo[] { referenceName, name, type };
}
Also used : ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo)

Example 89 with ColumnInfo

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

the class MQTTConsumerDialog method buildTopicsTable.

private void buildTopicsTable(Composite parentWidget, Control controlAbove, Control controlBelow) {
    ColumnInfo[] columns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "MQTTConsumerDialog.TopicHeading"), ColumnInfo.COLUMN_TYPE_TEXT, new String[1], false) };
    columns[0].setUsingVariables(true);
    int topicsCount = mqttMeta.getTopics().size();
    topicsTable = new TableView(transMeta, parentWidget, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, columns, topicsCount, false, lsMod, props, false);
    topicsTable.setSortable(false);
    topicsTable.getTable().addListener(SWT.Resize, event -> {
        Table table = (Table) event.widget;
        table.getColumn(1).setWidth(330);
    });
    FormData fdData = new FormData();
    fdData.left = new FormAttachment(0, 0);
    fdData.top = new FormAttachment(controlAbove, 5);
    fdData.right = new FormAttachment(0, 350);
    fdData.bottom = new FormAttachment(controlBelow, -10);
    // resize the columns to fit the data in them
    stream(topicsTable.getTable().getColumns()).forEach(column -> {
        if (column.getWidth() > 0) {
            // don't pack anything with a 0 width, it will resize it to make it visible (like the index column)
            column.setWidth(120);
        }
    });
    topicsTable.setLayoutData(fdData);
}
Also used : FormData(org.eclipse.swt.layout.FormData) Table(org.eclipse.swt.widgets.Table) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) Point(org.eclipse.swt.graphics.Point) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 90 with ColumnInfo

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

the class MqttDialogOptionsLayout method getColumns.

private ColumnInfo[] getColumns() {
    ColumnInfo optionName = new ColumnInfo(BaseMessages.getString(PKG, "MQTTDialog.Options.Column.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, true);
    ColumnInfo optionValue = new ColumnInfo(BaseMessages.getString(PKG, "MQTTDialog.Options.Column.Value"), ColumnInfo.COLUMN_TYPE_TEXT, false, false);
    optionValue.setUsingVariables(true);
    return new ColumnInfo[] { optionName, optionValue };
}
Also used : ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo)

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