Search in sources :

Example 21 with Form

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);
}
Also used : INode(org.talend.core.model.process.INode) Form(org.talend.daikon.properties.presentation.Form) Element(org.talend.core.model.process.Element) FakeElement(org.talend.designer.core.model.FakeElement) FakeElement(org.talend.designer.core.model.FakeElement) Test(org.junit.Test)

Example 22 with Form

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);
}
Also used : GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) ComponentProperties(org.talend.components.api.properties.ComponentProperties) Form(org.talend.daikon.properties.presentation.Form) Element(org.talend.core.model.process.Element) FakeElement(org.talend.designer.core.model.FakeElement) FakeElement(org.talend.designer.core.model.FakeElement) Test(org.junit.Test)

Example 23 with Form

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);
}
Also used : INode(org.talend.core.model.process.INode) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) ComponentProperties(org.talend.components.api.properties.ComponentProperties) Form(org.talend.daikon.properties.presentation.Form)

Example 24 with Form

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));
}
Also used : Form(org.talend.daikon.properties.presentation.Form)

Example 25 with Form

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);
}
Also used : Form(org.talend.daikon.properties.presentation.Form)

Aggregations

Form (org.talend.daikon.properties.presentation.Form)29 ComponentProperties (org.talend.components.api.properties.ComponentProperties)10 INode (org.talend.core.model.process.INode)7 ElementParameter (org.talend.designer.core.model.components.ElementParameter)7 GenericElementParameter (org.talend.designer.core.generic.model.GenericElementParameter)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 NamedThing (org.talend.daikon.NamedThing)4 Widget (org.talend.daikon.properties.presentation.Widget)4 FakeElement (org.talend.designer.core.model.FakeElement)4 List (java.util.List)3 ComponentService (org.talend.components.api.service.ComponentService)3 IComponent (org.talend.core.model.components.IComponent)3 Element (org.talend.core.model.process.Element)3 IElementParameter (org.talend.core.model.process.IElementParameter)3 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)3 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)3 PresentationItem (org.talend.daikon.properties.PresentationItem)3 Property (org.talend.daikon.properties.property.Property)3 Schema (org.apache.avro.Schema)2