Search in sources :

Example 6 with NodeConnector

use of org.talend.designer.core.model.components.NodeConnector 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 7 with NodeConnector

use of org.talend.designer.core.model.components.NodeConnector 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 8 with NodeConnector

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

the class ValidationRulesUtil method createRejectConnector.

public static INodeConnector createRejectConnector(INode node) {
    INodeConnector rejectConnector = null;
    if (isHasValidationRule(node)) {
        boolean isHas = false;
        for (INodeConnector connector : node.getListConnector()) {
            if ("VALIDATION_REJECT".equals(connector.getName())) {
                //$NON-NLS-1$
                isHas = true;
            }
        }
        if (!isHas) {
            rejectConnector = new NodeConnector(node);
            rejectConnector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
            //$NON-NLS-1$
            rejectConnector.setLinkName("Validation Reject");
            //$NON-NLS-1$
            rejectConnector.setMenuName("Validation Reject");
            rejectConnector.setMaxLinkInput(-1);
            rejectConnector.setMinLinkInput(0);
            rejectConnector.setMaxLinkOutput(1);
            rejectConnector.setMinLinkOutput(0);
            rejectConnector.setBuiltIn(false);
            rejectConnector.setMultiSchema(false);
            rejectConnector.setMergeAllowDifferentSchema(false);
            //$NON-NLS-1$
            rejectConnector.setName("VALIDATION_REJECT");
            RGB rgb = new RGB(243, 99, 0);
            rejectConnector.addConnectionProperty(EConnectionType.FLOW_MAIN, rgb, 2);
            rejectConnector.getConnectionProperty(EConnectionType.FLOW_MAIN).setRGB(rgb);
            //$NON-NLS-1$
            rejectConnector.setBaseSchema("FLOW");
            rejectConnector.addConnectionProperty(EConnectionType.FLOW_REF, rgb, 2);
            rejectConnector.addConnectionProperty(EConnectionType.FLOW_MERGE, rgb, 2);
            if (!node.getListConnector().contains(rejectConnector)) {
                ((List<INodeConnector>) node.getListConnector()).add(rejectConnector);
            }
        }
    }
    return rejectConnector;
}
Also used : INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List) RGB(org.eclipse.swt.graphics.RGB) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 9 with NodeConnector

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

the class Component method addStandardType.

/**
     * Add default connector type, if not already defined by component.
     *
     * @param listConnector
     * @param type
     * @param parentNode
     * @return
     */
private INodeConnector addStandardType(List<INodeConnector> listConnector, EConnectionType type, INode parentNode) {
    NodeConnector nodeConnector = new NodeConnector(parentNode);
    nodeConnector.setName(type.getName());
    nodeConnector.setBaseSchema(type.getName());
    nodeConnector.setDefaultConnectionType(type);
    nodeConnector.setLinkName(type.getDefaultLinkName());
    nodeConnector.setMenuName(type.getDefaultMenuName());
    nodeConnector.addConnectionProperty(type, type.getRGB(), type.getDefaultLineStyle());
    listConnector.add(nodeConnector);
    return nodeConnector;
}
Also used : INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector)

Example 10 with NodeConnector

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

the class JobletUtil method createConnectors.

public List<INodeConnector> createConnectors(INode node, IProcess2 process) {
    List<INodeConnector> listConnector = new ArrayList<INodeConnector>();
    if (process == null) {
        return listConnector;
    }
    if (process.getProperty().getItem() instanceof JobletProcessItem) {
        JobletProcess jobletProcess = ((JobletProcessItem) process.getProperty().getItem()).getJobletProcess();
        EList<JobletNode> jobletLinks = jobletProcess.getJobletNodes();
        INodeConnector nodeConnector;
        int nbInput = 0;
        int nbOutput = 0;
        int jobletNbInput = 0;
        for (JobletNode jNode : jobletLinks) {
            if (jNode.isInput()) {
                jobletNbInput++;
            }
        }
        boolean multipleInput = jobletNbInput > 1;
        for (JobletNode jNode : jobletLinks) {
            String name = ComponentUtilities.getNodeUniqueName(jNode);
            if (jNode.isTrigger()) {
            // createTriggerConnector(listConnector, node);
            } else {
                if (jNode.isInput()) {
                    if (multipleInput) {
                        nodeConnector = new NodeConnector(node);
                        nodeConnector.setName(name);
                        nodeConnector.setBaseSchema(EConnectionType.FLOW_MAIN.getName());
                        nodeConnector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
                        nodeConnector.setMaxLinkInput(1);
                        nodeConnector.setMinLinkInput(0);
                        nodeConnector.setMaxLinkOutput(0);
                        nodeConnector.setMinLinkOutput(0);
                        listConnector.add(nodeConnector);
                    }
                    nbInput++;
                } else {
                    nodeConnector = new NodeConnector(node);
                    nodeConnector.setName(name);
                    nodeConnector.setBaseSchema(EConnectionType.FLOW_MAIN.getName());
                    nodeConnector.setBuiltIn(true);
                    nodeConnector.setMaxLinkOutput(1);
                    nodeConnector.setMinLinkOutput(1);
                    // achen modify to fix bug 6205
                    String displayName = getDisplayName(jNode);
                    nodeConnector.setLinkName("Joblet " + name);
                    nodeConnector.setMenuName(displayName);
                    nodeConnector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
                    nodeConnector.addConnectionProperty(EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getRGB(), EConnectionType.FLOW_MAIN.getDefaultLineStyle());
                    nodeConnector.addConnectionProperty(EConnectionType.FLOW_REF, EConnectionType.FLOW_REF.getRGB(), EConnectionType.FLOW_REF.getDefaultLineStyle());
                    nodeConnector.addConnectionProperty(EConnectionType.FLOW_MERGE, EConnectionType.FLOW_MERGE.getRGB(), EConnectionType.FLOW_MERGE.getDefaultLineStyle());
                    listConnector.add(nodeConnector);
                    nbOutput++;
                }
            }
        }
    }
    createTriggerConnector(listConnector, node);
    return listConnector;
}
Also used : JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) ArrayList(java.util.ArrayList) JobletNode(org.talend.designer.joblet.model.JobletNode) JobletProcess(org.talend.designer.joblet.model.JobletProcess) INodeConnector(org.talend.core.model.process.INodeConnector) Point(org.eclipse.draw2d.geometry.Point)

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