Search in sources :

Example 31 with Element

use of org.talend.core.model.process.Element in project tdi-studio-se by Talend.

the class ProjectSettingManager method createImplicitContextLoadElement.

/**
     *
     * create implicitContextLoad Element for project
     *
     * @param pro
     * @return
     */
public static Element createImplicitContextLoadElement(Project pro) {
    ImplicitContextSettings implicit = pro.getEmfProject().getImplicitContextSettings();
    if (implicit == null) {
        loadImplicitContextLoadPreferenceToProject(pro);
    }
    Element elem = (Element) pro.getInitialContextLoad();
    if (elem == null) {
        elem = new ImplicitContextLoadElement();
        ProjectSettingManager.createImplicitContextLoadParameters(elem);
        pro.setInitialContextLoad(elem);
    }
    return elem;
}
Also used : Element(org.talend.core.model.process.Element) IElement(org.talend.core.model.process.IElement) ImplicitContextSettings(org.talend.core.model.properties.ImplicitContextSettings)

Example 32 with Element

use of org.talend.core.model.process.Element in project tdi-studio-se by Talend.

the class GenericDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite comp = new Composite(composite, SWT.NONE);
    comp.setLayoutData(new GridData(GridData.FILL_BOTH));
    comp.setLayout(new FormLayout());
    Element element = new FakeElement(form.getName());
    dynamicComposite = new DynamicComposite(comp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS, EComponentCategory.BASIC, element, true, comp.getBackground(), form, true);
    FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, 0);
    data.bottom = new FormAttachment(100, 0);
    dynamicComposite.setLayoutData(data);
    dynamicComposite.setConnectionItem(connectionItem);
    init();
    return parent;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) Element(org.talend.core.model.process.Element) FakeElement(org.talend.designer.core.model.FakeElement) GridData(org.eclipse.swt.layout.GridData) FakeElement(org.talend.designer.core.model.FakeElement) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 33 with Element

use of org.talend.core.model.process.Element in project tdi-studio-se by Talend.

the class ComponentsUtilsTest method testGetFormalPossibleValues.

@Test
public void testGetFormalPossibleValues() {
    ComponentService componentService = ComponentsUtils.getComponentService();
    //$NON-NLS-1$
    ComponentProperties props = (ComponentProperties) new TestProperties("test").init();
    Form form = props.getForm(Form.MAIN);
    Element element = new FakeElement(form.getName());
    Widget testWidget = null;
    Property testProperty = null;
    Collection<Widget> widgets = form.getWidgets();
    Iterator<Widget> widgetsIterator = widgets.iterator();
    while (widgetsIterator.hasNext()) {
        Widget widget = widgetsIterator.next();
        NamedThing content = widget.getContent();
        if (content instanceof Property) {
            testWidget = widget;
            testProperty = (Property) content;
            break;
        }
    }
    assertNotNull(testWidget);
    assertNotNull(testProperty);
    // Test NamedThing type
    List<NamedThing> namedThings = new ArrayList<>();
    namedThings.add(new SimpleNamedThing("p1", "Test P1"));
    namedThings.add(new SimpleNamedThing("p2", "Test P2"));
    namedThings.add(new SimpleNamedThing("p3", "Test P3"));
    testProperty.setPossibleValues(namedThings);
    GenericElementParameter param = new GenericElementParameter(element, props, form, testWidget, componentService);
    param.setPossibleValues(testProperty.getPossibleValues());
    List<NamedThing> possibleValues = ComponentsUtils.getFormalPossibleValues(param);
    assertEquals(3, possibleValues.size());
    namedThings.retainAll(possibleValues);
    assertEquals(3, namedThings.size());
    // Test Integer type which is not support yet
    List<Integer> ints = new ArrayList<>();
    ints.add(1);
    ints.add(2);
    ints.add(3);
    testProperty.setPossibleValues(ints);
    param = new GenericElementParameter(element, props, form, testWidget, componentService);
    param.setPossibleValues(testProperty.getPossibleValues());
    possibleValues = ComponentsUtils.getFormalPossibleValues(param);
    assertEquals(0, possibleValues.size());
    // Test StringProperty
    testWidget = null;
    StringProperty testStringProperty = null;
    widgetsIterator = widgets.iterator();
    while (widgetsIterator.hasNext()) {
        Widget widget = widgetsIterator.next();
        NamedThing content = widget.getContent();
        if (content instanceof StringProperty) {
            testWidget = widget;
            testStringProperty = (StringProperty) content;
            break;
        }
    }
    assertNotNull(testWidget);
    assertNotNull(testStringProperty);
    testStringProperty.setPossibleNamedThingValues(namedThings);
    param = new GenericElementParameter(element, props, form, testWidget, componentService);
    param.setPossibleValues(testStringProperty.getPossibleValues());
    possibleValues = ComponentsUtils.getFormalPossibleValues(param);
    assertEquals(3, possibleValues.size());
    List<String> pvNames = new ArrayList<>();
    for (NamedThing pv : possibleValues) {
        pvNames.add(pv.getName());
    }
    for (NamedThing nt : namedThings) {
        assertTrue(pvNames.contains(nt.getName()));
    }
}
Also used : 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) Widget(org.talend.daikon.properties.presentation.Widget) ArrayList(java.util.ArrayList) StringProperty(org.talend.daikon.properties.property.StringProperty) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) FakeElement(org.talend.designer.core.model.FakeElement) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) ComponentService(org.talend.components.api.service.ComponentService) StringProperty(org.talend.daikon.properties.property.StringProperty) Property(org.talend.daikon.properties.property.Property) Test(org.junit.Test)

Example 34 with Element

use of org.talend.core.model.process.Element 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 35 with Element

use of org.talend.core.model.process.Element 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)

Aggregations

Element (org.talend.core.model.process.Element)37 IProcess (org.talend.core.model.process.IProcess)11 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)11 IElementParameter (org.talend.core.model.process.IElementParameter)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 IElement (org.talend.core.model.process.IElement)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 TalendPropertyTabDescriptor (org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor)4 FakeElement (org.talend.designer.core.model.FakeElement)4 Process (org.talend.designer.core.ui.editor.process.Process)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 Control (org.eclipse.swt.widgets.Control)3 IEditorPart (org.eclipse.ui.IEditorPart)3 Test (org.junit.Test)3 IProcess2 (org.talend.core.model.process.IProcess2)3 EmptyRepositoryObject (org.talend.core.model.repository.EmptyRepositoryObject)3 Form (org.talend.daikon.properties.presentation.Form)3 ChangeValuesFromRepository (org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository)3