use of org.talend.daikon.properties.presentation.Form in project tdi-studio-se by Talend.
the class ComponentsUtilsTest method testGetParameterValue.
@Test
public void testGetParameterValue() {
//$NON-NLS-1$
TestProperties props = (TestProperties) new TestProperties("test").init();
//$NON-NLS-1$
props.userId.setValue("user");
Form form = props.getForm(Form.MAIN);
Element fakeElement = new FakeElement(form.getName());
INode node = createSFTestNode();
// If it is a fake element, do not add quotes.
Object parameterValue = ComponentsUtils.getParameterValue(fakeElement, props.userId, null);
//$NON-NLS-1$
assertEquals("user", parameterValue);
// If the property value is context mode, do not add quotes.
//$NON-NLS-1$
props.userId.setValue("context.user");
parameterValue = ComponentsUtils.getParameterValue(node, props.userId, null);
//$NON-NLS-1$
assertEquals("context.user", parameterValue);
// If the property value is changed by user, do not add quotes.
props.userId.setTaggedValue(UpdatesConstants.CHANGED_BY_USER, true);
//$NON-NLS-1$
props.userId.setValue("user");
parameterValue = ComponentsUtils.getParameterValue(node, props.userId, null);
//$NON-NLS-1$
assertEquals("user", parameterValue);
// Otherwise will add quotes.
props.userId.setTaggedValue(UpdatesConstants.CHANGED_BY_USER, false);
parameterValue = ComponentsUtils.getParameterValue(node, props.userId, null);
//$NON-NLS-1$
assertEquals("\"user\"", parameterValue);
// If value is NULL, return "".
props.userId.setValue(null);
parameterValue = ComponentsUtils.getParameterValue(node, props.userId, null);
//$NON-NLS-1$
assertEquals("\"\"", parameterValue);
}
use of org.talend.daikon.properties.presentation.Form in project tdi-studio-se by Talend.
the class ComponentsUtilsTest method testGetParametersFromForm.
@Test
public void testGetParametersFromForm() {
//$NON-NLS-1$
ComponentProperties props = (ComponentProperties) new TestProperties("test").init();
Form form = props.getForm(Form.MAIN);
/*
* Test wizard
*/
Element element = new FakeElement(form.getName());
// Test readonly case
List<ElementParameter> parameters = ComponentsUtils.getParametersFromForm(element, false, null, props, form);
for (ElementParameter parameter : parameters) {
assertFalse(parameter.isReadOnly());
}
element.setReadOnly(true);
parameters = ComponentsUtils.getParametersFromForm(element, false, null, props, form);
for (ElementParameter parameter : parameters) {
assertTrue(parameter.isReadOnly());
}
/*
* Test component
*/
// Test parameter initialization case (mainly to test ComponentsUtils.getParameterValue() method).
checkParameterInitializationStatus(true);
checkParameterInitializationStatus(false);
}
use of org.talend.daikon.properties.presentation.Form in project tdi-studio-se by Talend.
the class ComponentsUtilsTest method checkParameterInitializationStatus.
private void checkParameterInitializationStatus(boolean isInitializing) {
INode node = createSFTestNode();
ComponentProperties props = node.getComponentProperties();
props.setValueEvaluator(null);
Form form = props.getForm(Form.ADVANCED);
List<ElementParameter> parameters = ComponentsUtils.getParametersFromForm(node, isInitializing, null, props, form);
checkParameterInitializationStatus(parameters, isInitializing);
}
use of org.talend.daikon.properties.presentation.Form in project tdi-studio-se by Talend.
the class SchemaProperties method setupLayout.
@Override
public void setupLayout() {
super.setupLayout();
//$NON-NLS-1$
Form schemaForm = Form.create(this, Form.MAIN);
schemaForm.addRow(widget(schema).setWidgetType(Widget.SCHEMA_EDITOR_WIDGET_TYPE));
//$NON-NLS-1$
Form schemaRefForm = Form.create(this, Form.REFERENCE);
schemaRefForm.addRow(widget(schema).setWidgetType(Widget.SCHEMA_REFERENCE_WIDGET_TYPE));
}
use of org.talend.daikon.properties.presentation.Form in project tdi-studio-se by Talend.
the class TestContactProperties method setupLayout.
@Override
public void setupLayout() {
super.setupLayout();
Form form = Form.create(this, Form.MAIN);
form.addRow(mobile);
form.addRow(email);
}
Aggregations