Search in sources :

Example 1 with ConnectionCreateCommand

use of org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand in project tdi-studio-se by Talend.

the class NodeGraphicalEditPolicy method getConnectionCreateCommand.

@Override
@SuppressWarnings("unchecked")
protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
    Node source = (Node) getHost().getModel();
    if (source.isReadOnly()) {
        return null;
    }
    String style = (String) request.getNewObjectType();
    ConnectionCreateCommand cmd = new ConnectionCreateCommand(source, style, (List<Object>) request.getNewObject());
    request.setStartCommand(cmd);
    return cmd;
}
Also used : ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand)

Example 2 with ConnectionCreateCommand

use of org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand in project tdi-studio-se by Talend.

the class ComponentChooseDialog method updateConnectionCommand.

private void updateConnectionCommand(org.talend.designer.core.ui.editor.connections.Connection connection, Node node, CompoundCommand command) {
    if (connection != null || node != null) {
        Node originalTarget = (Node) connection.getTarget();
        INodeConnector targetConnector = node.getConnectorFromType(EConnectionType.FLOW_MAIN);
        for (INodeConnector connector : node.getConnectorsFromType(EConnectionType.FLOW_MAIN)) {
            if (connector.getMaxLinkOutput() != 0) {
                targetConnector = connector;
                break;
            }
        }
        ConnectionCreateCommand.setCreatingConnection(true);
        EConnectionType reconnectNewInputStyle = connection.getLineStyle();
        if (ConnectionManager.canConnectToTarget(connection.getSource(), originalTarget, node, connection.getLineStyle(), connection.getName(), targetConnector.getName())) {
            reconnectNewInputStyle = ConnectionManager.getNewConnectionType();
        }
        if (reconnectNewInputStyle.equals(EConnectionType.FLOW_MAIN)) {
            connection.reconnect(connection.getSource(), node, EConnectionType.FLOW_MAIN);
        } else if (reconnectNewInputStyle.equals(EConnectionType.FLOW_MERGE)) {
            connection.reconnect(connection.getSource(), node, EConnectionType.FLOW_MERGE);
        } else if (reconnectNewInputStyle.equals(EConnectionType.FLOW_REF)) {
            connection.reconnect(connection.getSource(), node, EConnectionType.FLOW_REF);
        }
        INodeConnector nodeConnector = node.getConnectorFromName(targetConnector.getName());
        nodeConnector.setCurLinkNbInput(nodeConnector.getCurLinkNbInput() + 1);
        List<Object> nodeArgs = CreateComponentOnLinkHelper.getTargetArgs(connection, node);
        ConnectionCreateCommand nodeCmd = new ConnectionCreateCommand(node, targetConnector.getName(), nodeArgs, false);
        nodeCmd.setTarget(originalTarget);
        INodeConnector originalNodeConnector = originalTarget.getConnectorFromName(connection.getTargetNodeConnector().getName());
        originalNodeConnector.setCurLinkNbInput(originalNodeConnector.getCurLinkNbInput() - 1);
        command.add(nodeCmd);
    }
}
Also used : 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) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) 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) EConnectionType(org.talend.core.model.process.EConnectionType) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 3 with ConnectionCreateCommand

use of org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand in project tdi-studio-se by Talend.

the class ProcessLayoutEditPolicy method getConnectionAndEndCommands.

protected Command getConnectionAndEndCommands(CreateConnectionRequest request) {
    CompoundCommand cc = new CompoundCommand("CreateNodeCommand");
    ProcessPart processPart = (ProcessPart) this.getHost();
    final GraphicalViewer graphicalViewer = (GraphicalViewer) processPart.getViewer();
    final CommandStack commandStack = processPart.getViewer().getEditDomain().getCommandStack();
    final String categoryName = ComponentsFactoryProvider.getInstance().getComponentsHandler().extractComponentsCategory().getName();
    final IProcess2 process = (IProcess2) processPart.getModel();
    TalendEditorConnectionTargetAssist assist = new TalendEditorConnectionTargetAssist(categoryName, graphicalViewer, commandStack, process);
    char start = '*';
    assist.showComponentCreationAssist(start);
    ConnectionCreateCommand cmd = (ConnectionCreateCommand) request.getStartCommand();
    if (assist.getComponentName() == null) {
        assist.releaseText();
        return cmd;
    }
    IComponent component = TalendEditorComponentCreationUtil.getComponentsInCategory(categoryName).get(assist.getComponentName());
    if (component == null) {
        assist.releaseText();
        return cmd;
    }
    assist.releaseText();
    Node newNode = new Node(component);
    NodeContainer nodeContainer = ((Process) newNode.getProcess()).loadNodeContainer(newNode, false);
    CreateNodeContainerCommand command = new CreateNodeContainerCommand((org.talend.designer.core.ui.editor.process.Process) newNode.getProcess(), nodeContainer, request.getLocation());
    cc.add(command);
    cmd.setTarget(newNode);
    cc.add(cmd);
    return cc;
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) GraphicalViewer(org.eclipse.gef.GraphicalViewer) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) IProcess2(org.talend.core.model.process.IProcess2) TalendEditorConnectionTargetAssist(org.talend.designer.core.assist.TalendEditorConnectionTargetAssist)

Example 4 with ConnectionCreateCommand

use of org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand in project tdi-studio-se by Talend.

the class NodeGraphicalEditPolicy method getConnectionCompleteCommand.

@Override
protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
    ConnectionCreateCommand cmd = (ConnectionCreateCommand) request.getStartCommand();
    cmd.setTarget((Node) getHost().getModel());
    return cmd;
}
Also used : ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand)

Example 5 with ConnectionCreateCommand

use of org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand 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)

Aggregations

ConnectionCreateCommand (org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand)5 Node (org.talend.designer.core.ui.editor.nodes.Node)3 HL7FileNode (org.talend.core.model.metadata.builder.connection.HL7FileNode)2 XMLFileNode (org.talend.core.model.metadata.builder.connection.XMLFileNode)2 EConnectionType (org.talend.core.model.process.EConnectionType)2 IExternalNode (org.talend.core.model.process.IExternalNode)2 INode (org.talend.core.model.process.INode)2 INodeConnector (org.talend.core.model.process.INodeConnector)2 IProcess2 (org.talend.core.model.process.IProcess2)2 MapperExternalNode (org.talend.core.model.process.node.MapperExternalNode)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)2 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)2 QueryRepositoryObject (org.talend.core.repository.model.repositoryObject.QueryRepositoryObject)2 SAPFunctionRepositoryObject (org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject)2 SAPIDocRepositoryObject (org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject)2 SalesforceModuleRepositoryObject (org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject)2 CreateNodeContainerCommand (org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand)2 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)2 IRepositoryNode (org.talend.repository.model.IRepositoryNode)2