use of org.knime.core.node.workflow.FlowVariable.Scope in project knime-core by knime.
the class WorkflowVariablesEditDialog method createDialogArea.
/**
* {@inheritDoc}
*/
@Override
protected Control createDialogArea(final Composite parent) {
parent.getShell().setText("Add/Edit Workflow Variable");
Composite twoColComp = new Composite(parent, SWT.NONE);
twoColComp.setLayout(new GridLayout(3, true));
GridData horizontalFill = new GridData(SWT.FILL, SWT.CENTER, true, false);
horizontalFill.horizontalSpan = 2;
// first row: node settings name
Label varNameLabel = new Label(twoColComp, SWT.NONE);
varNameLabel.setText("Variable name: ");
m_varNameCtrl = new Text(twoColComp, SWT.BORDER);
m_varNameCtrl.setLayoutData(horizontalFill);
// add validation (at least some basic "text length > 0)
m_varNameCtrl.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent arg0) {
String text = m_varNameCtrl.getText();
for (Scope s : FlowVariable.Scope.values()) {
if (!Scope.Flow.equals(s) && text.startsWith(s.getPrefix())) {
showError("Flow variables must not start with \"" + s.getPrefix() + "\"!");
m_varNameCtrl.setText("");
}
}
}
});
// second row: parameter type
Label typeLabel = new Label(twoColComp, SWT.NONE);
typeLabel.setText("Variable Type:");
m_typeSelectionCtrl = new Combo(twoColComp, SWT.DROP_DOWN | SWT.READ_ONLY);
for (FlowVariable.Type t : Arrays.asList(Type.DOUBLE, Type.INTEGER, Type.STRING)) {
m_typeSelectionCtrl.add(t.name());
}
m_typeSelectionCtrl.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent arg0) {
widgetSelected(arg0);
}
@Override
public void widgetSelected(final SelectionEvent arg0) {
m_type = FlowVariable.Type.valueOf(m_typeSelectionCtrl.getItem(m_typeSelectionCtrl.getSelectionIndex()));
}
});
m_typeSelectionCtrl.setLayoutData(horizontalFill);
m_typeSelectionCtrl.select(0);
// third row: data set parameter name
Label defaultValueLabel = new Label(twoColComp, SWT.NONE);
defaultValueLabel.setText("Default value: ");
m_varDefaultValueCtrl = new Text(twoColComp, SWT.BORDER);
m_varDefaultValueCtrl.setLayoutData(horizontalFill);
return twoColComp;
}
Aggregations