Search in sources :

Example 51 with Connection

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

the class JobletUtil method cloneConnection.

public Connection cloneConnection(IConnection conn, INode source, INode target) {
    Connection cloneConn = new Connection(source, target, conn.getLineStyle(), conn.getConnectorName(), conn.getMetaName(), conn.getName(), conn.isMonitorConnection());
    if (!source.isActivate() || !target.isActivate()) {
        cloneConn.setActivate(false);
    }
    List<? extends IElementParameter> elementParas = conn.getElementParameters();
    for (IElementParameter elementPara : elementParas) {
        if (elementPara.getName() != null && !elementPara.getName().equals("UNIQUE_NAME")) {
            IElementParameter cloneElement = cloneConn.getElementParameter(elementPara.getName());
            Object paValue = elementPara.getValue();
            if (paValue instanceof List) {
                List list = new ArrayList();
                list.addAll((List) paValue);
                cloneElement.setValue(list);
            } else {
                cloneElement.setContextMode(elementPara.isContextMode());
                cloneElement.setValue(elementPara.getValue());
            }
        }
    }
    return cloneConn;
}
Also used : Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList)

Example 52 with Connection

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

the class DummyNodeAnchor method getLocation.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.draw2d.ChopboxAnchor#getLocation(org.eclipse.draw2d.geometry.Point)
     */
@Override
public Point getLocation(Point reference) {
    int nb = 0;
    int connectionId = 0;
    for (Connection connection : (List<Connection>) source.getOutgoingConnections()) {
        if (connection.getTarget().equals(target)) {
            nb++;
            if (connection.equals(this.connection)) {
                connectionId = nb;
            }
        }
    }
    if (nb <= 1) {
        return getSourceAnchorLocation(reference);
    } else {
        return getLocationForMultipleConnections(connectionId);
    }
}
Also used : Connection(org.talend.designer.core.ui.editor.connections.Connection) List(java.util.List) Point(org.eclipse.draw2d.geometry.Point)

Example 53 with Connection

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

the class SubjobContainer method refreshOutputConnections.

/**
     * DOC nrousseau Comment method "refreshOutputConnections".
     */
private void refreshOutputConnections() {
    boolean collapsed = isCollapsed();
    // reinitialize all output connections.
    Node subjobStartNode = this.getSubjobStartNode();
    List<Connection> connectionsToUpdate = new ArrayList<Connection>(outputs);
    outputs = new ArrayList<Connection>();
    if (!collapsed) {
        fireStructureChange(UPDATE_SUBJOB_CONNECTIONS, this);
        for (NodeContainer nodeContainer : this.nodeContainers) {
            Node currentNode = nodeContainer.getNode();
            // force connections draw update
            currentNode.forceConnectionsUpdate();
            for (Connection connection : outputs) {
                if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DEPENDENCY)) {
                    connection.setSubjobConnection(false);
                }
            }
        }
        return;
    }
    for (NodeContainer nodeContainer : this.nodeContainers) {
        Node currentNode = nodeContainer.getNode();
        if (currentNode.equals(subjobStartNode)) {
            // avoid subjobStartNode as it's not needed
            continue;
        }
        for (Connection connection : (List<Connection>) currentNode.getOutgoingConnections()) {
            if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DEPENDENCY) && !subjobStartNode.equals(connection.getTarget().getDesignSubjobStartNode())) {
                connection.setSubjobConnection(true);
                outputs.add(connection);
            }
        }
        fireStructureChange(UPDATE_SUBJOB_CONNECTIONS, this);
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) ArrayList(java.util.ArrayList) List(java.util.List)

Example 54 with Connection

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

the class ProcessComposite method addTrace.

private void addTrace(int itemId) {
    Boolean trace = false;
    processContext.setMonitorTrace(trace);
    processManager.setBooleanTrace(trace);
    org.talend.core.model.process.IProcess process = processContext.getProcess();
    List<INode> nodeList = (List<INode>) process.getGraphicalNodes();
    for (INode node : nodeList) {
        for (Connection connection : (List<Connection>) node.getOutgoingConnections()) {
            ConnectionTrace traceNode = connection.getConnectionTrace();
            if (traceNode == null) {
                continue;
            }
            traceNode.setPropertyValue(EParameterName.TRACES_SHOW_ENABLE.getName(), trace);
            if (connection != null && connection.checkTraceShowEnable()) {
                connection.setPropertyValue(EParameterName.TRACES_SHOW_ENABLE.getName(), trace);
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) ConnectionTrace(org.talend.designer.core.ui.editor.connections.ConnectionTrace) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) List(java.util.List)

Example 55 with Connection

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

the class GEFDeleteAction method calculateEnabled.

@Override
protected boolean calculateEnabled() {
    objectsToDelete = new ArrayList();
    List objects = getSelectedObjects();
    objectsToDelete.addAll(objects);
    if (objects.isEmpty() || (objects.size() == 1 && objects.get(0) instanceof ProcessPart)) {
        return false;
    }
    if (!(objects.get(0) instanceof EditPart)) {
        return false;
    }
    AbstractTalendEditor editor = (AbstractTalendEditor) this.getWorkbenchPart();
    AbstractProcessProvider pProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
    if (pProvider != null) {
        Map<JobletContainerPart, List<NodePart>> jobletMap = new HashMap<JobletContainerPart, List<NodePart>>();
        boolean nodeInJoblet = false;
        boolean allJunitnode = true;
        boolean hasNode = false;
        int i = 0;
        for (Object o : objects) {
            if (o instanceof NodePart) {
                hasNode = true;
                NodePart nodePart = (NodePart) o;
                Node no = (Node) ((NodePart) o).getModel();
                if (no.getProcess().isReadOnly()) {
                    return false;
                }
                if (no.isReadOnly()) {
                    i++;
                }
                if (no.getJunitNode() == null) {
                    allJunitnode = false;
                }
                if (!pProvider.canDeleteNode(no)) {
                    return false;
                }
                boolean isCollapsedNode = false;
                if (editor.getProcess().getGraphicalNodes().contains(nodePart.getModel())) {
                    isCollapsedNode = true;
                }
                if (!isCollapsedNode && nodePart.getParent() instanceof JobletContainerPart) {
                    JobletContainerPart jobletContainer = (JobletContainerPart) nodePart.getParent();
                    List<NodePart> jobletNodeParts = jobletMap.get(jobletContainer);
                    if (jobletNodeParts == null) {
                        jobletNodeParts = new ArrayList<NodePart>();
                        jobletMap.put(jobletContainer, jobletNodeParts);
                    }
                    jobletNodeParts.add(nodePart);
                }
            } else if (o instanceof ConnectionPart) {
                Connection conn = (Connection) ((ConnectionPart) o).getModel();
                if (conn.getSource().getProcess().isReadOnly()) {
                    return false;
                }
                if (conn.isReadOnly()) {
                    i++;
                }
            } else if (o instanceof ConnLabelEditPart) {
                ConnectionLabel connLabel = (ConnectionLabel) ((ConnLabelEditPart) o).getModel();
                if (connLabel.getConnection().getSource().getProcess().isReadOnly()) {
                    return false;
                }
                if (connLabel.getConnection().isReadOnly()) {
                    i++;
                }
            } else if (o instanceof NoteEditPart) {
                allJunitnode = false;
                Note note = (Note) ((NoteEditPart) o).getModel();
                if (note.isReadOnly()) {
                    i++;
                }
            } else if (o instanceof SubjobContainerPart) {
                SubjobContainer subjob = (SubjobContainer) ((SubjobContainerPart) o).getModel();
                if (subjob.getProcess().isReadOnly()) {
                    return false;
                }
                if (subjob.isReadOnly()) {
                    i++;
                    continue;
                }
                boolean isAllReadonly = true;
                boolean subjobAllJunit = true;
                for (NodeContainer nc : subjob.getNodeContainers()) {
                    Node node = nc.getNode();
                    if (!node.isReadOnly()) {
                        isAllReadonly = false;
                    }
                    if (node.getJunitNode() == null) {
                        subjobAllJunit = false;
                    }
                }
                if (isAllReadonly || subjobAllJunit) {
                    i++;
                }
            }
        }
        for (JobletContainerPart jobletContainer : jobletMap.keySet()) {
            boolean copyJobletNode = true;
            List<NodePart> list = jobletMap.get(jobletContainer);
            for (Object obj : jobletContainer.getChildren()) {
                if (obj instanceof NodePart) {
                    if (!list.contains(obj)) {
                        copyJobletNode = false;
                        break;
                    }
                }
            }
            if (copyJobletNode) {
                objectsToDelete.removeAll(list);
                PartFactory factory = new PartFactory();
                NodePart createEditPart = (NodePart) factory.createEditPart(jobletContainer, ((NodeContainer) jobletContainer.getModel()).getNode());
                createEditPart.setParent(jobletContainer);
                createEditPart.installEditPolicy(EditPolicy.COMPONENT_ROLE, new NodeEditPolicy());
                objectsToDelete.add(createEditPart);
            } else {
                nodeInJoblet = true;
            }
        }
        if (((nodeInJoblet || allJunitnode) && hasNode) || i == objects.size()) {
            return false;
        }
    }
    return true;
}
Also used : HashMap(java.util.HashMap) PartFactory(org.talend.designer.core.ui.editor.PartFactory) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) AbstractProcessProvider(org.talend.designer.core.model.process.AbstractProcessProvider) NodeEditPolicy(org.talend.designer.core.ui.editor.nodes.NodeEditPolicy) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) ArrayList(java.util.ArrayList) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) EditPart(org.eclipse.gef.EditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) Connection(org.talend.designer.core.ui.editor.connections.Connection) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) JobletContainerPart(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) Note(org.talend.designer.core.ui.editor.notes.Note) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Aggregations

Connection (org.talend.designer.core.ui.editor.connections.Connection)84 IConnection (org.talend.core.model.process.IConnection)52 ArrayList (java.util.ArrayList)47 List (java.util.List)46 Node (org.talend.designer.core.ui.editor.nodes.Node)44 INode (org.talend.core.model.process.INode)35 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)28 Process (org.talend.designer.core.ui.editor.process.Process)24 IElementParameter (org.talend.core.model.process.IElementParameter)20 INodeConnector (org.talend.core.model.process.INodeConnector)18 HashMap (java.util.HashMap)12 IComponent (org.talend.core.model.components.IComponent)12 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)12 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)11 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)11 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)10 Property (org.talend.core.model.properties.Property)10 Test (org.junit.Test)9 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)9 Map (java.util.Map)8