Search in sources :

Example 11 with NodeConnector

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

the class SimpleOutputComponent method createConnectors.

@Override
public List<? extends INodeConnector> createConnectors(INode node) {
    List<NodeConnector> nodeConnectors = new ArrayList<NodeConnector>();
    NodeConnector connector = createBaseConnector(node, EConnectionType.FLOW_MAIN);
    connector.setMaxLinkInput(1);
    connector.setMaxLinkOutput(1);
    nodeConnectors.add(connector);
    return nodeConnectors;
}
Also used : NodeConnector(org.talend.designer.core.model.components.NodeConnector) INodeConnector(org.talend.core.model.process.INodeConnector) ArrayList(java.util.ArrayList)

Example 12 with NodeConnector

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

the class ConnectionCreateActionTest method setUp.

/**
     * DOC Administrator Comment method "setUp".
     * 
     * @throws java.lang.Exception
     */
@Before
public void setUp() throws Exception {
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    IProcess2 process = new Process(property);
    IComponent sourceCom = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
    IComponent targetCom = ComponentsFactoryProvider.getInstance().get("tMysqlOutput", ComponentCategory.CATEGORY_4_DI.getName());
    node = new Node(sourceCom, process);
    node.setLabel("tMysqlInput_1");
    curNodeConnector = new NodeConnector(node);
    curNodeConnector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
    connecType = curNodeConnector.getDefaultConnectionType();
    Node target = new Node(targetCom, process);
    IMetadataTable table = createSimpleMetadata();
    table.setLabel("JOBS");
    table.setTableName("JOBS");
    table.setAttachedConnector("FLOW");
    List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
    metadataList.add(table);
    node.setMetadataList(metadataList);
    Connection conn = new Connection(node, target, EConnectionType.FLOW_MAIN, "FLOW", "JOBS", "row1", false);
    List<Connection> connList = new ArrayList<Connection>();
    connList.add(conn);
    target.setIncomingConnections(connList);
    node.setOutgoingConnections(connList);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IProcess2(org.talend.core.model.process.IProcess2) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) Process(org.talend.designer.core.ui.editor.process.Process) Property(org.talend.core.model.properties.Property) Before(org.junit.Before)

Example 13 with NodeConnector

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

the class NodeTest method testGetNodeConnectorsShowIf2FlowConnectorWithName.

@Test
public void testGetNodeConnectorsShowIf2FlowConnectorWithName() {
    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("FILTER");
    listConnector.add(connector1);
    connector1.setShowIf("SHOW_FLOW_CONNECTOR == 'true'");
    NodeConnector connector2 = new NodeConnector(node);
    connector2.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
    connector2.setName("REJECT");
    connector2.setShowIf("SHOW_FLOW_CONNECTOR == 'true'");
    listConnector.add(connector2);
    node.setListConnector(listConnector);
    // create a test param with default value 'false'
    IElementParameter param = addShowIfParam(node);
    Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 0);
    // make connector show if to 'true'
    param.setValue(true);
    Assert.assertTrue(node.getConnectorFromName("FILTER") == connector1);
    Assert.assertTrue(node.getConnectorFromName("REJECT") == connector2);
    Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 2);
    // set CurLinkNbInput/Output should not affact other connector with same type but different name
    connector1.setCurLinkNbInput(10);
    connector1.setCurLinkNbOutput(100);
    Assert.assertEquals(connector1.getCurLinkNbInput(), 10);
    Assert.assertEquals(connector1.getCurLinkNbOutput(), 100);
    Assert.assertEquals(connector2.getCurLinkNbInput(), 0);
    Assert.assertEquals(connector2.getCurLinkNbOutput(), 0);
}
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)

Aggregations

INodeConnector (org.talend.core.model.process.INodeConnector)13 NodeConnector (org.talend.designer.core.model.components.NodeConnector)13 ArrayList (java.util.ArrayList)10 Process (org.talend.designer.core.ui.editor.process.Process)5 IComponent (org.talend.core.model.components.IComponent)4 Test (org.junit.Test)3 IElementParameter (org.talend.core.model.process.IElementParameter)3 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)3 RGB (org.eclipse.swt.graphics.RGB)2 Before (org.junit.Before)2 EConnectionType (org.talend.core.model.process.EConnectionType)2 IConnection (org.talend.core.model.process.IConnection)2 INode (org.talend.core.model.process.INode)2 Connection (org.talend.designer.core.ui.editor.connections.Connection)2 Node (org.talend.designer.core.ui.editor.nodes.Node)2 List (java.util.List)1 Point (org.eclipse.draw2d.geometry.Point)1 EList (org.eclipse.emf.common.util.EList)1 Connector (org.talend.components.api.component.Connector)1 ConnectorTopology (org.talend.components.api.component.ConnectorTopology)1