use of org.apache.hop.core.variables.Variables in project hop by apache.
the class DataSetEditor method createControl.
@Override
public void createControl(Composite parent) {
PropsUi props = PropsUi.getInstance();
int margin = Const.MARGIN;
// The name of the group...
//
Label wIcon = new Label(parent, 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);
// What's the name
Label wlName = new Label(parent, SWT.RIGHT);
props.setLook(wlName);
wlName.setText(BaseMessages.getString(PKG, "DataSetDialog.Name.Label"));
FormData fdlName = new FormData();
fdlName.top = new FormAttachment(0, 0);
fdlName.left = new FormAttachment(0, 0);
wlName.setLayoutData(fdlName);
wName = new Text(parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wName);
FormData fdName = new FormData();
fdName.top = new FormAttachment(wlName, 5);
fdName.left = new FormAttachment(0, 0);
fdName.right = new FormAttachment(wIcon, -5);
wName.setLayoutData(fdName);
Label spacer = new Label(parent, 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);
// The description of the group...
//
Label wlDescription = new Label(parent, SWT.LEFT);
props.setLook(wlDescription);
wlDescription.setText(BaseMessages.getString(PKG, "DataSetDialog.Description.Label"));
FormData fdlDescription = new FormData();
fdlDescription.top = new FormAttachment(spacer, margin);
fdlDescription.left = new FormAttachment(0, 0);
fdlDescription.right = new FormAttachment(100, 0);
wlDescription.setLayoutData(fdlDescription);
wDescription = new Text(parent, SWT.MULTI | SWT.LEFT | SWT.V_SCROLL | SWT.BORDER);
props.setLook(wDescription);
FormData fdDescription = new FormData();
fdDescription.height = 50;
fdDescription.top = new FormAttachment(wlDescription, margin);
fdDescription.left = new FormAttachment(0, 0);
fdDescription.right = new FormAttachment(100, 0);
wDescription.setLayoutData(fdDescription);
// The folder containing the set...
//
Label wlFolderName = new Label(parent, SWT.LEFT);
props.setLook(wlFolderName);
wlFolderName.setText(BaseMessages.getString(PKG, "DataSetDialog.FolderName.Label"));
FormData fdlFolderName = new FormData();
fdlFolderName.top = new FormAttachment(wDescription, margin);
fdlFolderName.left = new FormAttachment(0, 0);
fdlFolderName.right = new FormAttachment(100, 0);
wlFolderName.setLayoutData(fdlFolderName);
wFolderName = new TextVar(manager.getVariables(), parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFolderName);
FormData fdFolderName = new FormData();
fdFolderName.top = new FormAttachment(wlFolderName, margin);
fdFolderName.left = new FormAttachment(0, 0);
fdFolderName.right = new FormAttachment(100, 0);
wFolderName.setLayoutData(fdFolderName);
// The table storing the set...
//
Label wlBaseFilename = new Label(parent, SWT.LEFT);
props.setLook(wlBaseFilename);
wlBaseFilename.setText(BaseMessages.getString(PKG, "DataSetDialog.BaseFilename.Label"));
FormData fdlBaseFilename = new FormData();
fdlBaseFilename.top = new FormAttachment(wFolderName, margin);
fdlBaseFilename.left = new FormAttachment(0, 0);
fdlBaseFilename.right = new FormAttachment(100, 0);
wlBaseFilename.setLayoutData(fdlBaseFilename);
wBaseFilename = new Text(parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wBaseFilename);
FormData fdBaseFilename = new FormData();
fdBaseFilename.top = new FormAttachment(wlBaseFilename, margin);
fdBaseFilename.left = new FormAttachment(0, 0);
fdBaseFilename.right = new FormAttachment(100, 0);
wBaseFilename.setLayoutData(fdBaseFilename);
// The field mapping from the input to the data set...
//
Label wlFieldMapping = new Label(parent, SWT.NONE);
wlFieldMapping.setText(BaseMessages.getString(PKG, "DataSetDialog.FieldMapping.Label"));
props.setLook(wlFieldMapping);
FormData fdlUpIns = new FormData();
fdlUpIns.left = new FormAttachment(0, 0);
fdlUpIns.top = new FormAttachment(wBaseFilename, margin * 2);
wlFieldMapping.setLayoutData(fdlUpIns);
// the field mapping grid in between
//
ColumnInfo[] columns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "DataSetDialog.ColumnInfo.FieldName"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false), new ColumnInfo(BaseMessages.getString(PKG, "DataSetDialog.ColumnInfo.FieldType"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getAllValueMetaNames(), false), new ColumnInfo(BaseMessages.getString(PKG, "DataSetDialog.ColumnInfo.FieldFormat"), ColumnInfo.COLUMN_TYPE_FORMAT, 2), new ColumnInfo(BaseMessages.getString(PKG, "DataSetDialog.ColumnInfo.FieldLength"), ColumnInfo.COLUMN_TYPE_TEXT, true, false), new ColumnInfo(BaseMessages.getString(PKG, "DataSetDialog.ColumnInfo.FieldPrecision"), ColumnInfo.COLUMN_TYPE_TEXT, true, false), new ColumnInfo(BaseMessages.getString(PKG, "DataSetDialog.ColumnInfo.Comment"), ColumnInfo.COLUMN_TYPE_TEXT, false, false) };
wFieldMapping = new TableView(new Variables(), parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, columns, getMetadata().getFields().size(), null, props);
FormData fdFieldMapping = new FormData();
fdFieldMapping.left = new FormAttachment(0, 0);
fdFieldMapping.top = new FormAttachment(wlFieldMapping, margin);
fdFieldMapping.right = new FormAttachment(100, 0);
fdFieldMapping.bottom = new FormAttachment(100, -2 * margin);
wFieldMapping.setLayoutData(fdFieldMapping);
this.setWidgetsContent();
// Add listener to detect change after loading data
ModifyListener lsMod = e -> setChanged();
wName.addModifyListener(lsMod);
wDescription.addModifyListener(lsMod);
wFolderName.addModifyListener(lsMod);
wBaseFilename.addModifyListener(lsMod);
wFieldMapping.addModifyListener(lsMod);
}
use of org.apache.hop.core.variables.Variables in project hop by apache.
the class PipelineUnitTestEditor method createControl.
@Override
public void createControl(Composite parent) {
PipelineUnitTest pipelineUnitTest = this.getMetadata();
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// The name of the unit test...
//
Label wlName = new Label(parent, SWT.RIGHT);
props.setLook(wlName);
wlName.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.Name.Label"));
FormData fdlName = new FormData();
fdlName.top = new FormAttachment(0, margin);
fdlName.left = new FormAttachment(0, 0);
fdlName.right = new FormAttachment(middle, -margin);
wlName.setLayoutData(fdlName);
wName = new Text(parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wName);
FormData fdName = new FormData();
fdName.top = new FormAttachment(wlName, 0, SWT.CENTER);
fdName.left = new FormAttachment(middle, 0);
fdName.right = new FormAttachment(100, 0);
wName.setLayoutData(fdName);
Control lastControl = wName;
// The description of the test...
//
Label wlDescription = new Label(parent, SWT.RIGHT);
props.setLook(wlDescription);
wlDescription.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.Description.Label"));
FormData fdlDescription = new FormData();
fdlDescription.top = new FormAttachment(lastControl, margin);
fdlDescription.left = new FormAttachment(0, 0);
fdlDescription.right = new FormAttachment(middle, -margin);
wlDescription.setLayoutData(fdlDescription);
wDescription = new Text(parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDescription);
FormData fdDescription = new FormData();
fdDescription.top = new FormAttachment(wlDescription, 0, SWT.CENTER);
fdDescription.left = new FormAttachment(middle, 0);
fdDescription.right = new FormAttachment(100, 0);
wDescription.setLayoutData(fdDescription);
lastControl = wDescription;
// The type of test...
//
Label wlTestType = new Label(parent, SWT.RIGHT);
props.setLook(wlTestType);
wlTestType.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.TestType.Label"));
FormData fdlTestType = new FormData();
fdlTestType.top = new FormAttachment(lastControl, margin);
fdlTestType.left = new FormAttachment(0, 0);
fdlTestType.right = new FormAttachment(middle, -margin);
wlTestType.setLayoutData(fdlTestType);
wTestType = new Combo(parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
FormData fdTestType = new FormData();
fdTestType.top = new FormAttachment(wlTestType, 0, SWT.CENTER);
fdTestType.left = new FormAttachment(middle, 0);
fdTestType.right = new FormAttachment(100, 0);
wTestType.setLayoutData(fdTestType);
wTestType.setItems(DataSetConst.getTestTypeDescriptions());
lastControl = wTestType;
// The filename of the pipeline to test
//
Label wlPipelineFilename = new Label(parent, SWT.RIGHT);
props.setLook(wlPipelineFilename);
wlPipelineFilename.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.PipelineFilename.Label"));
FormData fdlPipelineFilename = new FormData();
fdlPipelineFilename.top = new FormAttachment(lastControl, margin);
fdlPipelineFilename.left = new FormAttachment(0, 0);
fdlPipelineFilename.right = new FormAttachment(middle, -margin);
wlPipelineFilename.setLayoutData(fdlPipelineFilename);
wPipelineFilename = new Text(parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wPipelineFilename);
FormData fdPipelineFilename = new FormData();
fdPipelineFilename.top = new FormAttachment(wlPipelineFilename, 0, SWT.CENTER);
fdPipelineFilename.left = new FormAttachment(middle, 0);
fdPipelineFilename.right = new FormAttachment(100, 0);
wPipelineFilename.setLayoutData(fdPipelineFilename);
lastControl = wPipelineFilename;
// The optional filename of the test result...
//
Label wlFilename = new Label(parent, SWT.RIGHT);
props.setLook(wlFilename);
wlFilename.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.Filename.Label"));
FormData fdlFilename = new FormData();
fdlFilename.top = new FormAttachment(lastControl, margin);
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wFilename = new TextVar(manager.getVariables(), parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFilename);
FormData fdFilename = new FormData();
fdFilename.top = new FormAttachment(wlFilename, 0, SWT.CENTER);
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.right = new FormAttachment(100, 0);
wFilename.setLayoutData(fdFilename);
lastControl = wFilename;
// The base path for relative test path resolution
//
Label wlBasePath = new Label(parent, SWT.RIGHT);
props.setLook(wlBasePath);
wlBasePath.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.BasePath.Label"));
FormData fdlBasePath = new FormData();
fdlBasePath.top = new FormAttachment(lastControl, margin);
fdlBasePath.left = new FormAttachment(0, 0);
fdlBasePath.right = new FormAttachment(middle, -margin);
wlBasePath.setLayoutData(fdlBasePath);
wBasePath = new TextVar(manager.getVariables(), parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wBasePath);
FormData fdBasePath = new FormData();
fdBasePath.top = new FormAttachment(wlBasePath, 0, SWT.CENTER);
fdBasePath.left = new FormAttachment(middle, 0);
fdBasePath.right = new FormAttachment(100, 0);
wBasePath.setLayoutData(fdBasePath);
lastControl = wBasePath;
// The base path for relative test path resolution
//
Label wlAutoOpen = new Label(parent, SWT.RIGHT);
props.setLook(wlAutoOpen);
wlAutoOpen.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.AutoOpen.Label"));
FormData fdlAutoOpen = new FormData();
fdlAutoOpen.top = new FormAttachment(lastControl, margin);
fdlAutoOpen.left = new FormAttachment(0, 0);
fdlAutoOpen.right = new FormAttachment(middle, -margin);
wlAutoOpen.setLayoutData(fdlAutoOpen);
wAutoOpen = new Button(parent, SWT.CHECK);
props.setLook(wAutoOpen);
FormData fdAutoOpen = new FormData();
fdAutoOpen.top = new FormAttachment(wlAutoOpen, 0, SWT.CENTER);
fdAutoOpen.left = new FormAttachment(middle, 0);
fdAutoOpen.right = new FormAttachment(100, 0);
wAutoOpen.setLayoutData(fdAutoOpen);
lastControl = wAutoOpen;
// The list of database replacements in the unit test pipeline
//
Label wlFieldMapping = new Label(parent, SWT.NONE);
wlFieldMapping.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.DbReplacements.Label"));
props.setLook(wlFieldMapping);
FormData fdlUpIns = new FormData();
fdlUpIns.left = new FormAttachment(0, 0);
fdlUpIns.top = new FormAttachment(lastControl, 3 * margin);
wlFieldMapping.setLayoutData(fdlUpIns);
lastControl = wlFieldMapping;
// the database replacements
//
List<String> dbNames;
try {
dbNames = metadataProvider.getSerializer(DatabaseMeta.class).listObjectNames();
Collections.sort(dbNames);
} catch (HopException e) {
LogChannel.UI.logError("Error getting list of databases", e);
dbNames = Collections.emptyList();
}
ColumnInfo[] columns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "PipelineUnitTestDialog.DbReplacement.ColumnInfo.OriginalDb"), ColumnInfo.COLUMN_TYPE_CCOMBO, dbNames.toArray(new String[0]), false), new ColumnInfo(BaseMessages.getString(PKG, "PipelineUnitTestDialog.DbReplacement.ColumnInfo.ReplacementDb"), ColumnInfo.COLUMN_TYPE_CCOMBO, dbNames.toArray(new String[0]), false) };
columns[0].setUsingVariables(true);
columns[1].setUsingVariables(true);
wDbReplacements = new TableView(new Variables(), parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, columns, pipelineUnitTest.getTweaks().size(), null, props);
FormData fdDbReplacements = new FormData();
fdDbReplacements.left = new FormAttachment(0, 0);
fdDbReplacements.top = new FormAttachment(lastControl, margin);
fdDbReplacements.right = new FormAttachment(100, 0);
fdDbReplacements.bottom = new FormAttachment(lastControl, 250);
wDbReplacements.setLayoutData(fdDbReplacements);
lastControl = wDbReplacements;
Label wlVariableValues = new Label(parent, SWT.NONE);
wlVariableValues.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.VariableValues.Label"));
props.setLook(wlVariableValues);
FormData fdlVariableValues = new FormData();
fdlVariableValues.left = new FormAttachment(0, 0);
fdlVariableValues.top = new FormAttachment(lastControl, margin);
wlVariableValues.setLayoutData(fdlVariableValues);
lastControl = wlVariableValues;
ColumnInfo[] varValColumns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "PipelineUnitTestDialog.VariableValues.ColumnInfo.VariableName"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "PipelineUnitTestDialog.VariableValues.ColumnInfo.VariableValue"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
varValColumns[0].setUsingVariables(true);
varValColumns[1].setUsingVariables(true);
wVariableValues = new TableView(new Variables(), parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, varValColumns, pipelineUnitTest.getVariableValues().size(), null, props);
FormData fdVariableValues = new FormData();
fdVariableValues.left = new FormAttachment(0, 0);
fdVariableValues.top = new FormAttachment(lastControl, margin);
fdVariableValues.right = new FormAttachment(100, 0);
fdVariableValues.bottom = new FormAttachment(100, -2 * margin);
wVariableValues.setLayoutData(fdVariableValues);
setWidgetsContent();
// Add listener to detect change after loading data
Listener modifyListener = e -> setChanged();
wName.addListener(SWT.Modify, modifyListener);
wDescription.addListener(SWT.Modify, modifyListener);
wTestType.addListener(SWT.Modify, modifyListener);
wPipelineFilename.addListener(SWT.Modify, modifyListener);
wFilename.addListener(SWT.Modify, modifyListener);
wBasePath.addListener(SWT.Modify, modifyListener);
wAutoOpen.addListener(SWT.Selection, modifyListener);
}
use of org.apache.hop.core.variables.Variables in project hop by apache.
the class RegexEvalDialog method open.
@Override
public String open() {
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = e -> input.setChanged();
SelectionListener lsSel = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent 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, "RegexEvalDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = props.getMargin();
// Buttons at the bottom
//
wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
setButtonPositions(new Button[] { wOk, wCancel }, margin, null);
// Filename line
wlTransformName = new Label(shell, SWT.RIGHT);
wlTransformName.setText(BaseMessages.getString(PKG, "RegexEvalDialog.TransformName.Label"));
props.setLook(wlTransformName);
fdlTransformName = new FormData();
fdlTransformName.left = new FormAttachment(0, 0);
fdlTransformName.right = new FormAttachment(middle, -margin);
fdlTransformName.top = new FormAttachment(0, margin);
wlTransformName.setLayoutData(fdlTransformName);
wTransformName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wTransformName.setText(transformName);
props.setLook(wTransformName);
wTransformName.addModifyListener(lsMod);
fdTransformName = new FormData();
fdTransformName.left = new FormAttachment(middle, 0);
fdTransformName.top = new FormAttachment(0, margin);
fdTransformName.right = new FormAttachment(100, 0);
wTransformName.setLayoutData(fdTransformName);
SashForm wSash = new SashForm(shell, SWT.VERTICAL);
CTabFolder wTabFolder = new CTabFolder(wSash, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// ////////////////////////
// START OF GENERAL TAB ///
// ////////////////////////
CTabItem wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setText(BaseMessages.getString(PKG, "RegexEvalDialog.GeneralTab.TabTitle"));
Composite wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = 3;
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
// Transform Settings grouping?
// ////////////////////////
// START OF Transform Settings GROUP
//
Group wTransformSettings = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wTransformSettings);
wTransformSettings.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Group.TransformSettings.Label"));
FormLayout groupLayout = new FormLayout();
groupLayout.marginWidth = 10;
groupLayout.marginHeight = 10;
wTransformSettings.setLayout(groupLayout);
// fieldevaluate
Label wlfieldevaluate = new Label(wTransformSettings, SWT.RIGHT);
wlfieldevaluate.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Matcher.Label"));
props.setLook(wlfieldevaluate);
FormData fdlfieldevaluate = new FormData();
fdlfieldevaluate.left = new FormAttachment(0, 0);
fdlfieldevaluate.top = new FormAttachment(wTransformName, margin);
fdlfieldevaluate.right = new FormAttachment(middle, -margin);
wlfieldevaluate.setLayoutData(fdlfieldevaluate);
wFieldEvaluate = new CCombo(wTransformSettings, SWT.BORDER | SWT.READ_ONLY);
wFieldEvaluate.setEditable(true);
props.setLook(wFieldEvaluate);
wFieldEvaluate.addModifyListener(lsMod);
FormData fdfieldevaluate = new FormData();
fdfieldevaluate.left = new FormAttachment(middle, margin);
fdfieldevaluate.top = new FormAttachment(wTransformName, margin);
fdfieldevaluate.right = new FormAttachment(100, -margin);
wFieldEvaluate.setLayoutData(fdfieldevaluate);
wFieldEvaluate.addSelectionListener(lsSel);
wFieldEvaluate.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
}
@Override
public void focusGained(FocusEvent e) {
Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
shell.setCursor(busy);
getPreviousFields();
shell.setCursor(null);
busy.dispose();
}
});
// Output Fieldame
wResultField = new LabelTextVar(variables, wTransformSettings, BaseMessages.getString(PKG, "RegexEvalDialog.ResultField.Label"), BaseMessages.getString(PKG, "RegexEvalDialog.ResultField.Tooltip"));
props.setLook(wResultField);
wResultField.addModifyListener(lsMod);
FormData fdResultField = new FormData();
fdResultField.left = new FormAttachment(0, 0);
fdResultField.top = new FormAttachment(wFieldEvaluate, margin);
fdResultField.right = new FormAttachment(100, 0);
wResultField.setLayoutData(fdResultField);
// Allow capture groups?
Label wlAllowCaptureGroups = new Label(wTransformSettings, SWT.RIGHT);
wlAllowCaptureGroups.setText(BaseMessages.getString(PKG, "RegexEvalDialog.AllowCaptureGroups.Label"));
props.setLook(wlAllowCaptureGroups);
FormData fdlAllowCaptureGroups = new FormData();
fdlAllowCaptureGroups.left = new FormAttachment(0, 0);
fdlAllowCaptureGroups.top = new FormAttachment(wResultField, margin);
fdlAllowCaptureGroups.right = new FormAttachment(middle, -margin);
wlAllowCaptureGroups.setLayoutData(fdlAllowCaptureGroups);
wAllowCaptureGroups = new Button(wTransformSettings, SWT.CHECK);
wAllowCaptureGroups.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.AllowCaptureGroups.Tooltip"));
props.setLook(wAllowCaptureGroups);
FormData fdAllowCaptureGroups = new FormData();
fdAllowCaptureGroups.left = new FormAttachment(middle, margin);
fdAllowCaptureGroups.top = new FormAttachment(wlAllowCaptureGroups, 0, SWT.CENTER);
fdAllowCaptureGroups.right = new FormAttachment(100, 0);
wAllowCaptureGroups.setLayoutData(fdAllowCaptureGroups);
wAllowCaptureGroups.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setFieldsEnabledStatus();
input.setChanged();
}
});
// Replace fields?
wlReplaceFields = new Label(wTransformSettings, SWT.RIGHT);
wlReplaceFields.setText(BaseMessages.getString(PKG, "RegexEvalDialog.ReplaceFields.Label"));
props.setLook(wlReplaceFields);
FormData fdlReplaceFields = new FormData();
fdlReplaceFields.left = new FormAttachment(0, 0);
fdlReplaceFields.top = new FormAttachment(wAllowCaptureGroups, margin);
fdlReplaceFields.right = new FormAttachment(middle, -margin);
wlReplaceFields.setLayoutData(fdlReplaceFields);
wReplaceFields = new Button(wTransformSettings, SWT.CHECK);
wReplaceFields.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.ReplaceFields.Tooltip"));
props.setLook(wReplaceFields);
FormData fdReplaceFields = new FormData();
fdReplaceFields.left = new FormAttachment(middle, margin);
fdReplaceFields.top = new FormAttachment(wlReplaceFields, 0, SWT.CENTER);
fdReplaceFields.right = new FormAttachment(100, 0);
wReplaceFields.setLayoutData(fdReplaceFields);
wReplaceFields.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// settings layout
FormData fdTransformSettings = new FormData();
fdTransformSettings.left = new FormAttachment(0, margin);
fdTransformSettings.top = new FormAttachment(wTransformName, margin);
fdTransformSettings.right = new FormAttachment(100, -margin);
wTransformSettings.setLayoutData(fdTransformSettings);
// ///////////////////////////////////////////////////////////
// / END OF TRANSFORM SETTINGS GROUP
// ///////////////////////////////////////////////////////////
// Script line
Label wlScript = new Label(wGeneralComp, SWT.NONE);
wlScript.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Javascript.Label"));
props.setLook(wlScript);
FormData fdlScript = new FormData();
fdlScript.left = new FormAttachment(0, 0);
fdlScript.top = new FormAttachment(wTransformSettings, margin);
wlScript.setLayoutData(fdlScript);
Button wbTestRegExScript = new Button(wGeneralComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbTestRegExScript);
wbTestRegExScript.setText(BaseMessages.getString(PKG, "RegexEvalDialog.TestScript.Label"));
FormData fdbTestRegExScript = new FormData();
fdbTestRegExScript.right = new FormAttachment(100, -margin);
fdbTestRegExScript.top = new FormAttachment(wTransformSettings, margin);
wbTestRegExScript.setLayoutData(fdbTestRegExScript);
wbTestRegExScript.addListener(SWT.Selection, e -> testRegExScript());
// Variable substitution?
Label wlUseVar = new Label(wGeneralComp, SWT.NONE);
wlUseVar.setText(BaseMessages.getString(PKG, "RegexEvalDialog.UseVar.Label"));
props.setLook(wlUseVar);
FormData fdlUseVar = new FormData();
fdlUseVar.left = new FormAttachment(0, margin);
fdlUseVar.bottom = new FormAttachment(100, 0);
wlUseVar.setLayoutData(fdlUseVar);
wUseVar = new Button(wGeneralComp, SWT.CHECK);
wUseVar.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.UseVar.Tooltip"));
props.setLook(wUseVar);
FormData fdUseVar = new FormData();
fdUseVar.left = new FormAttachment(wlUseVar, margin);
fdUseVar.top = new FormAttachment(wlUseVar, 0, SWT.CENTER);
wUseVar.setLayoutData(fdUseVar);
wUseVar.addSelectionListener(lsSel);
Composite wBottom = new Composite(wSash, SWT.NONE);
props.setLook(wBottom);
wScript = new StyledTextComp(variables, wGeneralComp, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
wScript.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Script.Label"));
props.setLook(wScript, Props.WIDGET_STYLE_FIXED);
wScript.addModifyListener(lsMod);
FormData fdScript = new FormData();
fdScript.left = new FormAttachment(0, 0);
fdScript.top = new FormAttachment(wbTestRegExScript, margin);
fdScript.right = new FormAttachment(100, -10);
fdScript.bottom = new FormAttachment(wUseVar, -2 * margin);
wScript.setLayoutData(fdScript);
FormLayout bottomLayout = new FormLayout();
bottomLayout.marginWidth = Const.FORM_MARGIN;
bottomLayout.marginHeight = Const.FORM_MARGIN;
wBottom.setLayout(bottomLayout);
Label wSeparator = new Label(wBottom, SWT.SEPARATOR | SWT.HORIZONTAL);
FormData 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, "RegexEvalDialog.Fields.Label"));
wlFields.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Fields.Tooltip"));
props.setLook(wlFields);
FormData 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[] columnInfo = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.NewField"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Type"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames()), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Length"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Precision"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Format"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Group"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Decimal"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Currency"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Nullif"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.IfNull"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.TrimType"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaString.trimTypeDesc, true) };
wFields = new TableView(variables, wBottom, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, columnInfo, fieldsRows, lsMod, props);
FormData 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);
FormData fdGeneralComp = new FormData();
fdGeneralComp.left = new FormAttachment(0, 0);
fdGeneralComp.top = new FormAttachment(0, 0);
fdGeneralComp.right = new FormAttachment(100, 0);
fdGeneralComp.bottom = new FormAttachment(100, 0);
wGeneralComp.setLayoutData(fdGeneralComp);
wGeneralComp.layout();
wGeneralTab.setControl(wGeneralComp);
props.setLook(wGeneralComp);
// ///////////////////////////////////////////////////////////
// / END OF GENERAL TAB
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF CONTENT TAB///
// /
CTabItem wContentTab = new CTabItem(wTabFolder, SWT.NONE);
wContentTab.setText(BaseMessages.getString(PKG, "RegexEvalDialog.ContentTab.TabTitle"));
FormLayout contentLayout = new FormLayout();
contentLayout.marginWidth = 3;
contentLayout.marginHeight = 3;
Composite wContentComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wContentComp);
wContentComp.setLayout(contentLayout);
// Transform RegexSettings grouping?
// ////////////////////////
// START OF RegexSettings GROUP
//
Group wRegexSettings = new Group(wContentComp, SWT.SHADOW_NONE);
props.setLook(wRegexSettings);
wRegexSettings.setText("Regex Settings");
FormLayout regexLayout = new FormLayout();
regexLayout.marginWidth = 10;
regexLayout.marginHeight = 10;
wRegexSettings.setLayout(regexLayout);
// Canon_Eq?
Label wlCanonEq = new Label(wRegexSettings, SWT.RIGHT);
wlCanonEq.setText(BaseMessages.getString(PKG, "RegexEvalDialog.CanonEq.Label"));
props.setLook(wlCanonEq);
FormData fdlCanonEq = new FormData();
fdlCanonEq.left = new FormAttachment(0, 0);
fdlCanonEq.top = new FormAttachment(wTransformSettings, margin);
fdlCanonEq.right = new FormAttachment(middle, -margin);
wlCanonEq.setLayoutData(fdlCanonEq);
wCanonEq = new Button(wRegexSettings, SWT.CHECK);
wCanonEq.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.CanonEq.Tooltip"));
props.setLook(wCanonEq);
FormData fdCanonEq = new FormData();
fdCanonEq.left = new FormAttachment(middle, 0);
fdCanonEq.top = new FormAttachment(wlCanonEq, 0, SWT.CENTER);
fdCanonEq.right = new FormAttachment(100, 0);
wCanonEq.setLayoutData(fdCanonEq);
wCanonEq.addSelectionListener(lsSel);
// CASE_INSENSITIVE?
Label wlCaseInsensitive = new Label(wRegexSettings, SWT.RIGHT);
wlCaseInsensitive.setText(BaseMessages.getString(PKG, "RegexEvalDialog.CaseInsensitive.Label"));
props.setLook(wlCaseInsensitive);
FormData fdlCaseInsensitive = new FormData();
fdlCaseInsensitive.left = new FormAttachment(0, 0);
fdlCaseInsensitive.top = new FormAttachment(wCanonEq, margin);
fdlCaseInsensitive.right = new FormAttachment(middle, -margin);
wlCaseInsensitive.setLayoutData(fdlCaseInsensitive);
wCaseInsensitive = new Button(wRegexSettings, SWT.CHECK);
wCaseInsensitive.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.CaseInsensitive.Tooltip"));
props.setLook(wCaseInsensitive);
FormData fdCaseInsensitive = new FormData();
fdCaseInsensitive.left = new FormAttachment(middle, 0);
fdCaseInsensitive.top = new FormAttachment(wlCaseInsensitive, 0, SWT.CENTER);
fdCaseInsensitive.right = new FormAttachment(100, 0);
wCaseInsensitive.setLayoutData(fdCaseInsensitive);
wCaseInsensitive.addSelectionListener(lsSel);
// COMMENT?
Label wlComment = new Label(wRegexSettings, SWT.RIGHT);
wlComment.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Comment.Label"));
props.setLook(wlComment);
FormData fdlComment = new FormData();
fdlComment.left = new FormAttachment(0, 0);
fdlComment.top = new FormAttachment(wCaseInsensitive, margin);
fdlComment.right = new FormAttachment(middle, -margin);
wlComment.setLayoutData(fdlComment);
wComment = new Button(wRegexSettings, SWT.CHECK);
wComment.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Comment.Tooltip"));
props.setLook(wComment);
FormData fdComment = new FormData();
fdComment.left = new FormAttachment(middle, 0);
fdComment.top = new FormAttachment(wlComment, 0, SWT.CENTER);
fdComment.right = new FormAttachment(100, 0);
wComment.setLayoutData(fdComment);
wComment.addSelectionListener(lsSel);
// DOTALL?
Label wlDotAll = new Label(wRegexSettings, SWT.RIGHT);
wlDotAll.setText(BaseMessages.getString(PKG, "RegexEvalDialog.DotAll.Label"));
props.setLook(wlDotAll);
FormData fdlDotAll = new FormData();
fdlDotAll.left = new FormAttachment(0, 0);
fdlDotAll.top = new FormAttachment(wComment, margin);
fdlDotAll.right = new FormAttachment(middle, -margin);
wlDotAll.setLayoutData(fdlDotAll);
wDotAll = new Button(wRegexSettings, SWT.CHECK);
wDotAll.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.DotAll.Tooltip"));
props.setLook(wDotAll);
FormData fdDotAll = new FormData();
fdDotAll.left = new FormAttachment(middle, 0);
fdDotAll.top = new FormAttachment(wlDotAll, 0, SWT.CENTER);
fdDotAll.right = new FormAttachment(100, 0);
wDotAll.setLayoutData(fdDotAll);
wDotAll.addSelectionListener(lsSel);
// MULTILINE?
Label wlMultiline = new Label(wRegexSettings, SWT.RIGHT);
wlMultiline.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Multiline.Label"));
props.setLook(wlMultiline);
FormData fdlMultiline = new FormData();
fdlMultiline.left = new FormAttachment(0, 0);
fdlMultiline.top = new FormAttachment(wDotAll, margin);
fdlMultiline.right = new FormAttachment(middle, -margin);
wlMultiline.setLayoutData(fdlMultiline);
wMultiline = new Button(wRegexSettings, SWT.CHECK);
wMultiline.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Multiline.Tooltip"));
props.setLook(wMultiline);
FormData fdMultiline = new FormData();
fdMultiline.left = new FormAttachment(middle, 0);
fdMultiline.top = new FormAttachment(wlMultiline, 0, SWT.CENTER);
fdMultiline.right = new FormAttachment(100, 0);
wMultiline.setLayoutData(fdMultiline);
wMultiline.addSelectionListener(lsSel);
// UNICODE?
Label wlUnicode = new Label(wRegexSettings, SWT.RIGHT);
wlUnicode.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Unicode.Label"));
props.setLook(wlUnicode);
FormData fdlUnicode = new FormData();
fdlUnicode.left = new FormAttachment(0, 0);
fdlUnicode.top = new FormAttachment(wMultiline, margin);
fdlUnicode.right = new FormAttachment(middle, -margin);
wlUnicode.setLayoutData(fdlUnicode);
wUnicode = new Button(wRegexSettings, SWT.CHECK);
wUnicode.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Unicode.Tooltip"));
props.setLook(wUnicode);
FormData fdUnicode = new FormData();
fdUnicode.left = new FormAttachment(middle, 0);
fdUnicode.top = new FormAttachment(wlUnicode, 0, SWT.CENTER);
fdUnicode.right = new FormAttachment(100, 0);
wUnicode.setLayoutData(fdUnicode);
wUnicode.addSelectionListener(lsSel);
// UNIX?
Label wlUnix = new Label(wRegexSettings, SWT.RIGHT);
wlUnix.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Unix.Label"));
props.setLook(wlUnix);
FormData fdlUnix = new FormData();
fdlUnix.left = new FormAttachment(0, 0);
fdlUnix.top = new FormAttachment(wUnicode, margin);
fdlUnix.right = new FormAttachment(middle, -margin);
wlUnix.setLayoutData(fdlUnix);
wUnix = new Button(wRegexSettings, SWT.CHECK);
wUnix.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Unix.Tooltip"));
props.setLook(wUnix);
FormData fdUnix = new FormData();
fdUnix.left = new FormAttachment(middle, 0);
fdUnix.top = new FormAttachment(wlUnix, 0, SWT.CENTER);
fdUnix.right = new FormAttachment(100, 0);
wUnix.setLayoutData(fdUnix);
wUnix.addSelectionListener(lsSel);
FormData fdRegexSettings = new FormData();
fdRegexSettings.left = new FormAttachment(0, margin);
fdRegexSettings.top = new FormAttachment(wTransformSettings, margin);
fdRegexSettings.right = new FormAttachment(100, -margin);
wRegexSettings.setLayoutData(fdRegexSettings);
// ///////////////////////////////////////////////////////////
// / END OF RegexSettings GROUP
// ///////////////////////////////////////////////////////////
FormData 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(wContentComp);
wContentComp.layout();
wContentTab.setControl(wContentComp);
// ///////////////////////////////////////////////////////////
// / END OF CONTENT TAB
// ///////////////////////////////////////////////////////////
FormData fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wTransformName, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(100, 0);
wTabFolder.setLayoutData(fdTabFolder);
FormData 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);
FormData fdSash = new FormData();
fdSash.left = new FormAttachment(0, 0);
fdSash.top = new FormAttachment(wTransformName, 0);
fdSash.right = new FormAttachment(100, 0);
fdSash.bottom = new FormAttachment(wOk, -margin);
wSash.setLayoutData(fdSash);
wSash.setWeights(60, 40);
// Add listeners
wTabFolder.setSelection(0);
getData();
setFieldsEnabledStatus();
input.setChanged(changed);
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
return transformName;
}
use of org.apache.hop.core.variables.Variables in project hop by apache.
the class BasePropertyParsingTest method setFields.
/**
* Declare fields for test.
*/
protected void setFields(PropertyInputField... fields) throws Exception {
meta.setInputFields(fields);
meta.getFields(data.outputRowMeta, meta.getName(), null, null, new Variables(), null);
data.convertRowMeta = data.outputRowMeta.cloneToType(IValueMeta.TYPE_STRING);
}
use of org.apache.hop.core.variables.Variables in project hop by apache.
the class CreditCardValidatorMetaTest method testGetFields.
@Test
public void testGetFields() throws HopTransformException {
CreditCardValidatorMeta meta = new CreditCardValidatorMeta();
meta.setDefault();
meta.setResultFieldName("The Result Field");
meta.setCardType("The Card Type Field");
meta.setNotValidMsg("Is Card Valid");
RowMeta rowMeta = new RowMeta();
meta.getFields(rowMeta, "this transform", null, null, new Variables(), null);
assertEquals(3, rowMeta.size());
assertEquals("The Result Field", rowMeta.getValueMeta(0).getName());
assertEquals(IValueMeta.TYPE_BOOLEAN, rowMeta.getValueMeta(0).getType());
assertEquals("this transform", rowMeta.getValueMeta(0).getOrigin());
assertEquals("The Card Type Field", rowMeta.getValueMeta(1).getName());
assertEquals(IValueMeta.TYPE_STRING, rowMeta.getValueMeta(1).getType());
assertEquals("this transform", rowMeta.getValueMeta(1).getOrigin());
assertEquals("Is Card Valid", rowMeta.getValueMeta(2).getName());
assertEquals(IValueMeta.TYPE_STRING, rowMeta.getValueMeta(2).getType());
assertEquals("this transform", rowMeta.getValueMeta(2).getOrigin());
}
Aggregations