Search in sources :

Example 16 with NodeContainer

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

the class DeleteNodeContainerCommand method undo.

@Override
@SuppressWarnings("unchecked")
public void undo() {
    process.setActivate(false);
    for (INode node : nodeList) {
        if (node.getJobletNode() != null) {
            continue;
        }
        NodeContainer nodeContainer = ((Node) node).getNodeContainer();
        this.process.addUniqueNodeName(node.getUniqueName());
        ((Process) process).addNodeContainer(nodeContainer);
        List<Connection> inputList = (List<Connection>) node.getIncomingConnections();
        List<Connection> outputList = (List<Connection>) node.getOutgoingConnections();
        boolean builtIn = node.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
        for (Connection connection : inputList) {
            // see bug 0004514: need to undo for 0002633
            if (connection != null && connection.getSourceNodeConnector() != null) {
                connection.getSourceNodeConnector().setCurLinkNbOutput(connection.getSourceNodeConnector().getCurLinkNbOutput() + 1);
            }
            INode prevNode = connection.getSource();
            if ((prevNode instanceof Node) && ((Node) prevNode).getJobletNode() != null) {
                Node jobletnode = (Node) prevNode.getJobletNode();
                ((AbstractJobletContainer) jobletnode.getNodeContainer()).getOutputs().add(connection);
                restoreMetadata(connection, jobletnode);
            }
            if (!nodeList.contains(prevNode)) {
                if (!prevNode.getOutgoingConnections().contains(connection)) {
                    prevNode.addOutput(connection);
                }
                restoreMetadata(connection, prevNode);
                connection.reconnect();
                connection.updateAllId();
                boolean builtInPrevNode = prevNode.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
                if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.UNIQUE_NAME) && !builtInPrevNode) {
                    // for bug 10024
                    // see 10583
                    String name = connection.getUniqueName();
                    if (connection.getConnectorName().startsWith("TRIGGER_OUTPUT")) {
                        if (process.checkValidConnectionName(name)) {
                            process.addUniqueConnectionName(name);
                        }
                    } else {
                        process.addUniqueConnectionName(name);
                    }
                }
            }
        }
        for (IConnection connection : outputList) {
            INode nextNode = connection.getTarget();
            if ((nextNode instanceof Node) && ((Node) nextNode).getJobletNode() != null) {
                Node jobletnode = (Node) nextNode.getJobletNode();
                ((AbstractJobletContainer) jobletnode.getNodeContainer()).getInputs().add(connection);
            }
            if (!nodeList.contains(nextNode)) {
                if (!nextNode.getIncomingConnections().contains(connection)) {
                    nextNode.addInput(connection);
                }
                INodeConnector nodeConnector = nextNode.getConnectorFromType(connection.getLineStyle());
                nodeConnector.setCurLinkNbInput(nodeConnector.getCurLinkNbInput() + 1);
                connection.reconnect();
                if (nextNode.getExternalNode() instanceof AbstractNode) {
                    ((AbstractNode) nextNode.getExternalNode()).addInput(connection);
                }
            }
            if (!builtIn) {
                if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.UNIQUE_NAME)) {
                    // for bug 10024
                    // see 10583
                    String name = connection.getUniqueName();
                    // name = process.generateUniqueConnectionName(name);
                    process.addUniqueConnectionName(name);
                }
            }
        }
        if (builtIn) {
            for (IMetadataTable meta : node.getMetadataList()) {
                String metaName = meta.getTableName();
                process.addUniqueConnectionName(metaName);
            }
            // tmap join table
            for (String name : joinTableNames) {
                process.addUniqueConnectionName(name);
            }
        }
    }
    process.setActivate(true);
    process.checkStartNodes();
    process.checkProcess();
}
Also used : 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) 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) Process(org.talend.designer.core.ui.editor.process.Process) IConnection(org.talend.core.model.process.IConnection) INodeConnector(org.talend.core.model.process.INodeConnector) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) List(java.util.List)

Example 17 with NodeContainer

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

the class ExternalNodeChangeCommand method changeCollapsedState.

private void changeCollapsedState(boolean state, Map<String, Boolean> map, INode node) {
    if (node instanceof Node) {
        NodeContainer nc = ((Node) node).getNodeContainer();
        if ((nc instanceof AbstractJobletContainer) && nc.getNode().isJoblet()) {
            if (((AbstractJobletContainer) nc).isCollapsed() && !state) {
                map.put(nc.getNode().getUniqueName(), false);
                ((AbstractJobletContainer) nc).setCollapsed(state);
            } else if (!((AbstractJobletContainer) nc).isCollapsed() && state) {
                if (map.get(nc.getNode().getUniqueName()) != null && !map.get(nc.getNode().getUniqueName())) {
                    ((AbstractJobletContainer) nc).setCollapsed(state);
                }
            }
        }
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) AbstractJobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer)

Example 18 with NodeContainer

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

the class NodesMoveCommond method findLocationForNodeInContainerList.

private Point findLocationForNodeInContainerList(final Point location, Dimension size, int index, int firstIndex, Node copiedNode) {
    Rectangle copiedRect = new Rectangle(location, size);
    Point newLocation = new Point(location);
    if (getCursorLocation() == null) {
        for (NodeContainer nodeContainer : nodeContainerList) {
            IGraphicalNode node = nodeContainer.getNode();
            Rectangle currentRect = new Rectangle((Point) node.getLocation(), (Dimension) node.getSize());
            if (currentRect.intersects(copiedRect)) {
                newLocation.x += size.width;
                newLocation.y += size.height;
                // newLocation = computeTheDistance(index, firstIndex, newLocation);
                Point tmpPoint = findLocationForNodeInProcess(newLocation, size);
                return findLocationForNodeInContainerList(tmpPoint, size, index, firstIndex, copiedNode);
            }
        }
        return newLocation;
    }
    if (!node.equals(copiedNode)) {
        newLocation = computeTheDistance(index, firstIndex, newLocation);
    }
    return newLocation;
}
Also used : IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Point(org.eclipse.draw2d.geometry.Point)

Example 19 with NodeContainer

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

the class NodesMoveCommond method undo.

@SuppressWarnings("unchecked")
@Override
public void undo() {
    // remove the current selection
    AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
    if (!multipleCommand) {
        viewer.deselectAll();
    }
    for (NodeContainer nodeContainer : nodeContainerList) {
        // remove the connections name from the list
        for (Connection connection : (List<Connection>) nodeContainer.getNode().getOutgoingConnections()) {
            process.removeUniqueConnectionName(connection.getName());
        }
        ((Process) process).removeNodeContainer(nodeContainer);
    }
    // check that the created connections are removed, remove them if not
    for (String newConnectionName : createdNames) {
        if (!process.checkValidConnectionName(newConnectionName, true)) {
            process.removeUniqueConnectionName(newConnectionName);
        }
    }
    process.checkStartNodes();
    process.checkProcess();
    // set the old selection active
    if (!multipleCommand) {
        StructuredSelection s = new StructuredSelection(oldSelection);
        viewer.setSelection(s);
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) List(java.util.List) ArrayList(java.util.ArrayList) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process)

Example 20 with NodeContainer

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

the class SubjobContainer method refreshNodesLocation.

public void refreshNodesLocation(boolean jobletCollapsed, AbstractJobletContainer nc, int rightChangewidth, int downChangeheight, int leftChangewidth, int upChangeheight) {
    JobletUtil util = new JobletUtil();
    Node node = nc.getNode();
    Rectangle jobletRec = new Rectangle(node.getLocation(), node.getSize());
    boolean isJobletSubjob = nc.getSubjobContainer() == this;
    for (NodeContainer container : nodeContainers) {
        if (container.getNode().getUniqueName().equals(nc.getNode().getUniqueName())) {
            continue;
        }
        Point nodePoint = container.getNode().getLocation().getCopy();
        Rectangle jRec = util.getExpandRectangle(jobletRec);
        // Rectangle jNodeConRec = util.getExpandRectangle(nodeConRec);
        // Rectangle pointrec = util.getExpandRectangle(container.getNodeContainerRectangle());
        jRec.width = jRec.width + rightChangewidth + leftChangewidth;
        jRec.height = jRec.height + downChangeheight + upChangeheight;
        // jNodeConRec.height = jNodeConRec.height + changeheight;
        if (!jobletCollapsed) {
            if (!nc.isUpdate()) {
                Point origPoint = new Point(nodePoint.x, nodePoint.y);
                pointMap.put(container.getNode().getUniqueName(), origPoint);
                if (isJobletSubjob) {
                    if (nodePoint.x > jobletRec.x) {
                        nodePoint.x = nodePoint.x + rightChangewidth;
                    }
                    if (nodePoint.y > jobletRec.y) {
                        nodePoint.y = nodePoint.y + downChangeheight;
                    }
                    if (nodePoint.x < jobletRec.x) {
                        nodePoint.x = nodePoint.x - leftChangewidth;
                    }
                    if (nodePoint.y < jobletRec.y) {
                        nodePoint.y = nodePoint.y - upChangeheight;
                    }
                } else {
                    Rectangle jobletSubRec = nc.getSubjobContainer().getSubjobContainerRectangle();
                    Rectangle currentRec = this.getSubjobContainerRectangle();
                    if (nodePoint.x > jobletRec.x && !(currentRec.y < jobletSubRec.y && currentRec.y + currentRec.height <= jobletSubRec.y + upChangeheight + node.getSize().height || jobletSubRec.y + jobletSubRec.height <= currentRec.y + downChangeheight + node.getSize().height && currentRec.y > jobletSubRec.y)) {
                        nodePoint.x = nodePoint.x + rightChangewidth;
                    }
                    if (nodePoint.y > jobletRec.y && !(currentRec.x < jobletSubRec.x && currentRec.x + currentRec.width <= jobletSubRec.x + leftChangewidth + node.getSize().width || jobletSubRec.x + jobletSubRec.width <= currentRec.x + rightChangewidth + node.getSize().width && currentRec.x > jobletSubRec.x)) {
                        nodePoint.y = nodePoint.y + downChangeheight;
                    }
                    if (nodePoint.x < jobletRec.x && !(currentRec.y < jobletSubRec.y && currentRec.y + currentRec.height <= jobletSubRec.y + upChangeheight + node.getSize().height || jobletSubRec.y + jobletSubRec.height <= currentRec.y + downChangeheight + node.getSize().height && currentRec.y > jobletSubRec.y)) {
                        nodePoint.x = nodePoint.x - leftChangewidth;
                    }
                    if (nodePoint.y < jobletRec.y && !(currentRec.x < jobletSubRec.x && currentRec.x + currentRec.width <= jobletSubRec.x + leftChangewidth + node.getSize().width || jobletSubRec.x + jobletSubRec.width <= currentRec.x + rightChangewidth + node.getSize().width && currentRec.x > jobletSubRec.x)) {
                        nodePoint.y = nodePoint.y - upChangeheight;
                    }
                }
            }
        } else {
            nodePoint = pointMap.get(container.getNode().getUniqueName());
        // if (nodePoint.x > nodeRec.x && nodePoint.x > rightChangewidth) {
        // nodePoint.x = nodePoint.x - rightChangewidth;
        // }
        // if (nodePoint.x < nodeRec.x) {
        // nodePoint.x = nodePoint.x + leftChangewidth;
        // }
        // if (nodePoint.y > nodeRec.y && nodePoint.y > downChangeheight) {
        // if ((nodePoint.y - downChangeheight) > (nodeRec.y + 64)) {
        // nodePoint.y = nodePoint.y - downChangeheight;
        // } else {
        // nodePoint.y = nodeRec.y + 64;
        // }
        //
        // }
        }
        container.getNode().setLocation(nodePoint);
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Point(org.eclipse.draw2d.geometry.Point) JobletUtil(org.talend.designer.core.ui.editor.jobletcontainer.JobletUtil)

Aggregations

NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)60 Node (org.talend.designer.core.ui.editor.nodes.Node)43 ArrayList (java.util.ArrayList)23 INode (org.talend.core.model.process.INode)23 List (java.util.List)20 Process (org.talend.designer.core.ui.editor.process.Process)20 Point (org.eclipse.draw2d.geometry.Point)17 IComponent (org.talend.core.model.components.IComponent)13 IConnection (org.talend.core.model.process.IConnection)12 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)12 Rectangle (org.eclipse.draw2d.geometry.Rectangle)11 IProcess (org.talend.core.model.process.IProcess)11 Connection (org.talend.designer.core.ui.editor.connections.Connection)11 IElementParameter (org.talend.core.model.process.IElementParameter)10 EditPart (org.eclipse.gef.EditPart)9 IExternalNode (org.talend.core.model.process.IExternalNode)9 IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)9 CreateNodeContainerCommand (org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand)9 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)9 HashMap (java.util.HashMap)8