Search in sources :

Example 1 with ConnectionFigure

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

the class TalendEditorComponentCreationAssist method highlightOveredConnection.

private void highlightOveredConnection(org.eclipse.swt.graphics.Point cursorRelativePosition) {
    if (overedConnection != null) {
        overedConnection.setLineWidth(1);
        overedConnection = null;
    }
    EditPart findObjectAt = graphicViewer.findObjectAt(new Point(cursorRelativePosition.x, cursorRelativePosition.y));
    if (findObjectAt instanceof ConnectionPart) {
        overedConnection = (ConnectionFigure) ((ConnectionPart) findObjectAt).getFigure();
    } else if (findObjectAt instanceof ConnLabelEditPart) {
        overedConnection = (ConnectionFigure) ((ConnectionPart) ((ConnLabelEditPart) findObjectAt).getParent()).getFigure();
    }
    if (overedConnection != null) {
        overedConnection.setLineWidth(2);
    }
}
Also used : ConnectionFigure(org.talend.designer.core.ui.editor.connections.ConnectionFigure) EditPart(org.eclipse.gef.EditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) Point(org.eclipse.draw2d.geometry.Point) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 2 with ConnectionFigure

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

the class NodePart method getSourceConnectionAnchor.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request)
     */
@Override
public ConnectionAnchor getSourceConnectionAnchor(final Request request) {
    if (!DesignerPlugin.getDefault().getPreferenceStore().getBoolean(TalendDesignerPrefConstants.EDITOR_LINESTYLE)) {
        return new ChopboxAnchor(getFigure());
    }
    if (!(request instanceof CreateConnectionRequest)) {
        if (request instanceof ReconnectRequest) {
            IFigure figure = ((ReconnectRequest) request).getConnectionEditPart().getFigure();
            if (figure instanceof ConnectionFigure) {
                ((ConnectionFigure) figure).setConnectionRouter(new TalendBorderItemRectilinearRouter(request));
            }
        }
        return new ChopboxAnchor(getFigure());
    }
    CreateConnectionRequest connReq = (CreateConnectionRequest) request;
    Node source = (Node) ((NodePart) connReq.getSourceEditPart()).getModel();
    // Node target = (Node) ((NodePart) connReq.getTargetEditPart()).getModel();
    // // System.out.println("getSource=> location:" + connReq.getLocation() + " / source:" + source.getLocation() +
    // "
    // // / target:"
    // // + target.getLocation());
    sourceAnchor = new DummyNodeAnchor((NodeFigure) getFigure(), source, false);
    return sourceAnchor;
}
Also used : ReconnectRequest(org.eclipse.gef.requests.ReconnectRequest) ChopboxAnchor(org.eclipse.draw2d.ChopboxAnchor) TalendBorderItemRectilinearRouter(org.talend.designer.core.ui.editor.connections.TalendBorderItemRectilinearRouter) ConnectionFigure(org.talend.designer.core.ui.editor.connections.ConnectionFigure) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) CreateConnectionRequest(org.eclipse.gef.requests.CreateConnectionRequest) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with ConnectionFigure

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

the class CreateComponentOnLinkHelper method unselectAllConnections.

public static void unselectAllConnections(SubjobContainerPart containerPart) {
    List children = containerPart.getChildren();
    for (int i = 0; i < children.size(); i++) {
        Object object = children.get(i);
        if (object instanceof NodeContainerPart) {
            NodeContainerPart nodeContainerPart = (NodeContainerPart) object;
            Object nodePart = nodeContainerPart.getChildren().get(0);
            if (nodePart instanceof NodePart) {
                List sourceConnections = ((NodePart) nodePart).getSourceConnections();
                for (int j = 0; j < sourceConnections.size(); j++) {
                    Object connectionPart = sourceConnections.get(j);
                    if (connectionPart instanceof ConnectionPart) {
                        ConnectionPart connPart = (ConnectionPart) connectionPart;
                        org.talend.designer.core.ui.editor.connections.Connection conn = (org.talend.designer.core.ui.editor.connections.Connection) connPart.getModel();
                        ConnectionFigure fig = (ConnectionFigure) connPart.getFigure();
                        if (fig.getLineWidth() != 1) {
                            fig.setLineWidth(1);
                            connPart.refresh();
                        }
                    }
                }
            }
        }
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) ConnectionFigure(org.talend.designer.core.ui.editor.connections.ConnectionFigure) IConnection(org.talend.core.model.process.IConnection) PolylineConnection(org.eclipse.draw2d.PolylineConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) Point(org.eclipse.draw2d.geometry.Point) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 4 with ConnectionFigure

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

the class CreateComponentOnLinkHelper method selectConnection.

public static void selectConnection(Connection connection, SubjobContainerPart containerPart) {
    List children = containerPart.getChildren();
    for (int i = 0; i < children.size(); i++) {
        Object object = children.get(i);
        if (object instanceof NodeContainerPart) {
            NodeContainerPart nodeContainerPart = (NodeContainerPart) object;
            Object nodePart = nodeContainerPart.getChildren().get(0);
            if (nodePart instanceof NodePart) {
                List sourceConnections = ((NodePart) nodePart).getSourceConnections();
                for (int j = 0; j < sourceConnections.size(); j++) {
                    Object connectionPart = sourceConnections.get(j);
                    if (connectionPart instanceof ConnectionPart) {
                        ConnectionPart connPart = (ConnectionPart) connectionPart;
                        org.talend.designer.core.ui.editor.connections.Connection conn = (org.talend.designer.core.ui.editor.connections.Connection) connPart.getModel();
                        if (conn.equals(connection)) {
                            ConnectionFigure fig = (ConnectionFigure) connPart.getFigure();
                            if (fig.getLineWidth() != 2) {
                                fig.setLineWidth(2);
                                connPart.refresh();
                            }
                        } else {
                            ConnectionFigure fig = (ConnectionFigure) connPart.getFigure();
                            if (fig.getLineWidth() != 1) {
                                fig.setLineWidth(1);
                                connPart.refresh();
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) ConnectionFigure(org.talend.designer.core.ui.editor.connections.ConnectionFigure) IConnection(org.talend.core.model.process.IConnection) PolylineConnection(org.eclipse.draw2d.PolylineConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) Point(org.eclipse.draw2d.geometry.Point) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 5 with ConnectionFigure

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

the class NodePart method getTargetConnectionAnchor.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.Request)
     */
@Override
public ConnectionAnchor getTargetConnectionAnchor(final Request request) {
    if (!DesignerPlugin.getDefault().getPreferenceStore().getBoolean(TalendDesignerPrefConstants.EDITOR_LINESTYLE)) {
        return new ChopboxAnchor(getFigure());
    }
    if (!(request instanceof CreateConnectionRequest)) {
        if (request instanceof ReconnectRequest) {
            IFigure figure = ((ReconnectRequest) request).getConnectionEditPart().getFigure();
            if (figure instanceof ConnectionFigure) {
                ((ConnectionFigure) figure).setConnectionRouter(new TalendBorderItemRectilinearRouter(request));
            }
        }
        return new ChopboxAnchor(getFigure());
    }
    CreateConnectionRequest connReq = (CreateConnectionRequest) request;
    Node source = (Node) ((NodePart) connReq.getSourceEditPart()).getModel();
    Node target = (Node) ((NodePart) connReq.getTargetEditPart()).getModel();
    // // + target.getLocation());
    if (sourceAnchor != null) {
        sourceAnchor.setTarget(target);
    }
    return new DummyNodeAnchor((NodeFigure) getFigure(), source, target, true);
}
Also used : ReconnectRequest(org.eclipse.gef.requests.ReconnectRequest) ChopboxAnchor(org.eclipse.draw2d.ChopboxAnchor) TalendBorderItemRectilinearRouter(org.talend.designer.core.ui.editor.connections.TalendBorderItemRectilinearRouter) ConnectionFigure(org.talend.designer.core.ui.editor.connections.ConnectionFigure) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) CreateConnectionRequest(org.eclipse.gef.requests.CreateConnectionRequest) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

ConnectionFigure (org.talend.designer.core.ui.editor.connections.ConnectionFigure)8 Point (org.eclipse.draw2d.geometry.Point)4 ArrayList (java.util.ArrayList)3 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)3 List (java.util.List)2 ChopboxAnchor (org.eclipse.draw2d.ChopboxAnchor)2 IFigure (org.eclipse.draw2d.IFigure)2 PolylineConnection (org.eclipse.draw2d.PolylineConnection)2 PointList (org.eclipse.draw2d.geometry.PointList)2 CreateConnectionRequest (org.eclipse.gef.requests.CreateConnectionRequest)2 ReconnectRequest (org.eclipse.gef.requests.ReconnectRequest)2 IConnection (org.talend.core.model.process.IConnection)2 IExternalNode (org.talend.core.model.process.IExternalNode)2 INode (org.talend.core.model.process.INode)2 IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)2 Connection (org.talend.designer.core.ui.editor.connections.Connection)2 TalendBorderItemRectilinearRouter (org.talend.designer.core.ui.editor.connections.TalendBorderItemRectilinearRouter)2 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)2 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)2 AnchorListener (org.eclipse.draw2d.AnchorListener)1