Search in sources :

Example 6 with TransExecutorParameters

use of org.pentaho.di.trans.steps.transexecutor.TransExecutorParameters 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)

Aggregations

TransExecutorParameters (org.pentaho.di.trans.steps.transexecutor.TransExecutorParameters)6 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)4 Test (org.junit.Test)3 LoggingObject (org.pentaho.di.core.logging.LoggingObject)3 LoggingObjectInterface (org.pentaho.di.core.logging.LoggingObjectInterface)3 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)3 Variables (org.pentaho.di.core.variables.Variables)3 ArrayList (java.util.ArrayList)2 TableItem (org.eclipse.swt.widgets.TableItem)2 Result (org.pentaho.di.core.Result)2 StepStatus (org.pentaho.di.trans.step.StepStatus)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 Throwables (com.google.common.base.Throwables)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1