Search in sources :

Example 1 with NodeConnector

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

the class JobletUtil method createTriggerConnector.

private void createTriggerConnector(List<INodeConnector> listConnector, INode jobletNode) {
    IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
    if (service != null) {
        List<INode> triggerNodes = service.getTriggerNodes(jobletNode.getJobletNode());
        for (INode node : triggerNodes) {
            // INode node = jobletNode;
            EConnectionType triggerConnType = service.getTriggerNodeConnType(node);
            if (triggerConnType == null) {
                continue;
            }
            boolean isInput = service.isTriggerInputNode(node);
            INodeConnector nodeConnector = null;
            String name = node.getUniqueName();
            nodeConnector = new NodeConnector(jobletNode);
            nodeConnector.setName(name);
            nodeConnector.setBaseSchema(triggerConnType.getName());
            nodeConnector.setBuiltIn(true);
            nodeConnector.setMaxLinkOutput(isInput ? 0 : 1);
            nodeConnector.setMinLinkOutput(0);
            nodeConnector.setMaxLinkInput(isInput ? 1 : 0);
            nodeConnector.setMinLinkInput(0);
            String displayName = conDisplayName(node.getLabel(), name);
            //$NON-NLS-1$ //$NON-NLS-2$
            nodeConnector.setLinkName(triggerConnType.getDefaultLinkName() + " (" + displayName + ")");
            //$NON-NLS-1$ //$NON-NLS-2$
            nodeConnector.setMenuName(triggerConnType.getDefaultMenuName() + " (" + displayName + ")");
            nodeConnector.setDefaultConnectionType(triggerConnType);
            nodeConnector.addConnectionProperty(triggerConnType, triggerConnType.getRGB(), triggerConnType.getDefaultLineStyle());
            listConnector.add(nodeConnector);
        }
    }
}
Also used : IJobletProviderService(org.talend.core.ui.IJobletProviderService) INode(org.talend.core.model.process.INode) INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) EConnectionType(org.talend.core.model.process.EConnectionType) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 2 with NodeConnector

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

the class Component method createConnectors.

@Override
public List<INodeConnector> createConnectors(INode parentNode) {
    List<INodeConnector> listConnector = new ArrayList<>();
    ComponentProperties componentProperties = ComponentsUtils.getComponentProperties(getName());
    Set<? extends Connector> inputConnectors = componentProperties.getPossibleConnectors(false);
    if (inputConnectors.isEmpty()) {
        INodeConnector connector = null;
        connector = addStandardType(listConnector, EConnectionType.FLOW_MAIN, parentNode);
        connector.setMaxLinkInput(0);
        connector.setMaxLinkOutput(0);
    } else {
        for (Connector connector : inputConnectors) {
            addGenericType(listConnector, EConnectionType.FLOW_MAIN, connector.getName(), parentNode, componentProperties, false);
        }
    }
    Set<? extends Connector> outputConnectors = componentProperties.getPossibleConnectors(true);
    List<? extends Connector> sortedOutputConnectors = new ArrayList<>(outputConnectors);
    sortedOutputConnectors.sort(new Comparator<Connector>() {

        @Override
        public int compare(Connector o1, Connector o2) {
            if (Connector.MAIN_NAME.equals(o1.getName())) {
                return -1;
            }
            if (Connector.MAIN_NAME.equals(o2.getName())) {
                return 1;
            }
            return 0;
        }
    });
    for (Connector connector : sortedOutputConnectors) {
        EConnectionType type = EConnectionType.FLOW_MAIN;
        if (Connector.REJECT_NAME.equals(connector.getName())) {
            type = EConnectionType.REJECT;
        }
        addGenericType(listConnector, type, connector.getName(), parentNode, componentProperties, true);
    }
    addStandardType(listConnector, EConnectionType.RUN_IF, parentNode);
    addStandardType(listConnector, EConnectionType.ON_COMPONENT_OK, parentNode);
    addStandardType(listConnector, EConnectionType.ON_COMPONENT_ERROR, parentNode);
    addStandardType(listConnector, EConnectionType.ON_SUBJOB_OK, parentNode);
    addStandardType(listConnector, EConnectionType.ON_SUBJOB_ERROR, parentNode);
    Set<ConnectorTopology> topologies = componentDefinition.getSupportedConnectorTopologies();
    createIterateConnectors(topologies, listConnector, parentNode);
    for (int i = 0; i < EConnectionType.values().length; i++) {
        EConnectionType currentType = EConnectionType.values()[i];
        if ((currentType == EConnectionType.FLOW_REF) || (currentType == EConnectionType.FLOW_MERGE)) {
            continue;
        }
        boolean exists = false;
        for (INodeConnector curNodeConn : listConnector) {
            if (curNodeConn.getDefaultConnectionType().equals(currentType)) {
                exists = true;
                if (currentType == EConnectionType.FLOW_MAIN) {
                    curNodeConn.addConnectionProperty(EConnectionType.FLOW_REF, EConnectionType.FLOW_REF.getRGB(), EConnectionType.FLOW_REF.getDefaultLineStyle());
                    curNodeConn.addConnectionProperty(EConnectionType.FLOW_MERGE, EConnectionType.FLOW_MERGE.getRGB(), EConnectionType.FLOW_MERGE.getDefaultLineStyle());
                }
            }
        }
        if (!exists) {
            // will add by default all connectors not defined in
            NodeConnector nodeConnector = new NodeConnector(parentNode);
            nodeConnector.setDefaultConnectionType(currentType);
            nodeConnector.setName(currentType.getName());
            nodeConnector.setBaseSchema(currentType.getName());
            nodeConnector.addConnectionProperty(currentType, currentType.getRGB(), currentType.getDefaultLineStyle());
            nodeConnector.setLinkName(currentType.getDefaultLinkName());
            nodeConnector.setMenuName(currentType.getDefaultMenuName());
            if ((currentType == EConnectionType.PARALLELIZE) || (currentType == EConnectionType.SYNCHRONIZE)) {
                nodeConnector.setMaxLinkInput(1);
            } else {
                nodeConnector.setMaxLinkInput(0);
            }
            nodeConnector.setMaxLinkOutput(0);
            nodeConnector.setMinLinkInput(0);
            nodeConnector.setMinLinkOutput(0);
            listConnector.add(nodeConnector);
        }
    }
    return listConnector;
}
Also used : PropertyPathConnector(org.talend.components.api.component.PropertyPathConnector) INodeConnector(org.talend.core.model.process.INodeConnector) Connector(org.talend.components.api.component.Connector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) ComponentProperties(org.talend.components.api.properties.ComponentProperties) INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) ArrayList(java.util.ArrayList) INodeConnector(org.talend.core.model.process.INodeConnector) EConnectionType(org.talend.core.model.process.EConnectionType) ConnectorTopology(org.talend.components.api.component.ConnectorTopology)

Example 3 with NodeConnector

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

the class AbstractFakeComponent method createBaseConnector.

protected NodeConnector createBaseConnector(INode node, EConnectionType currentType) {
    NodeConnector nodeConnector = new NodeConnector(node);
    nodeConnector.setDefaultConnectionType(currentType);
    // set the default values
    nodeConnector.setLinkName(currentType.getDefaultLinkName());
    nodeConnector.setMenuName(currentType.getDefaultMenuName());
    RGB rgb = currentType.getRGB();
    Integer lineStyle = currentType.getDefaultLineStyle();
    String connectorName = currentType.getName();
    nodeConnector.setName(connectorName);
    //$NON-NLS-1$
    nodeConnector.setMenuName(connectorName + ".MENU");
    //$NON-NLS-1$
    nodeConnector.setLinkName(connectorName + ".LINK");
    nodeConnector.addConnectionProperty(currentType, rgb, lineStyle);
    nodeConnector.setBaseSchema(nodeConnector.getName());
    return nodeConnector;
}
Also used : INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) RGB(org.eclipse.swt.graphics.RGB)

Example 4 with NodeConnector

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

the class SimpleInputComponent 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(0);
    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 5 with NodeConnector

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

the class UpdateELTMapComponentCommandTest method before.

@Before
public void before() {
    Process process = new Process(createProperty());
    sourceNode = new Node(sourceComponent, process);
    INodeConnector connector = new NodeConnector(sourceNode);
    connector.setName("connector");
    connector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
    ArrayList<INodeConnector> connectors = new ArrayList<INodeConnector>();
    connectors.add(connector);
    sourceNode.setListConnector(connectors);
    targetNode = new Node(targetComponent, process);
    DbMapComponent component = new DbMapComponent();
    targetNode.setExternalNode(component);
    connection = new Connection(sourceNode, targetNode, EConnectionType.FLOW_MAIN, "connector", "meta", "oldTable", true);
    inputs = (List<ExternalDbMapTable>) targetNode.getExternalData().getInputTables();
    ExternalDbMapTable input = new ExternalDbMapTable();
    input.setName("oldTable");
    input.setTableName("oldTable");
    inputs.add(input);
    outputs = (List<ExternalDbMapTable>) targetNode.getExternalData().getOutputTables();
    ExternalDbMapTable output = new ExternalDbMapTable();
    ExternalDbMapEntry entry = new ExternalDbMapEntry("oldTable", "oldTable.column");
    output.setMetadataTableEntries(new ArrayList<ExternalDbMapEntry>());
    output.getMetadataTableEntries().add(entry);
    outputs.add(output);
}
Also used : DbMapComponent(org.talend.designer.dbmap.DbMapComponent) INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) ExternalDbMapTable(org.talend.designer.dbmap.external.data.ExternalDbMapTable) Node(org.talend.designer.core.ui.editor.nodes.Node) 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) INodeConnector(org.talend.core.model.process.INodeConnector) ExternalDbMapEntry(org.talend.designer.dbmap.external.data.ExternalDbMapEntry) Before(org.junit.Before)

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