Search in sources :

Example 61 with Process

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

the class JobHierarchyTransferDropAdapter method drop.

public void drop(DropTargetEvent event) {
    IStructuredSelection selection = getSelection();
    if (selection.size() == 1) {
        if (selection.getFirstElement() instanceof RepositoryNode) {
            RepositoryNode sourceNode = (RepositoryNode) selection.getFirstElement();
            Item item = sourceNode.getObject().getProperty().getItem();
            if (item instanceof ProcessItem) {
                // Process loadedProcess = new Process(((ProcessItem) item).getProperty());
                // loadedProcess.loadXmlFile();
                IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
                Process loadedProcess = (Process) designerCoreService.getProcessFromProcessItem((ProcessItem) item);
                part.setInputProcess(loadedProcess);
            }
        }
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) Process(org.talend.designer.core.ui.editor.process.Process) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 62 with Process

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

the class ChangeActivateStatusElementCommand method undo.

@Override
public void undo() {
    Process process;
    if (nodeList.size() > 0) {
        process = (Process) nodeList.get(0).getProcess();
    } else {
        process = (Process) connectionList.get(0).getSource().getProcess();
    }
    process.setActivate(false);
    dummyMiddleElement(true);
    for (Node node : nodeList) {
        if (isSameSchemaInputOutput(node)) {
            node.setPropertyValue(EParameterName.DUMMY.getName(), value);
        }
        node.setPropertyValue(EParameterName.ACTIVATE.getName(), !value);
    }
    for (Connection connection : connectionList) {
        connection.setPropertyValue(EParameterName.ACTIVATE.getName(), !value);
    }
    if (connectionList != null && connectionList.size() != 0) {
        if (connIndex < outputs.size()) {
            outputs.remove(this.curConn);
            outputs.add(outputs.size() - deactiveNum, (Connection) object);
        }
        if (connIndex >= outputs.size()) {
            outputs.add(curConn);
        }
        curConn.updateAllId();
    }
    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) Process(org.talend.designer.core.ui.editor.process.Process)

Example 63 with Process

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

the class ChangeActivateStatusElementCommand method getAllMiddleConnections.

private Map<List<INode>, List<IConnection>> getAllMiddleConnections() {
    Map<List<INode>, List<IConnection>> middConnMap = new HashMap<List<INode>, List<IConnection>>();
    Process process;
    if (nodeList.size() > 0) {
        process = (Process) nodeList.get(0).getProcess();
    } else {
        process = (Process) connectionList.get(0).getSource().getProcess();
    }
    List<? extends INode> nodes = process.getGraphicalNodes();
    List<INode> jobletandnodeList = new ArrayList<INode>();
    for (INode node : nodes) {
        if (((Node) node).isJoblet() && !((Node) node).getNodeContainer().isCollapsed() && (((Node) node).getNodeContainer() instanceof AbstractJobletContainer)) {
            for (NodeContainer nc : ((AbstractJobletContainer) ((Node) node).getNodeContainer()).getNodeContainers()) {
                jobletandnodeList.add(nc.getNode());
            }
        } else {
            jobletandnodeList.add(node);
        }
    }
    for (INode node : jobletandnodeList) {
        if (node.isActivate()) {
            Map<IConnection, Node> outMiddleNodes = getAllOutMiddleNodes(node);
            Map<IConnection, Node> inMiddleNodes = getAllInMiddleNodes(node);
            Set<Entry<IConnection, Node>> outSet = outMiddleNodes.entrySet();
            Iterator<Entry<IConnection, Node>> outIte = outSet.iterator();
            boolean haveActivateTarget = false;
            List<INode> nodeList = new ArrayList<INode>();
            List<IConnection> connList = new ArrayList<IConnection>();
            while (outIte.hasNext()) {
                Entry<IConnection, Node> en = outIte.next();
                Node enNode = en.getValue();
                IConnection enConn = en.getKey();
                if (enNode != null) {
                    haveActivateTarget = true;
                    if (!nodeList.contains(node)) {
                        nodeList.add(node);
                    }
                    if (!nodeList.contains(enNode)) {
                        nodeList.add(enNode);
                    }
                }
                if (enConn != null && !connList.contains(enConn)) {
                    connList.add(enConn);
                }
            }
            if (!haveActivateTarget) {
                outMiddleNodes.clear();
            }
            if (!nodeList.isEmpty() && !connList.isEmpty()) {
                Set<Entry<List<INode>, List<IConnection>>> middSet = middConnMap.entrySet();
                Iterator<Entry<List<INode>, List<IConnection>>> middIte = middSet.iterator();
                boolean exist = false;
                while (middIte.hasNext()) {
                    Entry<List<INode>, List<IConnection>> entry = middIte.next();
                    List<INode> enNodeList = entry.getKey();
                    if (enNodeList.size() == 2 && nodeList.size() == 2) {
                        if (enNodeList.get(0).getUniqueName().equals(nodeList.get(1).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(0).getUniqueName())) {
                            exist = true;
                        } else if (enNodeList.get(0).getUniqueName().equals(nodeList.get(0).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(1).getUniqueName())) {
                            exist = true;
                        }
                    }
                }
                if (!exist) {
                    middConnMap.put(nodeList, connList);
                }
            }
            Set<Entry<IConnection, Node>> inSet = inMiddleNodes.entrySet();
            Iterator<Entry<IConnection, Node>> inIte = inSet.iterator();
            boolean haveActivateSource = false;
            nodeList = new ArrayList<INode>();
            connList = new ArrayList<IConnection>();
            while (inIte.hasNext()) {
                Entry<IConnection, Node> en = inIte.next();
                Node enNode = en.getValue();
                IConnection enConn = en.getKey();
                if (enNode != null) {
                    haveActivateSource = true;
                    if (!nodeList.contains(node)) {
                        nodeList.add(node);
                    }
                    if (!nodeList.contains(enNode)) {
                        nodeList.add(enNode);
                    }
                }
                if (enConn != null && !connList.contains(enConn)) {
                    connList.add(enConn);
                }
            }
            if (!haveActivateSource) {
                inMiddleNodes.clear();
            }
            if (!nodeList.isEmpty() && !connList.isEmpty()) {
                Set<Entry<List<INode>, List<IConnection>>> middSet = middConnMap.entrySet();
                Iterator<Entry<List<INode>, List<IConnection>>> middIte = middSet.iterator();
                boolean exist = false;
                while (middIte.hasNext()) {
                    Entry<List<INode>, List<IConnection>> entry = middIte.next();
                    List<INode> enNodeList = entry.getKey();
                    if (enNodeList.size() == 2 && nodeList.size() == 2) {
                        if (enNodeList.get(0).getUniqueName().equals(nodeList.get(1).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(0).getUniqueName())) {
                            exist = true;
                        } else if (enNodeList.get(0).getUniqueName().equals(nodeList.get(0).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(1).getUniqueName())) {
                            exist = true;
                        }
                    }
                }
                if (!exist) {
                    middConnMap.put(nodeList, connList);
                }
            }
        }
    }
    return middConnMap;
}
Also used : INode(org.talend.core.model.process.INode) HashMap(java.util.HashMap) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) AbstractJobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) List(java.util.List)

Example 64 with Process

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

the class ChangeConnectionStatusCommand method execute.

public void execute() {
    INode target = connection.getTarget();
    if (connection.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
        connection.setLineStyle(EConnectionType.FLOW_REF);
    } else {
        boolean found = false;
        for (int i = 0; i < target.getIncomingConnections().size() && !found; i++) {
            Connection currentConnection = (Connection) target.getIncomingConnections().get(i);
            if (currentConnection.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
                oldMainConnection = currentConnection;
                oldMainConnection.setLineStyle(EConnectionType.FLOW_REF);
            }
        }
        connection.setLineStyle(EConnectionType.FLOW_MAIN);
    }
    if (target.getExternalNode() != null) {
        target.getExternalNode().connectionStatusChanged(connection.getLineStyle(), connection.getUniqueName());
    }
    ((Process) connection.getSource().getProcess()).checkStartNodes();
    ((Process) connection.getSource().getProcess()).checkProcess();
}
Also used : INode(org.talend.core.model.process.INode) Connection(org.talend.designer.core.ui.editor.connections.Connection) Process(org.talend.designer.core.ui.editor.process.Process)

Example 65 with Process

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

the class ChangeConnTextCommand method undo.

@Override
public void undo() {
    connection.setName(oldName);
    IElementParameter elementParameter = connection.getElementParameter(EParameterName.UNIQUE_NAME.getName());
    if (elementParameter != null) {
        // if ("TABLE".equals(connection.getConnectorName())) {
        if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.TABLE)) {
            connection.setPropertyValue(EParameterName.UNIQUE_NAME.getName(), oldMetaName);
        } else {
            connection.setPropertyValue(EParameterName.UNIQUE_NAME.getName(), oldName);
        }
    }
    if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.UNIQUE_NAME)) {
        connection.getSource().getProcess().removeUniqueConnectionName(newName);
        connection.getSource().getProcess().addUniqueConnectionName(oldName);
    }
    ConnectionListController.renameConnectionInElement(newName, oldName, connection.getSource());
    IExternalNode externalNode = connection.getTarget().getExternalNode();
    if (externalNode != null) {
        externalNode.renameInputConnection(newName, oldName);
    }
    externalNode = connection.getSource().getExternalNode();
    if (externalNode != null) {
        externalNode.renameOutputConnection(newName, oldName);
    }
    UpgradeElementHelper.renameData(connection.getTarget(), newName, oldName);
    ((Process) connection.getSource().getProcess()).checkProcess();
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) IExternalNode(org.talend.core.model.process.IExternalNode)

Aggregations

Process (org.talend.designer.core.ui.editor.process.Process)119 Node (org.talend.designer.core.ui.editor.nodes.Node)69 INode (org.talend.core.model.process.INode)48 ArrayList (java.util.ArrayList)45 IComponent (org.talend.core.model.components.IComponent)36 IElementParameter (org.talend.core.model.process.IElementParameter)28 Test (org.junit.Test)26 List (java.util.List)25 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)25 IProcess (org.talend.core.model.process.IProcess)24 Connection (org.talend.designer.core.ui.editor.connections.Connection)24 Property (org.talend.core.model.properties.Property)23 INodeConnector (org.talend.core.model.process.INodeConnector)22 IConnection (org.talend.core.model.process.IConnection)20 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)20 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)15 ProcessItem (org.talend.core.model.properties.ProcessItem)12 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)11 HashMap (java.util.HashMap)10 Before (org.junit.Before)9