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;
}
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;
}
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()));
}
}
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);
}
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);
}
Aggregations