Search in sources :

Example 76 with Connection

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

the class ConnectionDeleteCommand method execute.

@Override
public void execute() {
    connectionDeletedInfosMap = new HashMap<Connection, ConnectionDeleteCommand.ConnectionDeletedInfo>();
    Process process = (Process) connectionList.get(0).getSource().getProcess();
    for (Connection connection : connectionList) {
        boolean re = deleteExpendNode(connection);
        if (re) {
            return;
        }
        ConnectionDeletedInfo deletedInfo = new ConnectionDeletedInfo();
        connectionDeletedInfosMap.put(connection, deletedInfo);
        INode source = connection.getSource();
        if (source != null && source instanceof Node && !(((Node) source).isELTMapComponent())) {
            deletedInfo.metadataTable = connection.getMetadataTable();
            List<IMetadataTable> metaList = source.getMetadataList();
            if (metaList != null && deletedInfo.metadataTable != null) {
                deletedInfo.metadataTableIndex = metaList.indexOf(deletedInfo.metadataTable);
            }
        }
        connection.disconnect();
        final INode target = connection.getTarget();
        if (target.getExternalNode() instanceof AbstractNode) {
            ((AbstractNode) target.getExternalNode()).removeInput(connection);
        }
        INodeConnector nodeConnectorSource, nodeConnectorTarget;
        nodeConnectorSource = connection.getSourceNodeConnector();
        if (nodeConnectorSource != null) {
            nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() - 1);
        }
        nodeConnectorTarget = connection.getTargetNodeConnector();
        nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() - 1);
    }
    process.checkStartNodes();
    process.checkProcess();
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) INode(org.talend.core.model.process.INode) AbstractNode(org.talend.core.model.process.AbstractNode) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) AbstractNode(org.talend.core.model.process.AbstractNode) 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)

Example 77 with Connection

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

the class RadioController method createCommand.

private List<Command> createCommand(SelectionEvent event) {
    Set<String> elementsName;
    Control ctrl = (Control) event.getSource();
    elementsName = hashCurControls.keySet();
    List<Command> commands = new ArrayList<Command>();
    for (String name : elementsName) {
        Object o = hashCurControls.get(name);
        if (o instanceof Control) {
            ctrl = (Control) o;
            if (ctrl == null) {
                hashCurControls.remove(name);
                return null;
            }
            if (ctrl.equals(event.getSource())) {
                if (ctrl instanceof Button) {
                    // before
                    if (!elem.getPropertyValue(name).equals(new Boolean(((Button) ctrl).getSelection()))) {
                        Command cmd = null;
                        Boolean value = new Boolean(((Button) ctrl).getSelection());
                        if (name.equals(EParameterName.ACTIVATE.getName())) {
                            if (elem instanceof Node) {
                                List<Node> nodeList = new ArrayList<Node>();
                                nodeList.add((Node) elem);
                                List<Connection> connList = new ArrayList<Connection>();
                                cmd = new ChangeActivateStatusElementCommand(value, nodeList, connList);
                                commands.add(cmd);
                            }
                        } else {
                            IElementParameter param = elem.getElementParameter(name);
                            if (Boolean.TRUE.equals(value)) {
                                List<IElementParameter> parameters = DesignerUtilities.findRadioParamInSameGroup(elem.getElementParameters(), param);
                                for (IElementParameter currentRadioParam : parameters) {
                                    if (Boolean.TRUE.equals(currentRadioParam.getValue())) {
                                        cmd = new PropertyChangeCommand(elem, currentRadioParam.getName(), Boolean.FALSE);
                                        commands.add(cmd);
                                    }
                                }
                            }
                            cmd = new PropertyChangeCommand(elem, name, value);
                            commands.add(cmd);
                            String groupName = param.getGroup();
                            if (groupName != null && elem.getElementParameter(groupName) != null) {
                                Command cmd2 = new PropertyChangeCommand(elem, groupName, name);
                                commands.add(cmd2);
                            }
                        }
                        return commands;
                    }
                }
            }
        }
    }
    return null;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) Connection(org.talend.designer.core.ui.editor.connections.Connection) Control(org.eclipse.swt.widgets.Control) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) ChangeActivateStatusElementCommand(org.talend.designer.core.ui.editor.cmd.ChangeActivateStatusElementCommand) Button(org.eclipse.swt.widgets.Button) IElementParameter(org.talend.core.model.process.IElementParameter) ChangeActivateStatusElementCommand(org.talend.designer.core.ui.editor.cmd.ChangeActivateStatusElementCommand)

Example 78 with Connection

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

the class PartFactory method createEditPart.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.EditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object)
     */
@Override
public EditPart createEditPart(EditPart context, Object model) {
    EditPart part = null;
    if (model instanceof SubjobContainer) {
        part = new SubjobContainerPart();
    } else if (model instanceof Process) {
        part = new ProcessPart();
    } else if (model instanceof Node) {
        part = new NodePart();
    } else if (model instanceof Connection) {
        part = new ConnectionPart();
    } else if (model instanceof ConnectionLabel) {
        part = new ConnLabelEditPart();
    } else if (model instanceof MonitorConnectionLabel) {
        part = new MonitorConnectionLabelPart();
    } else if (model instanceof ConnectionPerformance) {
        part = new ConnectionPerformanceEditPart();
    } else if (model instanceof ConnectionTrace) {
        part = new ConnectionTraceEditPart();
    } else if (model instanceof ConnectionResuming) {
        part = new ConnectionResumingEditPart();
    } else if (model instanceof NodeLabel) {
        part = new NodeLabelEditPart();
    } else if (model instanceof NodeContainer) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerGEFService.class)) {
            ITestContainerGEFService testContainerService = (ITestContainerGEFService) GlobalServiceRegister.getDefault().getService(ITestContainerGEFService.class);
            if (testContainerService != null) {
                part = testContainerService.createEditorPart(model);
                if (part != null) {
                    part.setModel(model);
                    return part;
                }
            }
        }
        if (((NodeContainer) model).getNode().isSparkJoblet()) {
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkJobletProviderService.class)) {
                ISparkJobletProviderService sparkService = (ISparkJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkJobletProviderService.class);
                if (sparkService != null) {
                    part = (EditPart) sparkService.createEditorPart(model);
                    if (part != null) {
                        part.setModel(model);
                        return part;
                    }
                }
            }
        } else if (((NodeContainer) model).getNode().isSparkStreamingJoblet()) {
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkStreamingJobletProviderService.class)) {
                ISparkStreamingJobletProviderService sparkService = (ISparkStreamingJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkStreamingJobletProviderService.class);
                if (sparkService != null) {
                    part = (EditPart) sparkService.createEditorPart(model);
                    if (part != null) {
                        part.setModel(model);
                        return part;
                    }
                }
            }
        } else if (((NodeContainer) model).getNode().isStandardJoblet()) {
            part = new JobletContainerPart();
        } else if (((NodeContainer) model).getNode().isMapReduce()) {
            part = new JobletContainerPart();
        } else {
            part = new NodeContainerPart();
        }
    } else if (model instanceof Note) {
        part = new NoteEditPart();
    } else if (model instanceof NodeError) {
        part = new NodeErrorEditPart();
    } else if (model instanceof NodeProgressBar) {
        part = new NodeProgressBarPart();
    } else {
        return null;
    }
    // tell the newly created part about the model object
    part.setModel(model);
    return part;
}
Also used : NodeError(org.talend.designer.core.ui.editor.nodes.NodeError) NodeProgressBar(org.talend.designer.core.ui.editor.nodes.NodeProgressBar) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) NodeProgressBarPart(org.talend.designer.core.ui.editor.nodes.NodeProgressBarPart) Node(org.talend.designer.core.ui.editor.nodes.Node) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) MonitorConnectionLabel(org.talend.designer.core.ui.editor.connections.MonitorConnectionLabel) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ConnectionResuming(org.talend.designer.core.ui.editor.connections.ConnectionResuming) ConnectionResumingEditPart(org.talend.designer.core.ui.editor.connections.ConnectionResumingEditPart) NodeLabel(org.talend.designer.core.ui.editor.nodes.NodeLabel) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) MonitorConnectionLabel(org.talend.designer.core.ui.editor.connections.MonitorConnectionLabel) ITestContainerGEFService(org.talend.designer.core.ITestContainerGEFService) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) ISparkJobletProviderService(org.talend.core.ui.ISparkJobletProviderService) NodeErrorEditPart(org.talend.designer.core.ui.editor.nodes.NodeErrorEditPart) ConnectionPerformanceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart) ConnectionResumingEditPart(org.talend.designer.core.ui.editor.connections.ConnectionResumingEditPart) NodeErrorEditPart(org.talend.designer.core.ui.editor.nodes.NodeErrorEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) ConnectionPerformanceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart) ConnectionTraceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionTraceEditPart) 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) ConnectionPerformance(org.talend.designer.core.ui.editor.connections.ConnectionPerformance) ConnectionTrace(org.talend.designer.core.ui.editor.connections.ConnectionTrace) ConnectionTraceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionTraceEditPart) ISparkStreamingJobletProviderService(org.talend.core.ui.ISparkStreamingJobletProviderService) Note(org.talend.designer.core.ui.editor.notes.Note) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) MonitorConnectionLabelPart(org.talend.designer.core.ui.editor.connections.MonitorConnectionLabelPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 79 with Connection

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

the class ChangeActivateStatusElementCommand method execute.

@SuppressWarnings("unchecked")
@Override
public void execute() {
    if (connectionList != null && connectionList.size() != 0) {
        curConn = connectionList.get(0);
        listNm = (List<IConnection>) curConn.getSource().getOutgoingConnections(curConn.getLineStyle());
        outputs = (List<Connection>) curConn.getSource().getOutgoingConnections();
        connIndex = outputs.indexOf(curConn);
        deactiveNum = 0;
        object = outputs.get(connIndex);
        if (listNm.size() > 1) {
            for (int i = 0; i < listNm.size(); i++) {
                if (!listNm.get(i).isActivate()) {
                    deactiveNum = deactiveNum + 1;
                }
            }
            outputs.remove(curConn);
            if (value) {
                outputs.add(outputs.size() - deactiveNum, (Connection) object);
            } else {
                outputs.add(curConn);
            }
            curConn.updateAllId();
        }
    }
    if (nodeList != null && nodeList.size() > 0) {
        List<Connection> connIn = null;
        List<Connection> allConn = null;
        connIn = (List<Connection>) nodeList.get(0).getIncomingConnections();
        if (nodeList.get(0).getIncomingConnections() != null && nodeList.get(0).getIncomingConnections().size() > 0) {
            allConn = (List<Connection>) nodeList.get(0).getIncomingConnections().get(0).getSource().getOutgoingConnections();
            if (allConn.containsAll(connIn)) {
                if (connIn != null && connIn.size() >= 1) {
                    for (int i = 0; i < connIn.size(); i++) {
                        Connection con = connIn.get(i);
                        allConn.remove(con);
                        allConn.add(con);
                    }
                }
            }
            allConn.get(0).updateAllId();
        }
    }
    Process process;
    if (nodeList.size() > 0) {
        process = (Process) nodeList.get(0).getProcess();
    } else {
        process = (Process) curConn.getSource().getProcess();
    }
    process.setActivate(false);
    for (Connection connection : connectionList) {
        connection.setPropertyValue(EParameterName.ACTIVATE.getName(), value);
    }
    List uniqueNameList = new ArrayList();
    for (Node node : nodeList) {
        uniqueNameList.add(node.getUniqueName());
        if (isSameSchemaInputOutput(node)) {
            node.setPropertyValue(EParameterName.DUMMY.getName(), !value);
        }
        node.setPropertyValue(EParameterName.ACTIVATE.getName(), value);
    }
    dummyMiddleElement(false);
    process.setActivate(true);
    process.checkStartNodes();
    process.checkProcess();
    refreshPropertyView();
    refreshMRStatus();
}
Also used : INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) Process(org.talend.designer.core.ui.editor.process.Process) ArrayList(java.util.ArrayList) List(java.util.List)

Example 80 with Connection

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

the class ChangeActivateStatusElementCommand method isSameSchemaInputOutput.

private boolean isSameSchemaInputOutput(Node node) {
    boolean hasInput = false;
    IMetadataTable inputMetadata = null;
    for (Connection connection : (List<Connection>) node.getIncomingConnections()) {
        if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
            if (hasInput) {
                // so don't accept the dummy
                return false;
            }
            hasInput = true;
            inputMetadata = connection.getMetadataTable();
        }
    }
    if (!hasInput) {
        return false;
    }
    for (Connection outputConnection : (List<Connection>) node.getOutgoingConnections()) {
        if (outputConnection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
            IMetadataTable outputMeta = outputConnection.getMetadataTable();
            if (!inputMetadata.sameMetadataAs(outputMeta, IMetadataColumn.OPTIONS_IGNORE_KEY | IMetadataColumn.OPTIONS_IGNORE_NULLABLE | IMetadataColumn.OPTIONS_IGNORE_COMMENT | IMetadataColumn.OPTIONS_IGNORE_PATTERN | IMetadataColumn.OPTIONS_IGNORE_DBCOLUMNNAME | IMetadataColumn.OPTIONS_IGNORE_DBTYPE)) {
                // input and output schema is different, so don't accept dummy
                return false;
            }
        }
    }
    return true;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) List(java.util.List)

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