Search in sources :

Example 1 with ProgressPolylineConnection

use of org.knime.workbench.editor2.figures.ProgressPolylineConnection in project knime-core by knime.

the class WorkflowEditorDropTargetListener method dragOver.

/**
 * {@inheritDoc}
 *
 * Marks nodes or edges if a new node should replace an old node or should be inserted on an edge.
 */
@Override
public void dragOver(final DropTargetEvent event) {
    WorkflowManagerUI wfm = ((WorkflowRootEditPart) getViewer().getRootEditPart().getContents()).getWorkflowManager();
    m_node = null;
    m_edge = null;
    m_nodeCount = 0;
    m_edgeCount = 0;
    // edge-/nodedist
    double edgedist = Integer.MAX_VALUE;
    double nodedist = Integer.MAX_VALUE;
    Point dropLocation = getDropLocation(event);
    EditPart ep = getViewer().findObjectAt(dropLocation.getTranslated(0, 0));
    if (ep instanceof NodeContainerEditPart) {
        double temp = dropLocation.getDistance(dropLocation.getTranslated(0, 0));
        // choose nearest node to mouse position
        if (nodedist >= temp) {
            m_node = (NodeContainerEditPart) ep;
            nodedist = temp;
        }
        m_nodeCount++;
    } else if (ep instanceof ConnectionContainerEditPart) {
        double temp = dropLocation.getDistance(dropLocation.getTranslated(0, 0));
        // choose nearest edge to mouse-position
        if (edgedist >= temp) {
            m_edge = (ConnectionContainerEditPart) ep;
            edgedist = temp;
        }
        m_edgeCount++;
    }
    unmark(wfm);
    if (m_node != null && m_nodeCount >= m_edgeCount) {
        m_markedNode = m_node;
        m_markedNode.mark();
        // workaround for eclipse bug 393868 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=393868)
        WindowsDNDHelper.hideDragImage();
    } else if (m_edge != null) {
        m_edgeColor = m_edge.getFigure().getForegroundColor();
        m_edgeWidth = ((ProgressPolylineConnection) m_edge.getFigure()).getLineWidth();
        m_markedEdge = m_edge;
        ((ProgressPolylineConnection) m_markedEdge.getFigure()).setLineWidth(m_edgeWidth + 3);
        m_markedEdge.getFigure().setForegroundColor(RED);
        // workaround for eclipse bug 393868 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=393868)
        WindowsDNDHelper.hideDragImage();
    }
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowInPortBarEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) EditPart(org.eclipse.gef.EditPart) WorkflowOutPortBarEditPart(org.knime.workbench.editor2.editparts.WorkflowOutPortBarEditPart) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) ProgressPolylineConnection(org.knime.workbench.editor2.figures.ProgressPolylineConnection) Point(org.eclipse.draw2d.geometry.Point)

Example 2 with ProgressPolylineConnection

use of org.knime.workbench.editor2.figures.ProgressPolylineConnection in project knime-core by knime.

the class ConnectionContainerEditPart method createFigure.

/**
 * {@inheritDoc}
 */
@Override
protected IFigure createFigure() {
    ProgressPolylineConnection conn = new CurvedPolylineConnection(false);
    // Bendpoints
    SnapOffBendPointConnectionRouter router = new SnapOffBendPointConnectionRouter();
    conn.setConnectionRouter(router);
    conn.setRoutingConstraint(new ArrayList());
    conn.setLineWidth(getCurrentEditorSettings().getConnectionLineWidth());
    // make flow variable port connections look red.
    if (getModel().isFlowVariablePortConnection()) {
        conn.setForegroundColor(AbstractPortFigure.getFlowVarPortColor());
    }
    return conn;
}
Also used : SnapOffBendPointConnectionRouter(org.knime.workbench.editor2.editparts.snap.SnapOffBendPointConnectionRouter) ArrayList(java.util.ArrayList) ProgressPolylineConnection(org.knime.workbench.editor2.figures.ProgressPolylineConnection) CurvedPolylineConnection(org.knime.workbench.editor2.figures.CurvedPolylineConnection)

Example 3 with ProgressPolylineConnection

use of org.knime.workbench.editor2.figures.ProgressPolylineConnection in project knime-core by knime.

the class ConnectionContainerEditPart method progressChanged.

/**
 * {@inheritDoc}
 */
@Override
public void progressChanged(final ConnectionProgressEvent pe) {
    ProgressPolylineConnection conn = (ProgressPolylineConnection) getFigure();
    conn.progressChanged(pe.getConnectionProgress());
}
Also used : ProgressPolylineConnection(org.knime.workbench.editor2.figures.ProgressPolylineConnection)

Aggregations

ProgressPolylineConnection (org.knime.workbench.editor2.figures.ProgressPolylineConnection)3 ArrayList (java.util.ArrayList)1 Point (org.eclipse.draw2d.geometry.Point)1 EditPart (org.eclipse.gef.EditPart)1 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)1 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)1 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)1 WorkflowInPortBarEditPart (org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart)1 WorkflowOutPortBarEditPart (org.knime.workbench.editor2.editparts.WorkflowOutPortBarEditPart)1 WorkflowRootEditPart (org.knime.workbench.editor2.editparts.WorkflowRootEditPart)1 SnapOffBendPointConnectionRouter (org.knime.workbench.editor2.editparts.snap.SnapOffBendPointConnectionRouter)1 CurvedPolylineConnection (org.knime.workbench.editor2.figures.CurvedPolylineConnection)1