Search in sources :

Example 61 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class JavaProcessUtilTest method testGetChildrenModules_noChildren.

@Test
public void testGetChildrenModules_noChildren() {
    INode node = mock(INode.class);
    IComponent component = mock(IComponent.class);
    when(node.getComponent()).thenReturn(component);
    when(component.getName()).thenReturn("tLogRow");
    List<ModuleNeeded> childrenModules = JavaProcessUtil.getChildrenModules(node, Collections.emptySet(), false);
    assertTrue(childrenModules.isEmpty());
}
Also used : INode(org.talend.core.model.process.INode) IComponent(org.talend.core.model.components.IComponent) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Test(org.junit.Test)

Example 62 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class NodeTest method testGetNodeConnectorsShowIf1FlowConnector.

@Test
public void testGetNodeConnectorsShowIf1FlowConnector() {
    Process process = new Process(new FakePropertyImpl());
    IComponent sourceCom = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
    Node node = new Node(sourceCom, process);
    // create node connector for test
    List<INodeConnector> listConnector = new ArrayList<>();
    NodeConnector connector = new NodeConnector(node);
    connector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
    connector.setName(EConnectionType.FLOW_MAIN.getName());
    connector.setMaxLinkOutput(1);
    connector.setShowIf("SHOW_FLOW_CONNECTOR == 'true'");
    listConnector.add(connector);
    node.setListConnector(listConnector);
    // create a test param with default value 'false'
    IElementParameter param = addShowIfParam(node);
    Assert.assertNull(node.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()));
    Assert.assertNull(node.getConnectorFromType(EConnectionType.FLOW_MAIN));
    Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 0);
    // make connector show if to 'true'
    param.setValue(true);
    Assert.assertNotNull(node.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()));
    Assert.assertNotNull(node.getConnectorFromType(EConnectionType.FLOW_MAIN));
    Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 1);
}
Also used : FakePropertyImpl(org.talend.core.model.repository.FakePropertyImpl) INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) INodeConnector(org.talend.core.model.process.INodeConnector) Test(org.junit.Test)

Example 63 with IComponent

use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.

the class NodeTest method testGetNodeConnectorsShowIf2FlowConnector.

@Test
public void testGetNodeConnectorsShowIf2FlowConnector() {
    Process process = new Process(new FakePropertyImpl());
    IComponent sourceCom = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
    Node node = new Node(sourceCom, process);
    // create node connector for test
    List<INodeConnector> listConnector = new ArrayList<>();
    NodeConnector connector1 = new NodeConnector(node);
    connector1.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
    connector1.setName(EConnectionType.FLOW_MAIN.getName());
    connector1.setMaxLinkOutput(1);
    listConnector.add(connector1);
    connector1.setShowIf("SHOW_FLOW_CONNECTOR == 'true'");
    NodeConnector connector2 = new NodeConnector(node);
    connector2.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
    connector2.setName(EConnectionType.FLOW_MAIN.getName());
    connector2.setMaxLinkInput(-1);
    connector2.setMaxLinkOutput(-1);
    connector2.setShowIf("SHOW_FLOW_CONNECTOR == 'false'");
    listConnector.add(connector2);
    node.setListConnector(listConnector);
    // create a test param with default value 'false'
    IElementParameter param = addShowIfParam(node);
    Assert.assertTrue(node.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()) == connector2);
    Assert.assertTrue(node.getConnectorFromType(EConnectionType.FLOW_MAIN) == connector2);
    Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 1);
    // make connector show if to 'true'
    param.setValue(true);
    Assert.assertTrue(node.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()) == connector1);
    Assert.assertTrue(node.getConnectorFromType(EConnectionType.FLOW_MAIN) == connector1);
    Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 1);
    // connector with same name should have the same current input/output
    connector1.setCurLinkNbInput(10);
    connector1.setCurLinkNbOutput(100);
    Assert.assertEquals(connector1.getCurLinkNbInput(), 10);
    Assert.assertEquals(connector1.getCurLinkNbOutput(), 100);
    Assert.assertEquals(connector2.getCurLinkNbInput(), 10);
    Assert.assertEquals(connector2.getCurLinkNbOutput(), 100);
}
Also used : FakePropertyImpl(org.talend.core.model.repository.FakePropertyImpl) INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) INodeConnector(org.talend.core.model.process.INodeConnector) Test(org.junit.Test)

Example 64 with IComponent

use of org.talend.core.model.components.IComponent in project tesb-studio-se by Talend.

the class CamelEditorDropTargetListener method extractComponents.

/**
     * Extracts the components which have the same palette type as process. Added by Marvin Wang on Feb 27, 2013.
     *
     * @param neededComponents
     * @return
     */
protected List<IComponent> extractComponents(List<IComponent> neededComponents) {
    if (neededComponents != null && neededComponents.size() > 0) {
        Iterator<IComponent> componentsIterator = neededComponents.iterator();
        while (componentsIterator.hasNext()) {
            IComponent component = componentsIterator.next();
            String compType = component.getPaletteType();
            if (compType != null && !compType.equals(editor.getProcess().getComponentsType())) {
                componentsIterator.remove();
            }
        }
    }
    return neededComponents;
}
Also used : IComponent(org.talend.core.model.components.IComponent)

Example 65 with IComponent

use of org.talend.core.model.components.IComponent in project tesb-studio-se by Talend.

the class CamelComponentsHandler method filterComponents.

// private List<IComponent> camelComponents = new ArrayList<IComponent>();
@Override
public List<IComponent> filterComponents(List<IComponent> allComponents) {
    List<IComponent> camelComponents = new ArrayList<IComponent>();
    if (allComponents == null || allComponents.isEmpty()) {
        return camelComponents;
    }
    final String categoryName = extractComponentsCategory().getName();
    for (IComponent component : allComponents) {
        if (categoryName.equals(component.getPaletteType())) {
            camelComponents.add(component);
        }
    }
    return camelComponents;
}
Also used : IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList)

Aggregations

IComponent (org.talend.core.model.components.IComponent)146 Node (org.talend.designer.core.ui.editor.nodes.Node)54 ArrayList (java.util.ArrayList)47 IElementParameter (org.talend.core.model.process.IElementParameter)36 Process (org.talend.designer.core.ui.editor.process.Process)36 Test (org.junit.Test)35 INode (org.talend.core.model.process.INode)33 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)22 List (java.util.List)15 Property (org.talend.core.model.properties.Property)15 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)15 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)13 IComponentsFactory (org.talend.core.model.components.IComponentsFactory)12 Connection (org.talend.designer.core.ui.editor.connections.Connection)12 HashMap (java.util.HashMap)11 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)10 DataNode (org.talend.designer.core.model.process.DataNode)10 HashSet (java.util.HashSet)9 IConnection (org.talend.core.model.process.IConnection)9 Rectangle (org.eclipse.swt.graphics.Rectangle)8