Search in sources :

Example 66 with INodeConnector

use of org.talend.core.model.process.INodeConnector 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)

Example 67 with INodeConnector

use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.

the class NodeFigure method setBounds.

@Override
public void setBounds(final Rectangle rect) {
    super.setBounds(rect);
    Point location = (new Point(rect.getCenter())).translate(new Point(-fig.getSize().width / 2, -(fig.getSize().height / 2)));
    Rectangle figBounds = new Rectangle(location, fig.getSize());
    this.fig.setBounds(figBounds);
    if (dummy) {
        if (sourceDummyMap != null) {
            if (targetConnection != null && sourceDummyMap.keySet().size() != 0) {
                for (final ConnectionFigure curConn : newSourceConnections) {
                    AnchorListener sourceListener = new AnchorListener() {

                        @Override
                        public void anchorMoved(ConnectionAnchor anchor) {
                            if (curConn != null) {
                                updateSource(curConn);
                            }
                        }
                    };
                    if (curConn.getTargetAnchor() != null && curConn.getTargetAnchor().getOwner() != null) {
                        sourceListeners.put(curConn, sourceListener);
                        curConn.getTargetAnchor().addAnchorListener(sourceListener);
                    }
                }
                newSourceConnections.clear();
                updateTarget();
                List<ConnectionFigure> toRemove = new ArrayList<ConnectionFigure>();
                for (ConnectionFigure curConn : sourceDummyMap.keySet()) {
                    ConnectionFigure connToRemove = updateSource(curConn);
                    if (connToRemove != null) {
                        toRemove.add(connToRemove);
                    }
                }
                sourceDummyMap.keySet().removeAll(toRemove);
            } else {
                INodeConnector mainNodeConnector = node.getConnectorFromType(EConnectionType.FLOW_MAIN);
                ConnectionFigure connection = new ConnectionFigure(mainNodeConnector.getConnectionProperty(EConnectionType.FLOW_MAIN), node);
                connection.setTargetDecoration(null);
                connection.setStart(new Point(figBounds.x, figBounds.y + figBounds.height / 2));
                connection.setEnd(new Point(figBounds.x + figBounds.width, figBounds.y + figBounds.height / 2));
            }
        }
    }
    if (!rect.getSize().equals(fig.getSize())) {
        lineBorder.setUseRectangle(true);
    } else {
        lineBorder.setUseRectangle(false);
    }
}
Also used : ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) ConnectionFigure(org.talend.designer.core.ui.editor.connections.ConnectionFigure) DummyConnectionFigure(org.talend.designer.core.ui.editor.connections.DummyConnectionFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) AnchorListener(org.eclipse.draw2d.AnchorListener) ArrayList(java.util.ArrayList) Point(org.eclipse.draw2d.geometry.Point) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 68 with INodeConnector

use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.

the class ConnectionCreateAction method getConnectors.

public List<INodeConnector> getConnectors() {
    List<INodeConnector> list = new ArrayList<INodeConnector>();
    if (getSelectedObjects().isEmpty()) {
        return list;
    }
    List parts = getSelectedObjects();
    if (parts.size() == 1) {
        Object o = parts.get(0);
        if (!(o instanceof NodePart)) {
            return list;
        }
        nodePart = (NodePart) o;
        if (!(nodePart.getModel() instanceof Node)) {
            return list;
        }
        Node node = (Node) nodePart.getModel();
        if (!node.isActivate()) {
            return list;
        }
        List<INodeConnector> nodeConnectorList = new ArrayList<INodeConnector>(node.getConnectorsFromType(connecType));
        List<INodeConnector> toRemove = new ArrayList<INodeConnector>();
        for (INodeConnector connector : nodeConnectorList) {
            if ((connector.getMaxLinkOutput() != -1) && (connector.getCurLinkNbOutput() >= connector.getMaxLinkOutput())) {
                toRemove.add(connector);
            } else {
                if (PluginChecker.isJobLetPluginLoaded()) {
                    IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                    if (service != null) {
                        if (service.isJobletComponent(node) && !service.isBuiltTriggerConnector(node, connector)) {
                            toRemove.add(connector);
                        }
                        // for bug 10973
                        List<? extends IConnection> outgoingConnections = node.getOutgoingConnections();
                        if (service.isTriggerInputNode(node) && outgoingConnections != null && outgoingConnections.size() >= 1) {
                            toRemove.add(connector);
                        }
                    }
                }
            }
        }
        nodeConnectorList.removeAll(toRemove);
        return nodeConnectorList;
    }
    return list;
}
Also used : IJobletProviderService(org.talend.core.ui.IJobletProviderService) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 69 with INodeConnector

use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.

the class ComponentChooseDialog method createComponentOnLink.

private boolean createComponentOnLink(Node node, Point originalPoint) {
    boolean executed = false;
    RootEditPart rep = editor.getViewer().getRootEditPart().getRoot();
    Point viewOriginalPosition = new Point();
    if (rep instanceof ScalableFreeformRootEditPart) {
        ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep;
        Viewport viewport = (Viewport) root.getFigure();
        viewOriginalPosition = viewport.getViewLocation();
    }
    Point point = new Point(originalPoint.x + viewOriginalPosition.x, originalPoint.y + viewOriginalPosition.y);
    point.x = (int) (point.x / AnimatableZoomManager.currentZoom);
    point.y = (int) (point.y / AnimatableZoomManager.currentZoom);
    org.talend.designer.core.ui.editor.connections.Connection targetConnection = null;
    if (selectedConnectionPart != null) {
        targetConnection = (org.talend.designer.core.ui.editor.connections.Connection) selectedConnectionPart.getModel();
    }
    if (targetConnection != null) {
        IProcess2 p = editor.getProcess();
        NodeContainer nodeContainer = ((Process) node.getProcess()).loadNodeContainer(node, false);
        // TDI-21099
        if (p instanceof Process) {
            CreateNodeContainerCommand createCmd = new CreateNodeContainerCommand((Process) p, nodeContainer, point);
            execCommandStack(createCmd);
            // reconnect the node
            Node originalTarget = (Node) targetConnection.getTarget();
            EConnectionType connectionType = EConnectionType.FLOW_MAIN;
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
                ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
                if (camelService.isRouteBuilderNode(node)) {
                    connectionType = camelService.getTargetConnectionType(node);
                }
            }
            INodeConnector targetConnector = node.getConnectorFromType(connectionType);
            for (INodeConnector connector : node.getConnectorsFromType(connectionType)) {
                if (connector.getMaxLinkOutput() != 0) {
                    targetConnector = connector;
                    break;
                }
            }
            ConnectionCreateCommand.setCreatingConnection(true);
            // bug 21411
            if (PluginChecker.isJobLetPluginLoaded()) {
                IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                if (service != null && service.isJobletComponent(targetConnection.getTarget())) {
                    if (targetConnection.getTarget() instanceof Node) {
                        NodeContainer jobletContainer = ((Node) targetConnection.getTarget()).getNodeContainer();
                        // remove the old connection in the container
                        jobletContainer.getInputs().remove(targetConnection);
                    }
                }
            }
            ConnectionReconnectCommand cmd2 = new ConnectionReconnectCommand(targetConnection);
            cmd2.setNewTarget(node);
            execCommandStack(cmd2);
            List<Object> nodeArgs = CreateComponentOnLinkHelper.getTargetArgs(targetConnection, node);
            ConnectionCreateCommand nodeCmd = new ConnectionCreateCommand(node, targetConnector.getName(), nodeArgs, false);
            nodeCmd.setTarget(originalTarget);
            execCommandStack(nodeCmd);
            // Setting,such as the target is TMap
            if (node.getOutgoingConnections().size() > 0) {
                if (node.getExternalNode() instanceof MapperExternalNode) {
                    CreateComponentOnLinkHelper.setupTMap(node);
                }
                if (originalTarget.getExternalNode() instanceof MapperExternalNode) {
                    CreateComponentOnLinkHelper.updateTMap(originalTarget, targetConnection, node.getOutgoingConnections().get(0));
                }
                originalTarget.renameData(targetConnection.getName(), node.getOutgoingConnections().get(0).getName());
            }
            if (!ConnectionCreateCommand.isCreatingConnection()) {
                return true;
            }
            executed = true;
        }
    }
    return executed;
}
Also used : ICamelDesignerCoreService(org.talend.designer.core.ICamelDesignerCoreService) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) Viewport(org.eclipse.draw2d.Viewport) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IProcess(org.talend.core.model.process.IProcess) Point(org.eclipse.draw2d.geometry.Point) INodeConnector(org.talend.core.model.process.INodeConnector) ConnectionReconnectCommand(org.talend.designer.core.ui.editor.cmd.ConnectionReconnectCommand) IJobletProviderService(org.talend.core.ui.IJobletProviderService) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) IProcess2(org.talend.core.model.process.IProcess2) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) EConnectionType(org.talend.core.model.process.EConnectionType) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart)

Example 70 with INodeConnector

use of org.talend.core.model.process.INodeConnector in project tesb-studio-se by Talend.

the class CamelDesignerCoreService method canCreateNodeOnLink.

@Override
public boolean canCreateNodeOnLink(IConnection connection, INode node) {
    INodeConnector connector = node.getConnectorFromType(EConnectionType.ROUTE);
    if (connector.getMaxLinkOutput() > 0) {
        return true;
    }
    connector = node.getConnectorFromType(EConnectionType.ROUTE_ENDBLOCK);
    if (connector.getMaxLinkOutput() > 0) {
        return true;
    }
    return false;
}
Also used : INodeConnector(org.talend.core.model.process.INodeConnector)

Aggregations

INodeConnector (org.talend.core.model.process.INodeConnector)76 ArrayList (java.util.ArrayList)37 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)31 INode (org.talend.core.model.process.INode)31 Node (org.talend.designer.core.ui.editor.nodes.Node)31 IConnection (org.talend.core.model.process.IConnection)27 IElementParameter (org.talend.core.model.process.IElementParameter)22 Process (org.talend.designer.core.ui.editor.process.Process)21 List (java.util.List)20 Connection (org.talend.designer.core.ui.editor.connections.Connection)17 IJobletProviderService (org.talend.core.ui.IJobletProviderService)14 HashMap (java.util.HashMap)11 NodeConnector (org.talend.designer.core.model.components.NodeConnector)11 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)9 EConnectionType (org.talend.core.model.process.EConnectionType)9 Map (java.util.Map)8 IExternalNode (org.talend.core.model.process.IExternalNode)7 IProcess (org.talend.core.model.process.IProcess)7 RepositoryNode (org.talend.repository.model.RepositoryNode)7 Point (org.eclipse.draw2d.geometry.Point)6