Search in sources :

Example 46 with CTabItem

use of org.eclipse.swt.custom.CTabItem in project pentaho-kettle by pentaho.

the class ScriptValuesModDialog 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);
    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, "ScriptValuesDialogMod.Shell.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Filename line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.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);
    wSash = new SashForm(shell, SWT.VERTICAL);
    // Top sash form
    // 
    wTop = new Composite(wSash, SWT.NONE);
    props.setLook(wTop);
    FormLayout topLayout = new FormLayout();
    topLayout.marginWidth = Const.FORM_MARGIN;
    topLayout.marginHeight = Const.FORM_MARGIN;
    wTop.setLayout(topLayout);
    // Script line
    wlScriptFunctions = new Label(wTop, SWT.NONE);
    wlScriptFunctions.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.JavascriptFunctions.Label"));
    props.setLook(wlScriptFunctions);
    fdlScriptFunctions = new FormData();
    fdlScriptFunctions.left = new FormAttachment(0, 0);
    fdlScriptFunctions.top = new FormAttachment(0, 0);
    wlScriptFunctions.setLayoutData(fdlScriptFunctions);
    // Tree View Test
    wTree = new Tree(wTop, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    props.setLook(wTree);
    fdlTree = new FormData();
    fdlTree.left = new FormAttachment(0, 0);
    fdlTree.top = new FormAttachment(wlScriptFunctions, margin);
    fdlTree.right = new FormAttachment(20, 0);
    fdlTree.bottom = new FormAttachment(100, -margin);
    wTree.setLayoutData(fdlTree);
    // Script line
    wlScript = new Label(wTop, SWT.NONE);
    wlScript.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Javascript.Label"));
    props.setLook(wlScript);
    fdlScript = new FormData();
    fdlScript.left = new FormAttachment(wTree, margin);
    fdlScript.top = new FormAttachment(0, 0);
    wlScript.setLayoutData(fdlScript);
    folder = new CTabFolder(wTop, SWT.BORDER | SWT.RESIZE);
    folder.setSimple(false);
    folder.setUnselectedImageVisible(true);
    folder.setUnselectedCloseVisible(true);
    fdScript = new FormData();
    fdScript.left = new FormAttachment(wTree, margin);
    fdScript.top = new FormAttachment(wlScript, margin);
    fdScript.right = new FormAttachment(100, -5);
    fdScript.bottom = new FormAttachment(100, -50);
    folder.setLayoutData(fdScript);
    wlPosition = new Label(wTop, SWT.NONE);
    wlPosition.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Position.Label"));
    props.setLook(wlPosition);
    fdlPosition = new FormData();
    fdlPosition.left = new FormAttachment(wTree, margin);
    fdlPosition.right = new FormAttachment(30, 0);
    fdlPosition.top = new FormAttachment(folder, margin);
    wlPosition.setLayoutData(fdlPosition);
    Label wlCompatible = new Label(wTop, SWT.NONE);
    wlCompatible.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Compatible.Label"));
    props.setLook(wlCompatible);
    FormData fdlCompatible = new FormData();
    fdlCompatible.left = new FormAttachment(wTree, margin);
    fdlCompatible.right = new FormAttachment(middle, 0);
    fdlCompatible.top = new FormAttachment(wlPosition, margin);
    wlCompatible.setLayoutData(fdlCompatible);
    wCompatible = new Button(wTop, SWT.CHECK);
    wCompatible.setToolTipText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Compatible.Tooltip"));
    props.setLook(wCompatible);
    FormData fdCompatible = new FormData();
    fdCompatible.left = new FormAttachment(wlCompatible, margin);
    fdCompatible.top = new FormAttachment(wlPosition, margin);
    wCompatible.setLayoutData(fdCompatible);
    wCompatible.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            setInputOutputFields();
            input.setChanged(true);
        }
    });
    Label wlOptimizationLevel = new Label(wTop, SWT.NONE);
    wlOptimizationLevel.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.OptimizationLevel.Label"));
    props.setLook(wlOptimizationLevel);
    FormData fdlOptimizationLevel = new FormData();
    fdlOptimizationLevel.left = new FormAttachment(wCompatible, margin * 2);
    fdlOptimizationLevel.top = new FormAttachment(wlPosition, margin);
    wlOptimizationLevel.setLayoutData(fdlOptimizationLevel);
    wOptimizationLevel = new TextVar(transMeta, wTop, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wOptimizationLevel.setToolTipText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.OptimizationLevel.Tooltip"));
    props.setLook(wOptimizationLevel);
    FormData fdOptimizationLevel = new FormData();
    fdOptimizationLevel.left = new FormAttachment(wlOptimizationLevel, margin);
    fdOptimizationLevel.top = new FormAttachment(wlPosition, margin);
    fdOptimizationLevel.right = new FormAttachment(100, margin);
    wOptimizationLevel.setLayoutData(fdOptimizationLevel);
    wOptimizationLevel.addModifyListener(lsMod);
    wlHelpLabel = new Text(wTop, SWT.V_SCROLL | SWT.LEFT);
    wlHelpLabel.setEditable(false);
    wlHelpLabel.setText("Hallo");
    props.setLook(wlHelpLabel);
    fdHelpLabel = new FormData();
    fdHelpLabel.left = new FormAttachment(wlPosition, margin);
    fdHelpLabel.top = new FormAttachment(folder, margin);
    fdHelpLabel.right = new FormAttachment(100, -5);
    fdHelpLabel.bottom = new FormAttachment(100, 0);
    wlHelpLabel.setLayoutData(fdHelpLabel);
    wlHelpLabel.setVisible(false);
    fdTop = new FormData();
    fdTop.left = new FormAttachment(0, 0);
    fdTop.top = new FormAttachment(0, 0);
    fdTop.right = new FormAttachment(100, 0);
    fdTop.bottom = new FormAttachment(100, 0);
    wTop.setLayoutData(fdTop);
    wBottom = new Composite(wSash, SWT.NONE);
    props.setLook(wBottom);
    FormLayout bottomLayout = new FormLayout();
    bottomLayout.marginWidth = Const.FORM_MARGIN;
    bottomLayout.marginHeight = Const.FORM_MARGIN;
    wBottom.setLayout(bottomLayout);
    wSeparator = new Label(wBottom, SWT.SEPARATOR | SWT.HORIZONTAL);
    fdSeparator = new FormData();
    fdSeparator.left = new FormAttachment(0, 0);
    fdSeparator.right = new FormAttachment(100, 0);
    fdSeparator.top = new FormAttachment(0, -margin + 2);
    wSeparator.setLayoutData(fdSeparator);
    wlFields = new Label(wBottom, SWT.NONE);
    wlFields.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Fields.Label"));
    props.setLook(wlFields);
    fdlFields = new FormData();
    fdlFields.left = new FormAttachment(0, 0);
    fdlFields.top = new FormAttachment(wSeparator, 0);
    wlFields.setLayoutData(fdlFields);
    final int FieldsRows = input.getFieldname().length;
    ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ColumnInfo.Filename"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ColumnInfo.RenameTo"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ColumnInfo.Type"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames()), new ColumnInfo(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ColumnInfo.Length"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ColumnInfo.Precision"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ColumnInfo.Replace"), ColumnInfo.COLUMN_TYPE_CCOMBO, YES_NO_COMBO) };
    wFields = new TableView(transMeta, wBottom, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
    fdFields = new FormData();
    fdFields.left = new FormAttachment(0, 0);
    fdFields.top = new FormAttachment(wlFields, margin);
    fdFields.right = new FormAttachment(100, 0);
    fdFields.bottom = new FormAttachment(100, 0);
    wFields.setLayoutData(fdFields);
    fdBottom = new FormData();
    fdBottom.left = new FormAttachment(0, 0);
    fdBottom.top = new FormAttachment(0, 0);
    fdBottom.right = new FormAttachment(100, 0);
    fdBottom.bottom = new FormAttachment(100, 0);
    wBottom.setLayoutData(fdBottom);
    fdSash = new FormData();
    fdSash.left = new FormAttachment(0, 0);
    fdSash.top = new FormAttachment(wStepname, 0);
    fdSash.right = new FormAttachment(100, 0);
    fdSash.bottom = new FormAttachment(100, -50);
    wSash.setLayoutData(fdSash);
    wSash.setWeights(new int[] { 75, 25 });
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wVars = new Button(shell, SWT.PUSH);
    wVars.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.GetVariables.Button"));
    wTest = new Button(shell, SWT.PUSH);
    wTest.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.TestScript.Button"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    setButtonPositions(new Button[] { wOK, wCancel, wVars, wTest }, margin, null);
    // Add listeners
    lsCancel = new Listener() {

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

        public void handleEvent(Event e) {
            newTest();
        }
    };
    lsVars = new Listener() {

        public void handleEvent(Event e) {
            test(true, true);
        }
    };
    lsOK = new Listener() {

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

        public void handleEvent(Event e) {
            treeDblClick(e);
        }
    };
    // lsHelp = new Listener(){public void handleEvent(Event e){ wlHelpLabel.setVisible(true); }};
    wCancel.addListener(SWT.Selection, lsCancel);
    // wGet.addListener (SWT.Selection, lsGet );
    wTest.addListener(SWT.Selection, lsTest);
    wVars.addListener(SWT.Selection, lsVars);
    wOK.addListener(SWT.Selection, lsOK);
    wTree.addListener(SWT.MouseDoubleClick, lsTree);
    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) {
            if (!cancel()) {
                e.doit = false;
            }
        }
    });
    folder.addCTabFolder2Listener(new CTabFolder2Adapter() {

        public void close(CTabFolderEvent event) {
            CTabItem cItem = (CTabItem) event.item;
            event.doit = false;
            if (cItem != null && folder.getItemCount() > 1) {
                MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | SWT.YES);
                messageBox.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.DeleteItem.Label"));
                messageBox.setMessage(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ConfirmDeleteItem.Label", cItem.getText()));
                switch(messageBox.open()) {
                    case SWT.YES:
                        modifyScriptTree(cItem, DELETE_ITEM);
                        event.doit = true;
                        break;
                    default:
                        break;
                }
            }
        }
    });
    cMenu = new Menu(shell, SWT.POP_UP);
    buildingFolderMenu();
    tMenu = new Menu(shell, SWT.POP_UP);
    buildingTreeMenu();
    // Adding the Default Transform Scripts Item to the Tree
    wTreeScriptsItem = new TreeItem(wTree, SWT.NULL);
    wTreeScriptsItem.setImage(guiresource.getImageBol());
    wTreeScriptsItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.TransformScript.Label"));
    // Set the shell size, based upon previous time...
    setSize();
    getData();
    // Adding the Rest (Functions, InputItems, etc.) to the Tree
    buildSpecialFunctionsTree();
    // Input Fields
    iteminput = new TreeItem(wTree, SWT.NULL);
    iteminput.setImage(imageInputFields);
    iteminput.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.InputFields.Label"));
    // Output Fields
    itemoutput = new TreeItem(wTree, SWT.NULL);
    itemoutput.setImage(imageOutputFields);
    itemoutput.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.OutputFields.Label"));
    // Display waiting message for input
    itemWaitFieldsIn = new TreeItem(iteminput, SWT.NULL);
    itemWaitFieldsIn.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.GettingFields.Label"));
    itemWaitFieldsIn.setForeground(guiresource.getColorDirectory());
    iteminput.setExpanded(true);
    // Display waiting message for output
    itemWaitFieldsOut = new TreeItem(itemoutput, SWT.NULL);
    itemWaitFieldsOut.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.GettingFields.Label"));
    itemWaitFieldsOut.setForeground(guiresource.getColorDirectory());
    itemoutput.setExpanded(true);
    // 
    // Search the fields in the background
    // 
    final Runnable runnable = new Runnable() {

        public void run() {
            StepMeta stepMeta = transMeta.findStep(stepname);
            if (stepMeta != null) {
                try {
                    rowPrevStepFields = transMeta.getPrevStepFields(stepMeta);
                    if (rowPrevStepFields != null) {
                        setInputOutputFields();
                    } else {
                        // Can not get fields...end of wait message
                        iteminput.removeAll();
                        itemoutput.removeAll();
                    }
                } catch (KettleException e) {
                    logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
                }
            }
        }
    };
    new Thread(runnable).start();
    // rebuildInputFieldsTree();
    // buildOutputFieldsTree();
    buildAddClassesListTree();
    addRenameTowTreeScriptItems();
    input.setChanged(changed);
    // Create the drag source on the tree
    DragSource ds = new DragSource(wTree, DND.DROP_MOVE);
    ds.setTransfer(new Transfer[] { TextTransfer.getInstance() });
    ds.addDragListener(new DragSourceAdapter() {

        public void dragStart(DragSourceEvent event) {
            TreeItem item = wTree.getSelection()[0];
            // Qualifikation where the Drag Request Comes from
            if (item != null && item.getParentItem() != null) {
                if (item.getParentItem().equals(wTreeScriptsItem)) {
                    event.doit = false;
                } else if (!item.getData().equals("Function")) {
                    String strInsert = (String) item.getData();
                    if (strInsert.equals("jsFunction")) {
                        event.doit = true;
                    } else {
                        event.doit = false;
                    }
                } else {
                    event.doit = false;
                }
            } else {
                event.doit = false;
            }
        }

        public void dragSetData(DragSourceEvent event) {
            // Set the data to be the first selected item's text
            event.data = wTree.getSelection()[0].getText();
        }
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) CTabFolder(org.eclipse.swt.custom.CTabFolder) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) TreeItem(org.eclipse.swt.widgets.TreeItem) 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) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) Menu(org.eclipse.swt.widgets.Menu) 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) DragSourceAdapter(org.eclipse.swt.dnd.DragSourceAdapter) ShellAdapter(org.eclipse.swt.events.ShellAdapter) CTabFolder2Adapter(org.eclipse.swt.custom.CTabFolder2Adapter) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) CTabFolderEvent(org.eclipse.swt.custom.CTabFolderEvent) DragSource(org.eclipse.swt.dnd.DragSource) 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) MessageBox(org.eclipse.swt.widgets.MessageBox) SashForm(org.eclipse.swt.custom.SashForm) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CTabFolderEvent(org.eclipse.swt.custom.CTabFolderEvent) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) 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 47 with CTabItem

use of org.eclipse.swt.custom.CTabItem in project pentaho-kettle by pentaho.

the class SimpleMappingDialog method addMappingDefinitionTab.

private void addMappingDefinitionTab(final MappingIODefinition definition, int index, final String tabTitle, final String tabTooltip, String sourceColumnLabel, String targetColumnLabel, final boolean input) {
    final CTabItem wTab;
    if (index >= wTabFolder.getItemCount()) {
        wTab = new CTabItem(wTabFolder, SWT.CLOSE);
    } else {
        wTab = new CTabItem(wTabFolder, SWT.CLOSE, index);
    }
    setMappingDefinitionTabNameAndToolTip(wTab, tabTitle, tabTooltip, definition, input);
    Composite wInputComposite = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wInputComposite);
    FormLayout tabLayout = new FormLayout();
    tabLayout.marginWidth = 15;
    tabLayout.marginHeight = 15;
    wInputComposite.setLayout(tabLayout);
    // Now add a table view with the 2 columns to specify: input and output
    // fields for the source and target steps.
    // 
    final Button wbEnterMapping = new Button(wInputComposite, SWT.PUSH);
    props.setLook(wbEnterMapping);
    if (input) {
        wbEnterMapping.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.button.EnterMapping"));
    } else {
        wbEnterMapping.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.button.GetFields"));
    }
    FormData fdbEnterMapping = new FormData();
    fdbEnterMapping.bottom = new FormAttachment(100);
    fdbEnterMapping.right = new FormAttachment(100);
    wbEnterMapping.setLayoutData(fdbEnterMapping);
    ColumnInfo[] colinfo = new ColumnInfo[] { new ColumnInfo(sourceColumnLabel, ColumnInfo.COLUMN_TYPE_TEXT, false, false), new ColumnInfo(targetColumnLabel, ColumnInfo.COLUMN_TYPE_TEXT, false, false) };
    final TableView wFieldMappings = new TableView(transMeta, wInputComposite, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER, colinfo, 1, false, lsMod, props, false);
    props.setLook(wFieldMappings);
    FormData fdMappings = new FormData();
    fdMappings.left = new FormAttachment(0);
    fdMappings.right = new FormAttachment(100);
    fdMappings.top = new FormAttachment(0);
    fdMappings.bottom = new FormAttachment(wbEnterMapping, -10);
    wFieldMappings.setLayoutData(fdMappings);
    wFieldMappings.getTable().addListener(SWT.Resize, new ColumnsResizer(0, 50, 50));
    for (MappingValueRename valueRename : definition.getValueRenames()) {
        TableItem tableItem = new TableItem(wFieldMappings.table, SWT.NONE);
        tableItem.setText(1, Const.NVL(valueRename.getSourceValueName(), ""));
        tableItem.setText(2, Const.NVL(valueRename.getTargetValueName(), ""));
    }
    wFieldMappings.removeEmptyRows();
    wFieldMappings.setRowNums();
    wFieldMappings.optWidth(true);
    wbEnterMapping.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            try {
                if (input) {
                    // INPUT
                    // 
                    RowMetaInterface sourceRowMeta = getFieldsFromStep(true, input);
                    RowMetaInterface targetRowMeta = getFieldsFromStep(false, input);
                    String[] sourceFields = sourceRowMeta.getFieldNames();
                    String[] targetFields = targetRowMeta.getFieldNames();
                    EnterMappingDialog dialog = new EnterMappingDialog(shell, sourceFields, targetFields);
                    List<SourceToTargetMapping> mappings = dialog.open();
                    if (mappings != null) {
                        // first clear the dialog...
                        wFieldMappings.clearAll(false);
                        // 
                        definition.getValueRenames().clear();
                        // Now add the new values...
                        for (int i = 0; i < mappings.size(); i++) {
                            SourceToTargetMapping mapping = mappings.get(i);
                            TableItem item = new TableItem(wFieldMappings.table, SWT.NONE);
                            item.setText(1, mapping.getSourceString(sourceFields));
                            item.setText(2, mapping.getTargetString(targetFields));
                            String source = input ? item.getText(1) : item.getText(2);
                            String target = input ? item.getText(2) : item.getText(1);
                            definition.getValueRenames().add(new MappingValueRename(source, target));
                        }
                        wFieldMappings.removeEmptyRows();
                        wFieldMappings.setRowNums();
                        wFieldMappings.optWidth(true);
                    }
                } else {
                    // OUTPUT
                    // 
                    RowMetaInterface sourceRowMeta = getFieldsFromStep(true, input);
                    BaseStepDialog.getFieldsFromPrevious(sourceRowMeta, wFieldMappings, 1, new int[] { 1 }, new int[] {}, -1, -1, null);
                }
            } catch (KettleException e) {
                new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "SimpleMappingDialog.Exception.ErrorGettingMappingSourceAndTargetFields", e.toString()), e);
            }
        }
    });
    if (input) {
        Button wRenameOutput = new Button(wInputComposite, SWT.CHECK);
        props.setLook(wRenameOutput);
        wRenameOutput.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.input.RenamingOnOutput"));
        FormData fdRenameOutput = new FormData();
        fdRenameOutput.top = new FormAttachment(wFieldMappings, 10);
        fdRenameOutput.left = new FormAttachment(0, 0);
        wRenameOutput.setLayoutData(fdRenameOutput);
        wRenameOutput.setSelection(definition.isRenamingOnOutput());
        wRenameOutput.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent event) {
                // flip the switch
                definition.setRenamingOnOutput(!definition.isRenamingOnOutput());
            }
        });
    }
    FormData fdParametersComposite = new FormData();
    fdParametersComposite.left = new FormAttachment(0, 0);
    fdParametersComposite.top = new FormAttachment(0, 0);
    fdParametersComposite.right = new FormAttachment(100, 0);
    fdParametersComposite.bottom = new FormAttachment(100, 0);
    wInputComposite.setLayoutData(fdParametersComposite);
    wInputComposite.layout();
    wTab.setControl(wInputComposite);
    final ApplyChanges applyChanges = new MappingDefinitionTab(definition, wFieldMappings);
    changeList.add(applyChanges);
    wTabFolder.setSelection(wTab);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) MappingValueRename(org.pentaho.di.trans.steps.mapping.MappingValueRename) KettleException(org.pentaho.di.core.exception.KettleException) Composite(org.eclipse.swt.widgets.Composite) ColumnsResizer(org.pentaho.di.ui.core.widget.ColumnsResizer) EnterMappingDialog(org.pentaho.di.ui.core.dialog.EnterMappingDialog) TableItem(org.eclipse.swt.widgets.TableItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) CTabItem(org.eclipse.swt.custom.CTabItem) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SourceToTargetMapping(org.pentaho.di.core.SourceToTargetMapping) List(java.util.List) ArrayList(java.util.ArrayList) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 48 with CTabItem

use of org.eclipse.swt.custom.CTabItem in project pentaho-kettle by pentaho.

the class TextFileInputDialog method addContentTab.

private void addContentTab() {
    // ////////////////////////
    // START OF CONTENT TAB///
    // /
    wContentTab = new CTabItem(wTabFolder, SWT.NONE);
    wContentTab.setText(BaseMessages.getString(PKG, "TextFileInputDialog.ContentTab.TabTitle"));
    FormLayout contentLayout = new FormLayout();
    contentLayout.marginWidth = 3;
    contentLayout.marginHeight = 3;
    wContentSComp = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL);
    wContentSComp.setLayout(new FillLayout());
    wContentComp = new Composite(wContentSComp, SWT.NONE);
    props.setLook(wContentComp);
    wContentComp.setLayout(contentLayout);
    // Filetype line
    wlFiletype = new Label(wContentComp, SWT.RIGHT);
    wlFiletype.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Filetype.Label"));
    props.setLook(wlFiletype);
    fdlFiletype = new FormData();
    fdlFiletype.left = new FormAttachment(0, 0);
    fdlFiletype.top = new FormAttachment(0, 0);
    fdlFiletype.right = new FormAttachment(middle, -margin);
    wlFiletype.setLayoutData(fdlFiletype);
    wFiletype = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
    wFiletype.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Filetype.Label"));
    props.setLook(wFiletype);
    wFiletype.add("CSV");
    wFiletype.add("Fixed");
    wFiletype.select(0);
    wFiletype.addModifyListener(lsMod);
    fdFiletype = new FormData();
    fdFiletype.left = new FormAttachment(middle, 0);
    fdFiletype.top = new FormAttachment(0, 0);
    fdFiletype.right = new FormAttachment(100, 0);
    wFiletype.setLayoutData(fdFiletype);
    wlSeparator = new Label(wContentComp, SWT.RIGHT);
    wlSeparator.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Separator.Label"));
    props.setLook(wlSeparator);
    fdlSeparator = new FormData();
    fdlSeparator.left = new FormAttachment(0, 0);
    fdlSeparator.top = new FormAttachment(wFiletype, margin);
    fdlSeparator.right = new FormAttachment(middle, -margin);
    wlSeparator.setLayoutData(fdlSeparator);
    wbSeparator = new Button(wContentComp, SWT.PUSH | SWT.CENTER);
    wbSeparator.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Delimiter.Button"));
    props.setLook(wbSeparator);
    fdbSeparator = new FormData();
    fdbSeparator.right = new FormAttachment(100, 0);
    fdbSeparator.top = new FormAttachment(wFiletype, 0);
    wbSeparator.setLayoutData(fdbSeparator);
    wSeparator = new TextVar(transMeta, wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wSeparator);
    wSeparator.addModifyListener(lsMod);
    fdSeparator = new FormData();
    fdSeparator.top = new FormAttachment(wFiletype, margin);
    fdSeparator.left = new FormAttachment(middle, 0);
    fdSeparator.right = new FormAttachment(wbSeparator, -margin);
    wSeparator.setLayoutData(fdSeparator);
    // Enclosure
    wlEnclosure = new Label(wContentComp, SWT.RIGHT);
    wlEnclosure.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Enclosure.Label"));
    props.setLook(wlEnclosure);
    fdlEnclosure = new FormData();
    fdlEnclosure.left = new FormAttachment(0, 0);
    fdlEnclosure.top = new FormAttachment(wSeparator, margin);
    fdlEnclosure.right = new FormAttachment(middle, -margin);
    wlEnclosure.setLayoutData(fdlEnclosure);
    wEnclosure = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wEnclosure);
    wEnclosure.addModifyListener(lsMod);
    fdEnclosure = new FormData();
    fdEnclosure.left = new FormAttachment(middle, 0);
    fdEnclosure.top = new FormAttachment(wSeparator, margin);
    fdEnclosure.right = new FormAttachment(100, 0);
    wEnclosure.setLayoutData(fdEnclosure);
    // Allow Enclosure breaks checkbox
    wlEnclBreaks = new Label(wContentComp, SWT.RIGHT);
    wlEnclBreaks.setText(BaseMessages.getString(PKG, "TextFileInputDialog.EnclBreaks.Label"));
    props.setLook(wlEnclBreaks);
    fdlEnclBreaks = new FormData();
    fdlEnclBreaks.left = new FormAttachment(0, 0);
    fdlEnclBreaks.top = new FormAttachment(wEnclosure, margin);
    fdlEnclBreaks.right = new FormAttachment(middle, -margin);
    wlEnclBreaks.setLayoutData(fdlEnclBreaks);
    wEnclBreaks = new Button(wContentComp, SWT.CHECK);
    props.setLook(wEnclBreaks);
    fdEnclBreaks = new FormData();
    fdEnclBreaks.left = new FormAttachment(middle, 0);
    fdEnclBreaks.top = new FormAttachment(wEnclosure, margin);
    wEnclBreaks.setLayoutData(fdEnclBreaks);
    // Disable until the logic works...
    wlEnclBreaks.setEnabled(false);
    wEnclBreaks.setEnabled(false);
    // Escape
    wlEscape = new Label(wContentComp, SWT.RIGHT);
    wlEscape.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Escape.Label"));
    props.setLook(wlEscape);
    fdlEscape = new FormData();
    fdlEscape.left = new FormAttachment(0, 0);
    fdlEscape.top = new FormAttachment(wEnclBreaks, margin);
    fdlEscape.right = new FormAttachment(middle, -margin);
    wlEscape.setLayoutData(fdlEscape);
    wEscape = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wEscape);
    wEscape.addModifyListener(lsMod);
    fdEscape = new FormData();
    fdEscape.left = new FormAttachment(middle, 0);
    fdEscape.top = new FormAttachment(wEnclBreaks, margin);
    fdEscape.right = new FormAttachment(100, 0);
    wEscape.setLayoutData(fdEscape);
    // Header checkbox
    wlHeader = new Label(wContentComp, SWT.RIGHT);
    wlHeader.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Header.Label"));
    props.setLook(wlHeader);
    fdlHeader = new FormData();
    fdlHeader.left = new FormAttachment(0, 0);
    fdlHeader.top = new FormAttachment(wEscape, margin);
    fdlHeader.right = new FormAttachment(middle, -margin);
    wlHeader.setLayoutData(fdlHeader);
    wHeader = new Button(wContentComp, SWT.CHECK);
    props.setLook(wHeader);
    fdHeader = new FormData();
    fdHeader.left = new FormAttachment(middle, 0);
    fdHeader.top = new FormAttachment(wEscape, margin);
    wHeader.setLayoutData(fdHeader);
    // NrHeader
    wlNrHeader = new Label(wContentComp, SWT.RIGHT);
    wlNrHeader.setText(BaseMessages.getString(PKG, "TextFileInputDialog.NrHeader.Label"));
    props.setLook(wlNrHeader);
    fdlNrHeader = new FormData();
    fdlNrHeader.left = new FormAttachment(wHeader, margin);
    fdlNrHeader.top = new FormAttachment(wEscape, margin);
    wlNrHeader.setLayoutData(fdlNrHeader);
    wNrHeader = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wNrHeader.setTextLimit(3);
    props.setLook(wNrHeader);
    wNrHeader.addModifyListener(lsMod);
    fdNrHeader = new FormData();
    fdNrHeader.left = new FormAttachment(wlNrHeader, margin);
    fdNrHeader.top = new FormAttachment(wEscape, margin);
    fdNrHeader.right = new FormAttachment(100, 0);
    wNrHeader.setLayoutData(fdNrHeader);
    wlFooter = new Label(wContentComp, SWT.RIGHT);
    wlFooter.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Footer.Label"));
    props.setLook(wlFooter);
    fdlFooter = new FormData();
    fdlFooter.left = new FormAttachment(0, 0);
    fdlFooter.top = new FormAttachment(wHeader, margin);
    fdlFooter.right = new FormAttachment(middle, -margin);
    wlFooter.setLayoutData(fdlFooter);
    wFooter = new Button(wContentComp, SWT.CHECK);
    props.setLook(wFooter);
    fdFooter = new FormData();
    fdFooter.left = new FormAttachment(middle, 0);
    fdFooter.top = new FormAttachment(wHeader, margin);
    wFooter.setLayoutData(fdFooter);
    // NrFooter
    wlNrFooter = new Label(wContentComp, SWT.RIGHT);
    wlNrFooter.setText(BaseMessages.getString(PKG, "TextFileInputDialog.NrFooter.Label"));
    props.setLook(wlNrFooter);
    fdlNrFooter = new FormData();
    fdlNrFooter.left = new FormAttachment(wFooter, margin);
    fdlNrFooter.top = new FormAttachment(wHeader, margin);
    wlNrFooter.setLayoutData(fdlNrFooter);
    wNrFooter = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wNrFooter.setTextLimit(3);
    props.setLook(wNrFooter);
    wNrFooter.addModifyListener(lsMod);
    fdNrFooter = new FormData();
    fdNrFooter.left = new FormAttachment(wlNrFooter, margin);
    fdNrFooter.top = new FormAttachment(wHeader, margin);
    fdNrFooter.right = new FormAttachment(100, 0);
    wNrFooter.setLayoutData(fdNrFooter);
    // Wraps
    wlWraps = new Label(wContentComp, SWT.RIGHT);
    wlWraps.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Wraps.Label"));
    props.setLook(wlWraps);
    fdlWraps = new FormData();
    fdlWraps.left = new FormAttachment(0, 0);
    fdlWraps.top = new FormAttachment(wFooter, margin);
    fdlWraps.right = new FormAttachment(middle, -margin);
    wlWraps.setLayoutData(fdlWraps);
    wWraps = new Button(wContentComp, SWT.CHECK);
    props.setLook(wWraps);
    fdWraps = new FormData();
    fdWraps.left = new FormAttachment(middle, 0);
    fdWraps.top = new FormAttachment(wFooter, margin);
    wWraps.setLayoutData(fdWraps);
    // NrWraps
    wlNrWraps = new Label(wContentComp, SWT.RIGHT);
    wlNrWraps.setText(BaseMessages.getString(PKG, "TextFileInputDialog.NrWraps.Label"));
    props.setLook(wlNrWraps);
    fdlNrWraps = new FormData();
    fdlNrWraps.left = new FormAttachment(wWraps, margin);
    fdlNrWraps.top = new FormAttachment(wFooter, margin);
    wlNrWraps.setLayoutData(fdlNrWraps);
    wNrWraps = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wNrWraps.setTextLimit(3);
    props.setLook(wNrWraps);
    wNrWraps.addModifyListener(lsMod);
    fdNrWraps = new FormData();
    fdNrWraps.left = new FormAttachment(wlNrWraps, margin);
    fdNrWraps.top = new FormAttachment(wFooter, margin);
    fdNrWraps.right = new FormAttachment(100, 0);
    wNrWraps.setLayoutData(fdNrWraps);
    // Pages
    wlLayoutPaged = new Label(wContentComp, SWT.RIGHT);
    wlLayoutPaged.setText(BaseMessages.getString(PKG, "TextFileInputDialog.LayoutPaged.Label"));
    props.setLook(wlLayoutPaged);
    fdlLayoutPaged = new FormData();
    fdlLayoutPaged.left = new FormAttachment(0, 0);
    fdlLayoutPaged.top = new FormAttachment(wWraps, margin);
    fdlLayoutPaged.right = new FormAttachment(middle, -margin);
    wlLayoutPaged.setLayoutData(fdlLayoutPaged);
    wLayoutPaged = new Button(wContentComp, SWT.CHECK);
    props.setLook(wLayoutPaged);
    fdLayoutPaged = new FormData();
    fdLayoutPaged.left = new FormAttachment(middle, 0);
    fdLayoutPaged.top = new FormAttachment(wWraps, margin);
    wLayoutPaged.setLayoutData(fdLayoutPaged);
    // Nr of lines per page
    wlNrLinesPerPage = new Label(wContentComp, SWT.RIGHT);
    wlNrLinesPerPage.setText(BaseMessages.getString(PKG, "TextFileInputDialog.NrLinesPerPage.Label"));
    props.setLook(wlNrLinesPerPage);
    fdlNrLinesPerPage = new FormData();
    fdlNrLinesPerPage.left = new FormAttachment(wLayoutPaged, margin);
    fdlNrLinesPerPage.top = new FormAttachment(wWraps, margin);
    wlNrLinesPerPage.setLayoutData(fdlNrLinesPerPage);
    wNrLinesPerPage = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wNrLinesPerPage.setTextLimit(3);
    props.setLook(wNrLinesPerPage);
    wNrLinesPerPage.addModifyListener(lsMod);
    fdNrLinesPerPage = new FormData();
    fdNrLinesPerPage.left = new FormAttachment(wlNrLinesPerPage, margin);
    fdNrLinesPerPage.top = new FormAttachment(wWraps, margin);
    fdNrLinesPerPage.right = new FormAttachment(100, 0);
    wNrLinesPerPage.setLayoutData(fdNrLinesPerPage);
    // NrPages
    wlNrLinesDocHeader = new Label(wContentComp, SWT.RIGHT);
    wlNrLinesDocHeader.setText(BaseMessages.getString(PKG, "TextFileInputDialog.NrLinesDocHeader.Label"));
    props.setLook(wlNrLinesDocHeader);
    fdlNrLinesDocHeader = new FormData();
    fdlNrLinesDocHeader.left = new FormAttachment(wLayoutPaged, margin);
    fdlNrLinesDocHeader.top = new FormAttachment(wNrLinesPerPage, margin);
    wlNrLinesDocHeader.setLayoutData(fdlNrLinesDocHeader);
    wNrLinesDocHeader = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wNrLinesDocHeader.setTextLimit(3);
    props.setLook(wNrLinesDocHeader);
    wNrLinesDocHeader.addModifyListener(lsMod);
    fdNrLinesDocHeader = new FormData();
    fdNrLinesDocHeader.left = new FormAttachment(wlNrLinesPerPage, margin);
    fdNrLinesDocHeader.top = new FormAttachment(wNrLinesPerPage, margin);
    fdNrLinesDocHeader.right = new FormAttachment(100, 0);
    wNrLinesDocHeader.setLayoutData(fdNrLinesDocHeader);
    // Compression type (None, Zip or GZip
    wlCompression = new Label(wContentComp, SWT.RIGHT);
    wlCompression.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Compression.Label"));
    props.setLook(wlCompression);
    fdlCompression = new FormData();
    fdlCompression.left = new FormAttachment(0, 0);
    fdlCompression.top = new FormAttachment(wNrLinesDocHeader, margin);
    fdlCompression.right = new FormAttachment(middle, -margin);
    wlCompression.setLayoutData(fdlCompression);
    wCompression = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
    wCompression.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Compression.Label"));
    wCompression.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.Compression.Tooltip"));
    props.setLook(wCompression);
    wCompression.setItems(CompressionProviderFactory.getInstance().getCompressionProviderNames());
    wCompression.addModifyListener(lsMod);
    fdCompression = new FormData();
    fdCompression.left = new FormAttachment(middle, 0);
    fdCompression.top = new FormAttachment(wNrLinesDocHeader, margin);
    fdCompression.right = new FormAttachment(100, 0);
    wCompression.setLayoutData(fdCompression);
    wlNoempty = new Label(wContentComp, SWT.RIGHT);
    wlNoempty.setText(BaseMessages.getString(PKG, "TextFileInputDialog.NoEmpty.Label"));
    props.setLook(wlNoempty);
    fdlNoempty = new FormData();
    fdlNoempty.left = new FormAttachment(0, 0);
    fdlNoempty.top = new FormAttachment(wCompression, margin);
    fdlNoempty.right = new FormAttachment(middle, -margin);
    wlNoempty.setLayoutData(fdlNoempty);
    wNoempty = new Button(wContentComp, SWT.CHECK);
    props.setLook(wNoempty);
    wNoempty.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.NoEmpty.Tooltip"));
    fdNoempty = new FormData();
    fdNoempty.left = new FormAttachment(middle, 0);
    fdNoempty.top = new FormAttachment(wCompression, margin);
    fdNoempty.right = new FormAttachment(100, 0);
    wNoempty.setLayoutData(fdNoempty);
    wlInclFilename = new Label(wContentComp, SWT.RIGHT);
    wlInclFilename.setText(BaseMessages.getString(PKG, "TextFileInputDialog.InclFilename.Label"));
    props.setLook(wlInclFilename);
    fdlInclFilename = new FormData();
    fdlInclFilename.left = new FormAttachment(0, 0);
    fdlInclFilename.top = new FormAttachment(wNoempty, margin);
    fdlInclFilename.right = new FormAttachment(middle, -margin);
    wlInclFilename.setLayoutData(fdlInclFilename);
    wInclFilename = new Button(wContentComp, SWT.CHECK);
    props.setLook(wInclFilename);
    wInclFilename.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.InclFilename.Tooltip"));
    fdInclFilename = new FormData();
    fdInclFilename.left = new FormAttachment(middle, 0);
    fdInclFilename.top = new FormAttachment(wNoempty, margin);
    wInclFilename.setLayoutData(fdInclFilename);
    wlInclFilenameField = new Label(wContentComp, SWT.LEFT);
    wlInclFilenameField.setText(BaseMessages.getString(PKG, "TextFileInputDialog.InclFilenameField.Label"));
    props.setLook(wlInclFilenameField);
    fdlInclFilenameField = new FormData();
    fdlInclFilenameField.left = new FormAttachment(wInclFilename, margin);
    fdlInclFilenameField.top = new FormAttachment(wNoempty, margin);
    wlInclFilenameField.setLayoutData(fdlInclFilenameField);
    wInclFilenameField = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wInclFilenameField);
    wInclFilenameField.addModifyListener(lsMod);
    fdInclFilenameField = new FormData();
    fdInclFilenameField.left = new FormAttachment(wlInclFilenameField, margin);
    fdInclFilenameField.top = new FormAttachment(wNoempty, margin);
    fdInclFilenameField.right = new FormAttachment(100, 0);
    wInclFilenameField.setLayoutData(fdInclFilenameField);
    wlInclRownum = new Label(wContentComp, SWT.RIGHT);
    wlInclRownum.setText(BaseMessages.getString(PKG, "TextFileInputDialog.InclRownum.Label"));
    props.setLook(wlInclRownum);
    fdlInclRownum = new FormData();
    fdlInclRownum.left = new FormAttachment(0, 0);
    fdlInclRownum.top = new FormAttachment(wInclFilenameField, margin);
    fdlInclRownum.right = new FormAttachment(middle, -margin);
    wlInclRownum.setLayoutData(fdlInclRownum);
    wInclRownum = new Button(wContentComp, SWT.CHECK);
    props.setLook(wInclRownum);
    wInclRownum.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.InclRownum.Tooltip"));
    fdRownum = new FormData();
    fdRownum.left = new FormAttachment(middle, 0);
    fdRownum.top = new FormAttachment(wInclFilenameField, margin);
    wInclRownum.setLayoutData(fdRownum);
    wlInclRownumField = new Label(wContentComp, SWT.RIGHT);
    wlInclRownumField.setText(BaseMessages.getString(PKG, "TextFileInputDialog.InclRownumField.Label"));
    props.setLook(wlInclRownumField);
    fdlInclRownumField = new FormData();
    fdlInclRownumField.left = new FormAttachment(wInclRownum, margin);
    fdlInclRownumField.top = new FormAttachment(wInclFilenameField, margin);
    wlInclRownumField.setLayoutData(fdlInclRownumField);
    wInclRownumField = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wInclRownumField);
    wInclRownumField.addModifyListener(lsMod);
    fdInclRownumField = new FormData();
    fdInclRownumField.left = new FormAttachment(wlInclRownumField, margin);
    fdInclRownumField.top = new FormAttachment(wInclFilenameField, margin);
    fdInclRownumField.right = new FormAttachment(100, 0);
    wInclRownumField.setLayoutData(fdInclRownumField);
    wlRownumByFileField = new Label(wContentComp, SWT.RIGHT);
    wlRownumByFileField.setText(BaseMessages.getString(PKG, "TextFileInputDialog.RownumByFile.Label"));
    props.setLook(wlRownumByFileField);
    fdlRownumByFile = new FormData();
    fdlRownumByFile.left = new FormAttachment(wInclRownum, margin);
    fdlRownumByFile.top = new FormAttachment(wInclRownumField, margin);
    wlRownumByFileField.setLayoutData(fdlRownumByFile);
    wRownumByFile = new Button(wContentComp, SWT.CHECK);
    props.setLook(wRownumByFile);
    wRownumByFile.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.RownumByFile.Tooltip"));
    fdRownumByFile = new FormData();
    fdRownumByFile.left = new FormAttachment(wlRownumByFileField, margin);
    fdRownumByFile.top = new FormAttachment(wInclRownumField, margin);
    wRownumByFile.setLayoutData(fdRownumByFile);
    wlFormat = new Label(wContentComp, SWT.RIGHT);
    wlFormat.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Format.Label"));
    props.setLook(wlFormat);
    fdlFormat = new FormData();
    fdlFormat.left = new FormAttachment(0, 0);
    fdlFormat.top = new FormAttachment(wRownumByFile, margin * 2);
    fdlFormat.right = new FormAttachment(middle, -margin);
    wlFormat.setLayoutData(fdlFormat);
    wFormat = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
    wFormat.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Format.Label"));
    props.setLook(wFormat);
    wFormat.add("DOS");
    wFormat.add("Unix");
    wFormat.add("mixed");
    wFormat.select(0);
    wFormat.addModifyListener(lsMod);
    fdFormat = new FormData();
    fdFormat.left = new FormAttachment(middle, 0);
    fdFormat.top = new FormAttachment(wRownumByFile, margin * 2);
    fdFormat.right = new FormAttachment(100, 0);
    wFormat.setLayoutData(fdFormat);
    wlEncoding = new Label(wContentComp, SWT.RIGHT);
    wlEncoding.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Encoding.Label"));
    props.setLook(wlEncoding);
    fdlEncoding = new FormData();
    fdlEncoding.left = new FormAttachment(0, 0);
    fdlEncoding.top = new FormAttachment(wFormat, margin);
    fdlEncoding.right = new FormAttachment(middle, -margin);
    wlEncoding.setLayoutData(fdlEncoding);
    wEncoding = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
    wEncoding.setEditable(true);
    props.setLook(wEncoding);
    wEncoding.addModifyListener(lsMod);
    fdEncoding = new FormData();
    fdEncoding.left = new FormAttachment(middle, 0);
    fdEncoding.top = new FormAttachment(wFormat, margin);
    fdEncoding.right = new FormAttachment(100, 0);
    wEncoding.setLayoutData(fdEncoding);
    wEncoding.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);
            setEncodings();
            shell.setCursor(null);
            busy.dispose();
        }
    });
    wlLimit = new Label(wContentComp, SWT.RIGHT);
    wlLimit.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Limit.Label"));
    props.setLook(wlLimit);
    fdlLimit = new FormData();
    fdlLimit.left = new FormAttachment(0, 0);
    fdlLimit.top = new FormAttachment(wEncoding, margin);
    fdlLimit.right = new FormAttachment(middle, -margin);
    wlLimit.setLayoutData(fdlLimit);
    wLimit = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wLimit);
    wLimit.addModifyListener(lsMod);
    fdLimit = new FormData();
    fdLimit.left = new FormAttachment(middle, 0);
    fdLimit.top = new FormAttachment(wEncoding, margin);
    fdLimit.right = new FormAttachment(100, 0);
    wLimit.setLayoutData(fdLimit);
    // Date Lenient checkbox
    wlDateLenient = new Label(wContentComp, SWT.RIGHT);
    wlDateLenient.setText(BaseMessages.getString(PKG, "TextFileInputDialog.DateLenient.Label"));
    props.setLook(wlDateLenient);
    fdlDateLenient = new FormData();
    fdlDateLenient.left = new FormAttachment(0, 0);
    fdlDateLenient.top = new FormAttachment(wLimit, margin);
    fdlDateLenient.right = new FormAttachment(middle, -margin);
    wlDateLenient.setLayoutData(fdlDateLenient);
    wDateLenient = new Button(wContentComp, SWT.CHECK);
    wDateLenient.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.DateLenient.Tooltip"));
    props.setLook(wDateLenient);
    fdDateLenient = new FormData();
    fdDateLenient.left = new FormAttachment(middle, 0);
    fdDateLenient.top = new FormAttachment(wLimit, margin);
    wDateLenient.setLayoutData(fdDateLenient);
    wlDateLocale = new Label(wContentComp, SWT.RIGHT);
    wlDateLocale.setText(BaseMessages.getString(PKG, "TextFileInputDialog.DateLocale.Label"));
    props.setLook(wlDateLocale);
    fdlDateLocale = new FormData();
    fdlDateLocale.left = new FormAttachment(0, 0);
    fdlDateLocale.top = new FormAttachment(wDateLenient, margin);
    fdlDateLocale.right = new FormAttachment(middle, -margin);
    wlDateLocale.setLayoutData(fdlDateLocale);
    wDateLocale = new CCombo(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wDateLocale.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.DateLocale.Tooltip"));
    props.setLook(wDateLocale);
    wDateLocale.addModifyListener(lsMod);
    fdDateLocale = new FormData();
    fdDateLocale.left = new FormAttachment(middle, 0);
    fdDateLocale.top = new FormAttachment(wDateLenient, margin);
    fdDateLocale.right = new FormAttachment(100, 0);
    wDateLocale.setLayoutData(fdDateLocale);
    wDateLocale.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);
            setLocales();
            shell.setCursor(null);
            busy.dispose();
        }
    });
    // ///////////////////////////////
    // START OF AddFileResult GROUP //
    // ///////////////////////////////
    wAddFileResult = new Group(wContentComp, SWT.SHADOW_NONE);
    props.setLook(wAddFileResult);
    wAddFileResult.setText(BaseMessages.getString(PKG, "TextFileInputDialog.wAddFileResult.Label"));
    FormLayout AddFileResultgroupLayout = new FormLayout();
    AddFileResultgroupLayout.marginWidth = 10;
    AddFileResultgroupLayout.marginHeight = 10;
    wAddFileResult.setLayout(AddFileResultgroupLayout);
    wlAddResult = new Label(wAddFileResult, SWT.RIGHT);
    wlAddResult.setText(BaseMessages.getString(PKG, "TextFileInputDialog.AddResult.Label"));
    props.setLook(wlAddResult);
    fdlAddResult = new FormData();
    fdlAddResult.left = new FormAttachment(0, 0);
    fdlAddResult.top = new FormAttachment(wDateLocale, margin);
    fdlAddResult.right = new FormAttachment(middle, -margin);
    wlAddResult.setLayoutData(fdlAddResult);
    wAddResult = new Button(wAddFileResult, SWT.CHECK);
    props.setLook(wAddResult);
    wAddResult.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.AddResult.Tooltip"));
    fdAddResult = new FormData();
    fdAddResult.left = new FormAttachment(middle, 0);
    fdAddResult.top = new FormAttachment(wDateLocale, margin);
    wAddResult.setLayoutData(fdAddResult);
    fdAddFileResult = new FormData();
    fdAddFileResult.left = new FormAttachment(0, margin);
    fdAddFileResult.top = new FormAttachment(wDateLocale, margin);
    fdAddFileResult.right = new FormAttachment(100, -margin);
    wAddFileResult.setLayoutData(fdAddFileResult);
    // ///////////////////////////////////////////////////////////
    // / END OF AddFileResult GROUP
    // ///////////////////////////////////////////////////////////
    wContentComp.pack();
    // What's the size:
    Rectangle bounds = wContentComp.getBounds();
    wContentSComp.setContent(wContentComp);
    wContentSComp.setExpandHorizontal(true);
    wContentSComp.setExpandVertical(true);
    wContentSComp.setMinWidth(bounds.width);
    wContentSComp.setMinHeight(bounds.height);
    fdContentComp = new FormData();
    fdContentComp.left = new FormAttachment(0, 0);
    fdContentComp.top = new FormAttachment(0, 0);
    fdContentComp.right = new FormAttachment(100, 0);
    fdContentComp.bottom = new FormAttachment(100, 0);
    wContentComp.setLayoutData(fdContentComp);
    wContentTab.setControl(wContentSComp);
// ///////////////////////////////////////////////////////////
// / END OF CONTENT TAB
// ///////////////////////////////////////////////////////////
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) Cursor(org.eclipse.swt.graphics.Cursor) CTabItem(org.eclipse.swt.custom.CTabItem) TextVar(org.pentaho.di.ui.core.widget.TextVar) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) FocusListener(org.eclipse.swt.events.FocusListener) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 49 with CTabItem

use of org.eclipse.swt.custom.CTabItem in project pentaho-kettle by pentaho.

the class TransExecutorDialog method addResultRowsTab.

private void addResultRowsTab() {
    final CTabItem wTab = new CTabItem(wTabFolder, SWT.NONE);
    wTab.setText(BaseMessages.getString(PKG, "TransExecutorDialog.ResultRows.Title"));
    wTab.setToolTipText(BaseMessages.getString(PKG, "TransExecutorDialog.ResultRows.Tooltip"));
    ScrolledComposite scrolledComposite = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL);
    scrolledComposite.setLayout(new FillLayout());
    Composite wInputComposite = new Composite(scrolledComposite, SWT.NONE);
    props.setLook(wInputComposite);
    FormLayout tabLayout = new FormLayout();
    tabLayout.marginWidth = 15;
    tabLayout.marginHeight = 15;
    wInputComposite.setLayout(tabLayout);
    wlResultRowsTarget = new Label(wInputComposite, SWT.RIGHT);
    props.setLook(wlResultRowsTarget);
    wlResultRowsTarget.setText(BaseMessages.getString(PKG, "TransExecutorDialog.OutputRowsSource.Label"));
    FormData fdlResultRowsTarget = new FormData();
    fdlResultRowsTarget.top = new FormAttachment(0, 0);
    // First one in the left
    fdlResultRowsTarget.left = new FormAttachment(0, 0);
    wlResultRowsTarget.setLayoutData(fdlResultRowsTarget);
    wOutputRowsSource = new CCombo(wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wOutputRowsSource);
    wOutputRowsSource.addModifyListener(lsMod);
    FormData fdResultRowsTarget = new FormData();
    fdResultRowsTarget.width = 250;
    fdResultRowsTarget.top = new FormAttachment(wlResultRowsTarget, 5);
    // To the right
    fdResultRowsTarget.left = new FormAttachment(0, 0);
    wOutputRowsSource.setLayoutData(fdResultRowsTarget);
    wlOutputFields = new Label(wInputComposite, SWT.NONE);
    wlOutputFields.setText(BaseMessages.getString(PKG, "TransExecutorDialog.ResultFields.Label"));
    props.setLook(wlOutputFields);
    FormData fdlResultFields = new FormData();
    fdlResultFields.left = new FormAttachment(0, 0);
    fdlResultFields.top = new FormAttachment(wOutputRowsSource, 10);
    wlOutputFields.setLayoutData(fdlResultFields);
    int nrRows = (transExecutorMeta.getOutputRowsField() != null ? transExecutorMeta.getOutputRowsField().length : 1);
    ColumnInfo[] ciResultFields = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "TransExecutorDialog.ColumnInfo.Field"), ColumnInfo.COLUMN_TYPE_TEXT, false, false), new ColumnInfo(BaseMessages.getString(PKG, "TransExecutorDialog.ColumnInfo.Type"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames()), new ColumnInfo(BaseMessages.getString(PKG, "TransExecutorDialog.ColumnInfo.Length"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "TransExecutorDialog.ColumnInfo.Precision"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
    wOutputFields = new TableView(transMeta, wInputComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciResultFields, nrRows, false, lsMod, props, false);
    FormData fdResultFields = new FormData();
    fdResultFields.left = new FormAttachment(0, 0);
    fdResultFields.top = new FormAttachment(wlOutputFields, 5);
    fdResultFields.right = new FormAttachment(100, 0);
    fdResultFields.bottom = new FormAttachment(100, 0);
    wOutputFields.setLayoutData(fdResultFields);
    wOutputFields.getTable().addListener(SWT.Resize, new ColumnsResizer(0, 25, 25, 25, 25));
    wInputComposite.pack();
    Rectangle bounds = wInputComposite.getBounds();
    scrolledComposite.setContent(wInputComposite);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setMinWidth(bounds.width);
    scrolledComposite.setMinHeight(bounds.height);
    wTab.setControl(scrolledComposite);
    wTabFolder.setSelection(wTab);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ColumnsResizer(org.pentaho.di.ui.core.widget.ColumnsResizer) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) FillLayout(org.eclipse.swt.layout.FillLayout) CTabItem(org.eclipse.swt.custom.CTabItem) CCombo(org.eclipse.swt.custom.CCombo) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 50 with CTabItem

use of org.eclipse.swt.custom.CTabItem in project pentaho-kettle by pentaho.

the class TransExecutorDialog method addRowGroupTab.

private void addRowGroupTab() {
    final CTabItem wTab = new CTabItem(wTabFolder, SWT.NONE);
    wTab.setText(BaseMessages.getString(PKG, "TransExecutorDialog.RowGroup.Title"));
    wTab.setToolTipText(BaseMessages.getString(PKG, "TransExecutorDialog.RowGroup.Tooltip"));
    Composite wInputComposite = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wInputComposite);
    FormLayout tabLayout = new FormLayout();
    tabLayout.marginWidth = 15;
    tabLayout.marginHeight = 15;
    wInputComposite.setLayout(tabLayout);
    // Group size
    // 
    wlGroupSize = new Label(wInputComposite, SWT.RIGHT);
    props.setLook(wlGroupSize);
    wlGroupSize.setText(BaseMessages.getString(PKG, "TransExecutorDialog.GroupSize.Label"));
    FormData fdlGroupSize = new FormData();
    fdlGroupSize.top = new FormAttachment(0, 0);
    fdlGroupSize.left = new FormAttachment(0, 0);
    wlGroupSize.setLayoutData(fdlGroupSize);
    wGroupSize = new TextVar(transMeta, wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wGroupSize);
    wGroupSize.addModifyListener(lsMod);
    FormData fdGroupSize = new FormData();
    fdGroupSize.width = 250;
    fdGroupSize.top = new FormAttachment(wlGroupSize, 5);
    fdGroupSize.left = new FormAttachment(0, 0);
    wGroupSize.setLayoutData(fdGroupSize);
    // Group field
    // 
    wlGroupField = new Label(wInputComposite, SWT.RIGHT);
    props.setLook(wlGroupField);
    wlGroupField.setText(BaseMessages.getString(PKG, "TransExecutorDialog.GroupField.Label"));
    FormData fdlGroupField = new FormData();
    fdlGroupField.top = new FormAttachment(wGroupSize, 10);
    fdlGroupField.left = new FormAttachment(0, 0);
    wlGroupField.setLayoutData(fdlGroupField);
    wGroupField = new CCombo(wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wGroupField);
    wGroupField.addModifyListener(lsMod);
    FormData fdGroupField = new FormData();
    fdGroupField.width = 250;
    fdGroupField.top = new FormAttachment(wlGroupField, 5);
    fdGroupField.left = new FormAttachment(0, 0);
    wGroupField.setLayoutData(fdGroupField);
    // Group time
    // 
    wlGroupTime = new Label(wInputComposite, SWT.RIGHT);
    props.setLook(wlGroupTime);
    wlGroupTime.setText(BaseMessages.getString(PKG, "TransExecutorDialog.GroupTime.Label"));
    FormData fdlGroupTime = new FormData();
    fdlGroupTime.top = new FormAttachment(wGroupField, 10);
    // First one in the left
    fdlGroupTime.left = new FormAttachment(0, 0);
    wlGroupTime.setLayoutData(fdlGroupTime);
    wGroupTime = new TextVar(transMeta, wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wGroupTime);
    wGroupTime.addModifyListener(lsMod);
    FormData fdGroupTime = new FormData();
    fdGroupTime.width = 250;
    fdGroupTime.top = new FormAttachment(wlGroupTime, 5);
    fdGroupTime.left = new FormAttachment(0, 0);
    wGroupTime.setLayoutData(fdGroupTime);
    wTab.setControl(wInputComposite);
    wTabFolder.setSelection(wTab);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) CCombo(org.eclipse.swt.custom.CCombo) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) CTabItem(org.eclipse.swt.custom.CTabItem) FormAttachment(org.eclipse.swt.layout.FormAttachment) TextVar(org.pentaho.di.ui.core.widget.TextVar)

Aggregations

CTabItem (org.eclipse.swt.custom.CTabItem)377 Composite (org.eclipse.swt.widgets.Composite)246 FormLayout (org.eclipse.swt.layout.FormLayout)189 FormAttachment (org.eclipse.swt.layout.FormAttachment)185 FormData (org.eclipse.swt.layout.FormData)185 SelectionEvent (org.eclipse.swt.events.SelectionEvent)173 Label (org.eclipse.swt.widgets.Label)168 CTabFolder (org.eclipse.swt.custom.CTabFolder)165 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)149 Button (org.eclipse.swt.widgets.Button)142 Text (org.eclipse.swt.widgets.Text)117 Event (org.eclipse.swt.widgets.Event)107 Listener (org.eclipse.swt.widgets.Listener)107 TextVar (org.pentaho.di.ui.core.widget.TextVar)107 ModifyListener (org.eclipse.swt.events.ModifyListener)106 ModifyEvent (org.eclipse.swt.events.ModifyEvent)104 Shell (org.eclipse.swt.widgets.Shell)101 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)100 TableView (org.pentaho.di.ui.core.widget.TableView)99 ShellEvent (org.eclipse.swt.events.ShellEvent)95