Search in sources :

Example 36 with NodePart

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

the class CreateComponentOnLinkHelper method getConnection.

public static List<Connection> getConnection(SubjobContainerPart containerPart, Point point, Node node) {
    List<Connection> connectionList = new ArrayList<Connection>();
    List<Connection> connList = new ArrayList<Connection>();
    List children = containerPart.getChildren();
    for (int i = 0; i < children.size(); i++) {
        Object object = children.get(i);
        if (object instanceof NodeContainerPart) {
            NodeContainerPart nodePart = (NodeContainerPart) object;
            Object o = nodePart.getChildren().get(0);
            if (o instanceof NodePart) {
                List connections = ((NodePart) o).getSourceConnections();
                for (int j = 0; j < connections.size(); j++) {
                    Object connection = connections.get(j);
                    if (connection instanceof ConnectionPart) {
                        ConnectionPart connPart = (ConnectionPart) connection;
                        Connection conn = (Connection) connPart.getModel();
                        if (canCreateNodeOnLink(conn, node)) {
                            Rectangle bounds = ((ConnectionPart) connection).getFigure().getBounds();
                            // System.out.println("location:" + point);
                            if (bounds.contains(point)) {
                                // System.out.println("bounds:" + bounds);
                                connectionList.add(conn);
                            }
                            if (containsPoint(bounds, point)) {
                                // System.out.println("contains");
                                connList.add(conn);
                            }
                        }
                    }
                }
            }
        }
    }
    if (!connectionList.isEmpty()) {
        return connectionList;
    } else {
        return connList;
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) PolylineConnection(org.eclipse.draw2d.PolylineConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) Rectangle(org.eclipse.draw2d.geometry.Rectangle) ArrayList(java.util.ArrayList) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) Point(org.eclipse.draw2d.geometry.Point)

Example 37 with NodePart

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

the class SetParallelizationAction method run.

@Override
public void run() {
    List editparts = getSelectedObjects();
    if (editparts.size() == 1) {
        Object o = editparts.get(0);
        if (o instanceof NodePart) {
            NodePart part = (NodePart) o;
            Node node = (Node) part.getModel();
            getCommandStack().execute(new SetParallelizationCommand(node));
        } else if (o instanceof SubjobContainerPart) {
            boolean hasStartNode = false;
            List<NodeContainerPart> childNodes = ((SubjobContainerPart) o).getChildren();
            for (NodeContainerPart childNode : childNodes) {
                NodeContainerPart part = (NodeContainerPart) childNode;
                NodeContainer node = (NodeContainer) part.getModel();
                if (node.getNode().isStart()) {
                    hasStartNode = true;
                    getCommandStack().execute(new SetParallelizationCommand(node.getNode()));
                }
            }
            if (!hasStartNode) {
                for (NodeContainerPart childNode : childNodes) {
                    NodeContainerPart part = (NodeContainerPart) childNode;
                    NodeContainer node = (NodeContainer) part.getModel();
                    if (node.getNode().isSubProcessStart()) {
                        getCommandStack().execute(new SetParallelizationCommand(node.getNode()));
                    }
                }
            }
        }
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) SetParallelizationCommand(org.talend.designer.core.ui.editor.cmd.SetParallelizationCommand) Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)

Example 38 with NodePart

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

the class SearchComponentAction method run.

@Override
public void run() {
    List selection = getSelectedObjects();
    Object input = selection.get(0);
    if (input instanceof NodePart) {
        NodePart part = (NodePart) input;
        Node node = (Node) part.getModel();
        final String nodeName = node.getComponent().getName();
        // System.out.println(nodeName);
        ComponentSearcher searcher = new ComponentSearcher(nodeName, getWorkbenchPart().getSite().getShell());
        searcher.run();
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 39 with NodePart

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

the class SearchComponentAction method calculateEnabled.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
     */
@Override
protected boolean calculateEnabled() {
    List parts = getSelectedObjects();
    if (parts.size() != 1) {
        return false;
    }
    // TESB-17218: Hide for route test case editor
    if (PluginUtil.isMediation() || PluginUtil.isRouteTestEditor()) {
        return false;
    }
    Object o = parts.get(0);
    if (o instanceof NodePart) {
        Node node = (Node) ((NodePart) o).getModel();
        if (node.getJobletNode() != null) {
            return false;
        }
        return true;
    }
    return false;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 40 with NodePart

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

the class SetParallelizationAction method calculateEnabled.

@Override
protected boolean calculateEnabled() {
    List parts = getSelectedObjects();
    if (parts.isEmpty()) {
        return false;
    }
    if (parts.size() == 1) {
        Object o = parts.get(0);
        if (o instanceof SubjobContainerPart) {
            SubjobContainerPart part = (SubjobContainerPart) o;
            SubjobContainer subjob = (SubjobContainer) part.getModel();
            if (subjob.getProcess().getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
                if (subjob.isDisplayed()) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        } else if (o instanceof NodePart) {
            NodePart part = (NodePart) o;
            Node node = (Node) part.getModel();
            if (node.getProcess().getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
                if (node.isStart()) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
    return false;
}
Also used : SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Aggregations

NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)59 List (java.util.List)45 Node (org.talend.designer.core.ui.editor.nodes.Node)39 ArrayList (java.util.ArrayList)27 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)23 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)17 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)17 EditPart (org.eclipse.gef.EditPart)16 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)15 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)14 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)14 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)14 Connection (org.talend.designer.core.ui.editor.connections.Connection)12 INode (org.talend.core.model.process.INode)10 Point (org.eclipse.draw2d.geometry.Point)9 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)9 SubjobContainer (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer)9 NodeTreeEditPart (org.talend.designer.core.ui.editor.outline.NodeTreeEditPart)7 GraphicalViewer (org.eclipse.gef.GraphicalViewer)6 IConnection (org.talend.core.model.process.IConnection)6