Search in sources :

Example 6 with ColumnsResizer

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

the class JobEntryBaseDialog method createElements.

protected void createElements() {
    ModifyListener lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getJobEntry().setChanged();
        }
    };
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 15;
    formLayout.marginHeight = 15;
    shell.setLayout(formLayout);
    Label wicon = new Label(shell, SWT.RIGHT);
    wicon.setImage(getImage());
    FormData fdlicon = new FormData();
    fdlicon.top = new FormAttachment(0, 0);
    fdlicon.right = new FormAttachment(100, 0);
    wicon.setLayoutData(fdlicon);
    props.setLook(wicon);
    wlName = new Label(shell, SWT.LEFT);
    props.setLook(wlName);
    wlName.setText(BaseMessages.getString(PKG, "JobTrans.JobStep.Label"));
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.top = new FormAttachment(0, 0);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    fdName = new FormData();
    fdName.width = 250;
    fdName.top = new FormAttachment(wlName, 5);
    fdName.left = new FormAttachment(0, 0);
    wName.setLayoutData(fdName);
    Label spacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
    FormData fdSpacer = new FormData();
    fdSpacer.left = new FormAttachment(0, 0);
    fdSpacer.top = new FormAttachment(wName, 15);
    fdSpacer.right = new FormAttachment(100, 0);
    spacer.setLayoutData(fdSpacer);
    wlPath = new Label(shell, SWT.LEFT);
    props.setLook(wlPath);
    FormData fdlTransformation = new FormData();
    fdlTransformation.left = new FormAttachment(0, 0);
    fdlTransformation.top = new FormAttachment(spacer, 20);
    fdlTransformation.right = new FormAttachment(50, 0);
    wlPath.setLayoutData(fdlTransformation);
    wPath = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wPath);
    FormData fdTransformation = new FormData();
    fdTransformation.left = new FormAttachment(0, 0);
    fdTransformation.top = new FormAttachment(wlPath, 5);
    fdTransformation.right = new FormAttachment(50, 0);
    wPath.setLayoutData(fdTransformation);
    wbBrowse = new Button(shell, SWT.PUSH);
    props.setLook(wbBrowse);
    wbBrowse.setText(BaseMessages.getString(PKG, "JobTrans.Browse.Label"));
    FormData fdBrowse = new FormData();
    fdBrowse.left = new FormAttachment(wPath, 5);
    fdBrowse.top = new FormAttachment(wlPath, Const.isOSX() ? 0 : 5);
    wbBrowse.setLayoutData(fdBrowse);
    CTabFolder wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
    // Options Tab Start
    CTabItem wOptionsTab = new CTabItem(wTabFolder, SWT.NONE);
    wOptionsTab.setText(BaseMessages.getString(PKG, "JobTrans.Options.Group.Label"));
    wOptions = new Composite(wTabFolder, SWT.SHADOW_NONE);
    props.setLook(wOptions);
    FormLayout specLayout = new FormLayout();
    specLayout.marginWidth = 15;
    specLayout.marginHeight = 15;
    wOptions.setLayout(specLayout);
    gExecution = new Group(wOptions, SWT.SHADOW_ETCHED_IN);
    props.setLook(gExecution);
    gExecution.setText(BaseMessages.getString(PKG, "JobTrans.Execution.Group.Label"));
    FormLayout gExecutionLayout = new FormLayout();
    gExecutionLayout.marginWidth = 15;
    gExecutionLayout.marginHeight = 15;
    gExecution.setLayout(gExecutionLayout);
    fdgExecution = new FormData();
    fdgExecution.top = new FormAttachment(0, 10);
    fdgExecution.left = new FormAttachment(0, 0);
    fdgExecution.right = new FormAttachment(100, 0);
    gExecution.setLayoutData(fdgExecution);
    wEveryRow = new Button(gExecution, SWT.CHECK);
    props.setLook(wEveryRow);
    wEveryRow.setText(BaseMessages.getString(PKG, "JobTrans.ExecForEveryInputRow.Label"));
    FormData fdbExecute = new FormData();
    fdbExecute.left = new FormAttachment(0, 0);
    fdbExecute.top = new FormAttachment(0, 0);
    wEveryRow.setLayoutData(fdbExecute);
    wOptionsTab.setControl(wOptions);
    FormData fdOptions = new FormData();
    fdOptions.left = new FormAttachment(0, 0);
    fdOptions.top = new FormAttachment(0, 0);
    fdOptions.right = new FormAttachment(100, 0);
    fdOptions.bottom = new FormAttachment(100, 0);
    wOptions.setLayoutData(fdOptions);
    // Options Tab End
    // Logging Tab Start
    CTabItem wLoggingTab = new CTabItem(wTabFolder, SWT.NONE);
    wLoggingTab.setText(BaseMessages.getString(PKG, "JobTrans.LogSettings.Group.Label"));
    Composite wLogging = new Composite(wTabFolder, SWT.SHADOW_NONE);
    props.setLook(wLogging);
    FormLayout loggingLayout = new FormLayout();
    loggingLayout.marginWidth = 15;
    loggingLayout.marginHeight = 15;
    wLogging.setLayout(loggingLayout);
    wSetLogfile = new Button(wLogging, SWT.CHECK);
    props.setLook(wSetLogfile);
    wSetLogfile.setText(BaseMessages.getString(PKG, "JobTrans.Specify.Logfile.Label"));
    FormData fdSpecifyLogFile = new FormData();
    fdSpecifyLogFile.left = new FormAttachment(0, 0);
    fdSpecifyLogFile.top = new FormAttachment(0, 0);
    wSetLogfile.setLayoutData(fdSpecifyLogFile);
    gLogFile = new Group(wLogging, SWT.SHADOW_ETCHED_IN);
    props.setLook(gLogFile);
    gLogFile.setText(BaseMessages.getString(PKG, "JobTrans.Logfile.Group.Label"));
    FormLayout gLogFileLayout = new FormLayout();
    gLogFileLayout.marginWidth = 15;
    gLogFileLayout.marginHeight = 15;
    gLogFile.setLayout(gLogFileLayout);
    FormData fdgLogFile = new FormData();
    fdgLogFile.top = new FormAttachment(wSetLogfile, 10);
    fdgLogFile.left = new FormAttachment(0, 0);
    fdgLogFile.right = new FormAttachment(100, 0);
    gLogFile.setLayoutData(fdgLogFile);
    wlLogfile = new Label(gLogFile, SWT.LEFT);
    props.setLook(wlLogfile);
    wlLogfile.setText(BaseMessages.getString(PKG, "JobTrans.NameOfLogfile.Label"));
    FormData fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.top = new FormAttachment(0, 0);
    wlLogfile.setLayoutData(fdlName);
    wLogfile = new TextVar(jobMeta, gLogFile, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wLogfile);
    FormData fdName = new FormData();
    fdName.width = 250;
    fdName.left = new FormAttachment(0, 0);
    fdName.top = new FormAttachment(wlLogfile, 5);
    wLogfile.setLayoutData(fdName);
    wbLogFilename = new Button(gLogFile, SWT.PUSH | SWT.CENTER);
    props.setLook(wbLogFilename);
    wbLogFilename.setText(BaseMessages.getString(PKG, "JobTrans.Browse.Label"));
    fdbLogFilename = new FormData();
    fdbLogFilename.top = new FormAttachment(wlLogfile, Const.isOSX() ? 0 : 5);
    fdbLogFilename.left = new FormAttachment(wLogfile, 5);
    wbLogFilename.setLayoutData(fdbLogFilename);
    wlLogext = new Label(gLogFile, SWT.LEFT);
    props.setLook(wlLogext);
    wlLogext.setText(BaseMessages.getString(PKG, "JobTrans.LogfileExtension.Label"));
    FormData fdlExtension = new FormData();
    fdlExtension.left = new FormAttachment(0, 0);
    fdlExtension.top = new FormAttachment(wLogfile, 10);
    wlLogext.setLayoutData(fdlExtension);
    wLogext = new TextVar(jobMeta, gLogFile, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wLogext);
    FormData fdExtension = new FormData();
    fdExtension.width = 250;
    fdExtension.left = new FormAttachment(0, 0);
    fdExtension.top = new FormAttachment(wlLogext, 5);
    wLogext.setLayoutData(fdExtension);
    wlLoglevel = new Label(gLogFile, SWT.LEFT);
    props.setLook(wlLoglevel);
    wlLoglevel.setText(BaseMessages.getString(PKG, "JobTrans.Loglevel.Label"));
    FormData fdlLogLevel = new FormData();
    fdlLogLevel.left = new FormAttachment(0, 0);
    fdlLogLevel.top = new FormAttachment(wLogext, 10);
    wlLoglevel.setLayoutData(fdlLogLevel);
    wLoglevel = new CCombo(gLogFile, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wLoglevel.setItems(LogLevel.getLogLevelDescriptions());
    props.setLook(wLoglevel);
    FormData fdLogLevel = new FormData();
    fdLogLevel.width = 250;
    fdLogLevel.left = new FormAttachment(0, 0);
    fdLogLevel.top = new FormAttachment(wlLoglevel, 5);
    wLoglevel.setLayoutData(fdLogLevel);
    wAppendLogfile = new Button(gLogFile, SWT.CHECK);
    props.setLook(wAppendLogfile);
    wAppendLogfile.setText(BaseMessages.getString(PKG, "JobTrans.Append.Logfile.Label"));
    FormData fdLogFile = new FormData();
    fdLogFile.left = new FormAttachment(0, 0);
    fdLogFile.top = new FormAttachment(wLoglevel, 10);
    wAppendLogfile.setLayoutData(fdLogFile);
    wCreateParentFolder = new Button(gLogFile, SWT.CHECK);
    props.setLook(wCreateParentFolder);
    wCreateParentFolder.setText(BaseMessages.getString(PKG, "JobTrans.Logfile.CreateParentFolder.Label"));
    FormData fdCreateParent = new FormData();
    fdCreateParent.left = new FormAttachment(0, 0);
    fdCreateParent.top = new FormAttachment(wAppendLogfile, 10);
    wCreateParentFolder.setLayoutData(fdCreateParent);
    wAddDate = new Button(gLogFile, SWT.CHECK);
    props.setLook(wAddDate);
    wAddDate.setText(BaseMessages.getString(PKG, "JobTrans.Logfile.IncludeDate.Label"));
    FormData fdIncludeDate = new FormData();
    fdIncludeDate.left = new FormAttachment(0, 0);
    fdIncludeDate.top = new FormAttachment(wCreateParentFolder, 10);
    wAddDate.setLayoutData(fdIncludeDate);
    wAddTime = new Button(gLogFile, SWT.CHECK);
    props.setLook(wAddTime);
    wAddTime.setText(BaseMessages.getString(PKG, "JobTrans.Logfile.IncludeTime.Label"));
    FormData fdIncludeTime = new FormData();
    fdIncludeTime.left = new FormAttachment(0, 0);
    fdIncludeTime.top = new FormAttachment(wAddDate, 10);
    wAddTime.setLayoutData(fdIncludeTime);
    wSetLogfile.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent selectionEvent) {
            setActive();
        }
    });
    wLoggingTab.setControl(wLogging);
    FormData fdLogging = new FormData();
    fdLogging.left = new FormAttachment(0, 0);
    fdLogging.top = new FormAttachment(0, 0);
    fdLogging.right = new FormAttachment(100, 0);
    fdLogging.bottom = new FormAttachment(100, 0);
    wOptions.setLayoutData(fdLogging);
    // Logging Tab End
    CTabItem wArgumentTab = new CTabItem(wTabFolder, SWT.NONE);
    wArgumentTab.setText(BaseMessages.getString(PKG, "JobTrans.Fields.Arguments.Label"));
    FormLayout fieldLayout = new FormLayout();
    fieldLayout.marginWidth = 15;
    fieldLayout.marginHeight = 15;
    Composite wFieldComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wFieldComp);
    wFieldComp.setLayout(fieldLayout);
    wPrevious = new Button(wFieldComp, SWT.CHECK);
    props.setLook(wPrevious);
    wPrevious.setSelection(getArgFromPrev());
    wPrevious.setText(BaseMessages.getString(PKG, "JobTrans.Previous.Label"));
    FormData fdCopyResults = new FormData();
    fdCopyResults.top = new FormAttachment(0, 0);
    fdCopyResults.left = new FormAttachment(0, 0);
    wPrevious.setLayoutData(fdCopyResults);
    wPrevious.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            wFields.setEnabled(!getArgFromPrev());
        }
    });
    final int FieldsCols = 1;
    int rows = getArguments() == null ? 1 : (getArguments().length == 0 ? 0 : getArguments().length);
    final int FieldsRows = rows;
    ColumnInfo[] colinf = new ColumnInfo[FieldsCols];
    colinf[0] = new ColumnInfo(BaseMessages.getString(PKG, "JobTrans.Arguments.Argument.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false);
    colinf[0].setUsingVariables(true);
    wFields = new TableView(jobMeta, wFieldComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.NO_SCROLL | SWT.V_SCROLL, colinf, FieldsRows, false, lsMod, props, false);
    FormData fdFields = new FormData();
    fdFields.left = new FormAttachment(0, 0);
    fdFields.top = new FormAttachment(wPrevious, 15);
    fdFields.right = new FormAttachment(100, 0);
    fdFields.bottom = new FormAttachment(100, 0);
    wFields.setLayoutData(fdFields);
    wFields.getTable().addListener(SWT.Resize, new ColumnsResizer(0, 100));
    FormData fdFieldsComp = new FormData();
    fdFieldsComp.left = new FormAttachment(0, 0);
    fdFieldsComp.top = new FormAttachment(0, 0);
    fdFieldsComp.right = new FormAttachment(100, 0);
    fdFieldsComp.bottom = new FormAttachment(100, 0);
    wFieldComp.setLayoutData(fdFieldsComp);
    wFieldComp.layout();
    wArgumentTab.setControl(wFieldComp);
    CTabItem wParametersTab = new CTabItem(wTabFolder, SWT.NONE);
    wParametersTab.setText(BaseMessages.getString(PKG, "JobTrans.Fields.Parameters.Label"));
    fieldLayout = new FormLayout();
    fieldLayout.marginWidth = 15;
    fieldLayout.marginHeight = 15;
    Composite wParameterComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wParameterComp);
    wParameterComp.setLayout(fieldLayout);
    wPrevToParams = new Button(wParameterComp, SWT.CHECK);
    props.setLook(wPrevToParams);
    wPrevToParams.setText(BaseMessages.getString(PKG, "JobTrans.PrevToParams.Label"));
    FormData fdCopyResultsParams = new FormData();
    fdCopyResultsParams.left = new FormAttachment(0, 0);
    fdCopyResultsParams.top = new FormAttachment(0, 0);
    wPrevToParams.setLayoutData(fdCopyResultsParams);
    wPrevToParams.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            getJobEntry().setChanged();
        }
    });
    wPassParams = new Button(wParameterComp, SWT.CHECK);
    props.setLook(wPassParams);
    FormData fdPassParams = new FormData();
    fdPassParams.left = new FormAttachment(0, 0);
    fdPassParams.top = new FormAttachment(wPrevToParams, 10);
    wPassParams.setLayoutData(fdPassParams);
    wbGetParams = new Button(wParameterComp, SWT.PUSH);
    wbGetParams.setText(BaseMessages.getString(PKG, "JobTrans.GetParameters.Button.Label"));
    FormData fdGetParams = new FormData();
    fdGetParams.bottom = new FormAttachment(100, 0);
    fdGetParams.right = new FormAttachment(100, 0);
    wbGetParams.setLayoutData(fdGetParams);
    final int parameterRows = getParamters() != null ? getParamters().length : 0;
    colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "JobTrans.Parameters.Parameter.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "JobTrans.Parameters.ColumnName.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "JobTrans.Parameters.Value.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
    colinf[2].setUsingVariables(true);
    wParameters = new TableView(jobMeta, wParameterComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, parameterRows, false, lsMod, props, false);
    props.setLook(wParameters);
    FormData fdParameters = new FormData();
    fdParameters.left = new FormAttachment(0, 0);
    fdParameters.top = new FormAttachment(wPassParams, 10);
    fdParameters.right = new FormAttachment(100);
    fdParameters.bottom = new FormAttachment(wbGetParams, -10);
    wParameters.setLayoutData(fdParameters);
    wParameters.getTable().addListener(SWT.Resize, new ColumnsResizer(0, 33, 33, 33));
    FormData fdParametersComp = new FormData();
    fdParametersComp.left = new FormAttachment(0, 0);
    fdParametersComp.top = new FormAttachment(0, 0);
    fdParametersComp.right = new FormAttachment(100, 0);
    fdParametersComp.bottom = new FormAttachment(100, 0);
    wParameterComp.setLayoutData(fdParametersComp);
    wParameterComp.layout();
    wParametersTab.setControl(wParameterComp);
    wTabFolder.setSelection(0);
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    FormData fdCancel = new FormData();
    fdCancel.right = new FormAttachment(100, 0);
    fdCancel.bottom = new FormAttachment(100, 0);
    wCancel.setLayoutData(fdCancel);
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    FormData fdOk = new FormData();
    fdOk.right = new FormAttachment(wCancel, -5);
    fdOk.bottom = new FormAttachment(100, 0);
    wOK.setLayoutData(fdOk);
    Label hSpacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
    FormData fdhSpacer = new FormData();
    fdhSpacer.left = new FormAttachment(0, 0);
    fdhSpacer.bottom = new FormAttachment(wCancel, -15);
    fdhSpacer.right = new FormAttachment(100, 0);
    hSpacer.setLayoutData(fdhSpacer);
    FormData fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(wPath, 20);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.bottom = new FormAttachment(hSpacer, -15);
    wTabFolder.setLayoutData(fdTabFolder);
    // Add listeners
    lsCancel = new Listener() {

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

        public void handleEvent(Event e) {
            ok();
        }
    };
    wOK.addListener(SWT.Selection, lsOK);
    wCancel.addListener(SWT.Selection, lsCancel);
    lsDef = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wName.addSelectionListener(lsDef);
    wPath.addSelectionListener(lsDef);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) CTabFolder(org.eclipse.swt.custom.CTabFolder) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) ColumnsResizer(org.pentaho.di.ui.core.widget.ColumnsResizer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) Text(org.eclipse.swt.widgets.Text) CTabItem(org.eclipse.swt.custom.CTabItem) TextVar(org.pentaho.di.ui.core.widget.TextVar) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 7 with ColumnsResizer

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

the class SimpleMappingDialog method addParametersTab.

private void addParametersTab(final MappingParameters parameters) {
    CTabItem wParametersTab = new CTabItem(wTabFolder, SWT.NONE);
    wParametersTab.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.Parameters.Title"));
    wParametersTab.setToolTipText(BaseMessages.getString(PKG, "SimpleMappingDialog.Parameters.Tooltip"));
    Composite wParametersComposite = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wParametersComposite);
    FormLayout parameterTabLayout = new FormLayout();
    parameterTabLayout.marginWidth = 15;
    parameterTabLayout.marginHeight = 15;
    wParametersComposite.setLayout(parameterTabLayout);
    // Add a checkbox: inherit all variables...
    // 
    Button wInheritAll = new Button(wParametersComposite, SWT.CHECK);
    wInheritAll.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.Parameters.InheritAll"));
    props.setLook(wInheritAll);
    FormData fdInheritAll = new FormData();
    fdInheritAll.bottom = new FormAttachment(100, 0);
    fdInheritAll.left = new FormAttachment(0, 0);
    fdInheritAll.right = new FormAttachment(100, -30);
    wInheritAll.setLayoutData(fdInheritAll);
    wInheritAll.setSelection(parameters.isInheritingAllVariables());
    // Now add a tableview with the 2 columns to specify: input and output
    // fields for the source and target steps.
    // 
    ColumnInfo[] colinfo = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "SimpleMappingDialog.Parameters.column.Variable"), ColumnInfo.COLUMN_TYPE_TEXT, false, false), new ColumnInfo(BaseMessages.getString(PKG, "SimpleMappingDialog.Parameters.column.ValueOrField"), ColumnInfo.COLUMN_TYPE_TEXT, false, false) };
    colinfo[1].setUsingVariables(true);
    final TableView wMappingParameters = new TableView(transMeta, wParametersComposite, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER, colinfo, parameters.getVariable().length, false, lsMod, props, false);
    props.setLook(wMappingParameters);
    FormData fdMappings = new FormData();
    fdMappings.left = new FormAttachment(0, 0);
    fdMappings.right = new FormAttachment(100, 0);
    fdMappings.top = new FormAttachment(0, 0);
    fdMappings.bottom = new FormAttachment(wInheritAll, -10);
    wMappingParameters.setLayoutData(fdMappings);
    wMappingParameters.getTable().addListener(SWT.Resize, new ColumnsResizer(0, 50, 50));
    for (int i = 0; i < parameters.getVariable().length; i++) {
        TableItem tableItem = wMappingParameters.table.getItem(i);
        tableItem.setText(1, parameters.getVariable()[i]);
        tableItem.setText(2, parameters.getInputField()[i]);
    }
    wMappingParameters.setRowNums();
    wMappingParameters.optWidth(true);
    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);
    wParametersComposite.setLayoutData(fdParametersComposite);
    wParametersComposite.layout();
    wParametersTab.setControl(wParametersComposite);
    changeList.add(new MappingParametersTab(wMappingParameters, wInheritAll, parameters));
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) ColumnsResizer(org.pentaho.di.ui.core.widget.ColumnsResizer) TableItem(org.eclipse.swt.widgets.TableItem) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) CTabItem(org.eclipse.swt.custom.CTabItem) Button(org.eclipse.swt.widgets.Button) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 8 with ColumnsResizer

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

the class SingleThreaderDialog method open.

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

        public void modifyText(ModifyEvent e) {
            singleThreaderMeta.setChanged();
        }
    };
    changed = singleThreaderMeta.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 15;
    formLayout.marginHeight = 15;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Shell.Title"));
    Label wicon = new Label(shell, SWT.RIGHT);
    wicon.setImage(getImage());
    FormData fdlicon = new FormData();
    fdlicon.top = new FormAttachment(0, 0);
    fdlicon.right = new FormAttachment(100, 0);
    wicon.setLayoutData(fdlicon);
    props.setLook(wicon);
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Stepname.Label"));
    props.setLook(wlStepname);
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment(0, 0);
    fdlStepname.top = new FormAttachment(0, 0);
    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.width = 250;
    fdStepname.left = new FormAttachment(0, 0);
    fdStepname.top = new FormAttachment(wlStepname, 5);
    wStepname.setLayoutData(fdStepname);
    Label spacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
    FormData fdSpacer = new FormData();
    fdSpacer.left = new FormAttachment(0, 0);
    fdSpacer.top = new FormAttachment(wStepname, 15);
    fdSpacer.right = new FormAttachment(100, 0);
    spacer.setLayoutData(fdSpacer);
    wlPath = new Label(shell, SWT.LEFT);
    props.setLook(wlPath);
    wlPath.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Transformation.Label"));
    FormData fdlTransformation = new FormData();
    fdlTransformation.left = new FormAttachment(0, 0);
    fdlTransformation.top = new FormAttachment(spacer, 20);
    fdlTransformation.right = new FormAttachment(50, 0);
    wlPath.setLayoutData(fdlTransformation);
    wPath = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wPath);
    FormData fdTransformation = new FormData();
    fdTransformation.left = new FormAttachment(0, 0);
    fdTransformation.top = new FormAttachment(wlPath, 5);
    fdTransformation.width = 350;
    wPath.setLayoutData(fdTransformation);
    wbBrowse = new Button(shell, SWT.PUSH);
    props.setLook(wbBrowse);
    wbBrowse.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Browse.Label"));
    FormData fdBrowse = new FormData();
    fdBrowse.left = new FormAttachment(wPath, 5);
    fdBrowse.top = new FormAttachment(wlPath, Const.isOSX() ? 0 : 5);
    wbBrowse.setLayoutData(fdBrowse);
    wbBrowse.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (repository != null) {
                selectRepositoryTrans();
            } else {
                selectFileTrans(true);
            }
        }
    });
    CTabFolder wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
    // Options Tab Start
    CTabItem wOptionsTab = new CTabItem(wTabFolder, SWT.NONE);
    wOptionsTab.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Options.Group.Label"));
    Composite wOptions = new Composite(wTabFolder, SWT.SHADOW_NONE);
    props.setLook(wOptions);
    FormLayout specLayout = new FormLayout();
    specLayout.marginWidth = 15;
    specLayout.marginHeight = 15;
    wOptions.setLayout(specLayout);
    // Inject step
    // 
    Label wlInjectStep = new Label(wOptions, SWT.LEFT);
    wlInjectStep.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.InjectStep.Label"));
    props.setLook(wlInjectStep);
    FormData fdlInjectStep = new FormData();
    fdlInjectStep.top = new FormAttachment(0, 0);
    fdlInjectStep.left = new FormAttachment(0, 0);
    wlInjectStep.setLayoutData(fdlInjectStep);
    wInjectStep = new TextVar(transMeta, wOptions, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wInjectStep);
    wInjectStep.addModifyListener(lsMod);
    FormData fdInjectStep = new FormData();
    fdInjectStep.width = 250;
    fdInjectStep.left = new FormAttachment(0, 0);
    fdInjectStep.top = new FormAttachment(wlInjectStep, 5);
    wInjectStep.setLayoutData(fdInjectStep);
    wGetInjectStep = new Button(wOptions, SWT.PUSH);
    wGetInjectStep.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Button.Get"));
    FormData fdGetInjectStep = new FormData();
    fdGetInjectStep.top = new FormAttachment(wlInjectStep, Const.isOSX() ? 0 : 5);
    fdGetInjectStep.left = new FormAttachment(wInjectStep, 5);
    wGetInjectStep.setLayoutData(fdGetInjectStep);
    wGetInjectStep.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            try {
                loadTransformation();
                String stepname = mappingTransMeta == null ? "" : Const.NVL(getInjectorStep(mappingTransMeta), "");
                wInjectStep.setText(stepname);
            } catch (Exception e) {
                new ErrorDialog(shell, BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogMessage"), e);
            }
        }
    });
    // Retrieve step...
    // 
    Label wlRetrieveStep = new Label(wOptions, SWT.LEFT);
    wlRetrieveStep.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.RetrieveStep.Label"));
    props.setLook(wlRetrieveStep);
    FormData fdlRetrieveStep = new FormData();
    fdlRetrieveStep.top = new FormAttachment(wInjectStep, 10);
    fdlRetrieveStep.left = new FormAttachment(0, 0);
    wlRetrieveStep.setLayoutData(fdlRetrieveStep);
    wRetrieveStep = new TextVar(transMeta, wOptions, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wRetrieveStep);
    wRetrieveStep.addModifyListener(lsMod);
    FormData fdRetrieveStep = new FormData();
    fdRetrieveStep.width = 250;
    fdRetrieveStep.left = new FormAttachment(0, 0);
    fdRetrieveStep.top = new FormAttachment(wlRetrieveStep, 5);
    wRetrieveStep.setLayoutData(fdRetrieveStep);
    wGetRetrieveStep = new Button(wOptions, SWT.PUSH);
    wGetRetrieveStep.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Button.Get"));
    FormData fdGetRetrieveStep = new FormData();
    fdGetRetrieveStep.top = new FormAttachment(wlRetrieveStep, Const.isOSX() ? 0 : 5);
    fdGetRetrieveStep.left = new FormAttachment(wRetrieveStep, 5);
    wGetRetrieveStep.setLayoutData(fdGetRetrieveStep);
    wGetRetrieveStep.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            try {
                loadTransformation();
                if (mappingTransMeta != null) {
                    String[] stepNames = mappingTransMeta.getStepNames();
                    EnterSelectionDialog d = new EnterSelectionDialog(shell, stepNames, BaseMessages.getString(PKG, "SingleThreaderDialog.SelectStep.Title"), BaseMessages.getString(PKG, "SingleThreaderDialog.SelectStep.Message"));
                    String step = d.open();
                    if (step != null) {
                        wRetrieveStep.setText(step);
                    }
                }
            } catch (Exception e) {
                new ErrorDialog(shell, BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogMessage"), e);
            }
        }
    });
    // Here come the batch size, inject and retrieve fields...
    // 
    Label wlBatchSize = new Label(wOptions, SWT.LEFT);
    wlBatchSize.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.BatchSize.Label"));
    props.setLook(wlBatchSize);
    FormData fdlBatchSize = new FormData();
    fdlBatchSize.top = new FormAttachment(wRetrieveStep, 10);
    fdlBatchSize.left = new FormAttachment(0, 0);
    wlBatchSize.setLayoutData(fdlBatchSize);
    wBatchSize = new TextVar(transMeta, wOptions, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    FormData fdBatchSize = new FormData();
    fdBatchSize.left = new FormAttachment(0, 0);
    fdBatchSize.top = new FormAttachment(wlBatchSize, 5);
    wBatchSize.setLayoutData(fdBatchSize);
    Label wlBatchTime = new Label(wOptions, SWT.LEFT);
    wlBatchTime.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.BatchTime.Label"));
    props.setLook(wlBatchTime);
    FormData fdlBatchTime = new FormData();
    fdlBatchTime.top = new FormAttachment(wBatchSize, 10);
    fdlBatchTime.left = new FormAttachment(0, 0);
    wlBatchTime.setLayoutData(fdlBatchTime);
    wBatchTime = new TextVar(transMeta, wOptions, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wBatchTime.addModifyListener(lsMod);
    FormData fdBatchTime = new FormData();
    fdBatchTime.left = new FormAttachment(0, 0);
    fdBatchTime.top = new FormAttachment(wlBatchTime, 5);
    wBatchTime.setLayoutData(fdBatchTime);
    wOptionsTab.setControl(wOptions);
    FormData fdOptions = new FormData();
    fdOptions.left = new FormAttachment(0, 0);
    fdOptions.top = new FormAttachment(0, 0);
    fdOptions.right = new FormAttachment(100, 0);
    fdOptions.bottom = new FormAttachment(100, 0);
    wOptions.setLayoutData(fdOptions);
    // Options Tab End
    // Parameters Tab Start
    CTabItem wParametersTab = new CTabItem(wTabFolder, SWT.NONE);
    wParametersTab.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Fields.Parameters.Label"));
    FormLayout fieldLayout = new FormLayout();
    fieldLayout.marginWidth = 15;
    fieldLayout.marginHeight = 15;
    Composite wParameterComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wParameterComp);
    wParameterComp.setLayout(fieldLayout);
    // Pass all parameters down
    // 
    wPassParams = new Button(wParameterComp, SWT.CHECK);
    props.setLook(wPassParams);
    wPassParams.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.PassAllParameters.Label"));
    FormData fdPassParams = new FormData();
    fdPassParams.left = new FormAttachment(0, 0);
    fdPassParams.top = new FormAttachment(0, 0);
    wPassParams.setLayoutData(fdPassParams);
    wPassParams.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            changed = true;
        }
    });
    wbGetParams = new Button(wParameterComp, SWT.PUSH);
    wbGetParams.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.GetParameters.Button.Label"));
    FormData fdGetParams = new FormData();
    fdGetParams.bottom = new FormAttachment(100, 0);
    fdGetParams.right = new FormAttachment(100, 0);
    wbGetParams.setLayoutData(fdGetParams);
    wbGetParams.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            // null: force reload of file from specification
            getParameters(null);
        }
    });
    final int parameterRows = singleThreaderMeta.getParameters() != null ? singleThreaderMeta.getParameters().length : 0;
    ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "SingleThreaderDialog.Parameters.Parameter.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "SingleThreaderDialog.Parameters.Value.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
    colinf[1].setUsingVariables(true);
    wParameters = new TableView(transMeta, wParameterComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, parameterRows, false, lsMod, props, false);
    FormData fdParameters = new FormData();
    fdParameters.left = new FormAttachment(0, 0);
    fdParameters.top = new FormAttachment(wPassParams, 10);
    fdParameters.right = new FormAttachment(100);
    fdParameters.bottom = new FormAttachment(wbGetParams, -10);
    wParameters.setLayoutData(fdParameters);
    wParameters.getTable().addListener(SWT.Resize, new ColumnsResizer(0, 50, 50));
    FormData fdParametersComp = new FormData();
    fdParametersComp.left = new FormAttachment(0, 0);
    fdParametersComp.top = new FormAttachment(0, 0);
    fdParametersComp.right = new FormAttachment(100, 0);
    fdParametersComp.bottom = new FormAttachment(100, 0);
    wParameterComp.setLayoutData(fdParametersComp);
    wParameterComp.layout();
    wParametersTab.setControl(wParameterComp);
    wTabFolder.setSelection(0);
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    FormData fdCancel = new FormData();
    fdCancel.right = new FormAttachment(100, 0);
    fdCancel.bottom = new FormAttachment(100, 0);
    wCancel.setLayoutData(fdCancel);
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    FormData fdOk = new FormData();
    fdOk.right = new FormAttachment(wCancel, -5);
    fdOk.bottom = new FormAttachment(100, 0);
    wOK.setLayoutData(fdOk);
    Label hSpacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
    FormData fdhSpacer = new FormData();
    fdhSpacer.left = new FormAttachment(0, 0);
    fdhSpacer.bottom = new FormAttachment(wCancel, -15);
    fdhSpacer.right = new FormAttachment(100, 0);
    hSpacer.setLayoutData(fdhSpacer);
    FormData fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(wPath, 20);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.bottom = new FormAttachment(hSpacer, -15);
    wTabFolder.setLayoutData(fdTabFolder);
    // Add listeners
    lsCancel = new Listener() {

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

        public void handleEvent(Event e) {
            ok();
        }
    };
    wOK.addListener(SWT.Selection, lsOK);
    wCancel.addListener(SWT.Selection, lsCancel);
    lsDef = new SelectionAdapter() {

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

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    // Set the shell size, based upon previous time...
    setSize();
    getData();
    singleThreaderMeta.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) ColumnsResizer(org.pentaho.di.ui.core.widget.ColumnsResizer) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) ShellEvent(org.eclipse.swt.events.ShellEvent) CTabItem(org.eclipse.swt.custom.CTabItem) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) 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) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Text(org.eclipse.swt.widgets.Text) KettleException(org.pentaho.di.core.exception.KettleException) IOException(java.io.IOException) TextVar(org.pentaho.di.ui.core.widget.TextVar) 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 9 with ColumnsResizer

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

the class TransExecutorDialog method addParametersTab.

private void addParametersTab() {
    CTabItem wParametersTab = new CTabItem(wTabFolder, SWT.NONE);
    wParametersTab.setText(BaseMessages.getString(PKG, "TransExecutorDialog.Parameters.Title"));
    wParametersTab.setToolTipText(BaseMessages.getString(PKG, "TransExecutorDialog.Parameters.Tooltip"));
    Composite wParametersComposite = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wParametersComposite);
    FormLayout parameterTabLayout = new FormLayout();
    parameterTabLayout.marginWidth = 15;
    parameterTabLayout.marginHeight = 15;
    wParametersComposite.setLayout(parameterTabLayout);
    // Add a button: get parameters
    // 
    wGetParameters = new Button(wParametersComposite, SWT.PUSH);
    wGetParameters.setText(BaseMessages.getString(PKG, "TransExecutorDialog.Parameters.GetParameters"));
    props.setLook(wGetParameters);
    FormData fdGetParameters = new FormData();
    fdGetParameters.bottom = new FormAttachment(100, 0);
    fdGetParameters.right = new FormAttachment(100, 0);
    wGetParameters.setLayoutData(fdGetParameters);
    wGetParameters.setSelection(transExecutorMeta.getParameters().isInheritingAllVariables());
    wGetParameters.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            // null = force reload of data on disk
            getParametersFromTrans(null);
        }
    });
    // Now add a table view with the 3 columns to specify: variable name, input field & optional static input
    // 
    parameterColumns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "TransExecutorDialog.Parameters.column.Variable"), ColumnInfo.COLUMN_TYPE_TEXT, false, false), new ColumnInfo(BaseMessages.getString(PKG, "TransExecutorDialog.Parameters.column.Field"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] {}, false), new ColumnInfo(BaseMessages.getString(PKG, "TransExecutorDialog.Parameters.column.Input"), ColumnInfo.COLUMN_TYPE_TEXT, false, false) };
    parameterColumns[1].setUsingVariables(true);
    TransExecutorParameters parameters = transExecutorMeta.getParameters();
    wTransExecutorParameters = new TableView(transMeta, wParametersComposite, SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER, parameterColumns, parameters.getVariable().length, false, lsMod, props, false);
    props.setLook(wTransExecutorParameters);
    FormData fdTransExecutors = new FormData();
    fdTransExecutors.left = new FormAttachment(0, 0);
    fdTransExecutors.right = new FormAttachment(100, 0);
    fdTransExecutors.top = new FormAttachment(0, 0);
    fdTransExecutors.bottom = new FormAttachment(wGetParameters, -10);
    wTransExecutorParameters.setLayoutData(fdTransExecutors);
    wTransExecutorParameters.getTable().addListener(SWT.Resize, new ColumnsResizer(0, 33, 33, 33));
    for (int i = 0; i < parameters.getVariable().length; i++) {
        TableItem tableItem = wTransExecutorParameters.table.getItem(i);
        tableItem.setText(1, Const.NVL(parameters.getVariable()[i], ""));
        tableItem.setText(2, Const.NVL(parameters.getField()[i], ""));
        tableItem.setText(3, Const.NVL(parameters.getInput()[i], ""));
    }
    wTransExecutorParameters.setRowNums();
    wTransExecutorParameters.optWidth(true);
    // Add a checkbox: inherit all variables...
    // 
    wInheritAll = new Button(wParametersComposite, SWT.CHECK);
    wInheritAll.setText(BaseMessages.getString(PKG, "TransExecutorDialog.Parameters.InheritAll"));
    props.setLook(wInheritAll);
    FormData fdInheritAll = new FormData();
    fdInheritAll.top = new FormAttachment(wTransExecutorParameters, 15);
    fdInheritAll.left = new FormAttachment(0, 0);
    wInheritAll.setLayoutData(fdInheritAll);
    wInheritAll.setSelection(transExecutorMeta.getParameters().isInheritingAllVariables());
    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);
    wParametersComposite.setLayoutData(fdParametersComposite);
    wParametersComposite.layout();
    wParametersTab.setControl(wParametersComposite);
}
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) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) CTabItem(org.eclipse.swt.custom.CTabItem) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TransExecutorParameters(org.pentaho.di.trans.steps.transexecutor.TransExecutorParameters) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 10 with ColumnsResizer

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

the class TransExecutorDialog method addExecutionResultTab.

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

Aggregations

CTabItem (org.eclipse.swt.custom.CTabItem)13 FormAttachment (org.eclipse.swt.layout.FormAttachment)13 FormData (org.eclipse.swt.layout.FormData)13 FormLayout (org.eclipse.swt.layout.FormLayout)13 Composite (org.eclipse.swt.widgets.Composite)13 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)13 ColumnsResizer (org.pentaho.di.ui.core.widget.ColumnsResizer)13 TableView (org.pentaho.di.ui.core.widget.TableView)13 Button (org.eclipse.swt.widgets.Button)9 Label (org.eclipse.swt.widgets.Label)8 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)7 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 CCombo (org.eclipse.swt.custom.CCombo)6 TableItem (org.eclipse.swt.widgets.TableItem)6 Rectangle (org.eclipse.swt.graphics.Rectangle)5 FillLayout (org.eclipse.swt.layout.FillLayout)5 Text (org.eclipse.swt.widgets.Text)3 KettleException (org.pentaho.di.core.exception.KettleException)3 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)3