Search in sources :

Example 6 with NodeInPortEditPart

use of org.knime.workbench.editor2.editparts.NodeInPortEditPart in project knime-core by knime.

the class NodeContainerEditPart method updateFigureFromUIinfo.

private void updateFigureFromUIinfo(final NodeUIInformation uiInfo) {
    NodeContainerFigure fig = (NodeContainerFigure) getFigure();
    setBoundsFromUIinfo(uiInfo);
    // update tooltip
    fig.setCustomDescription(getNodeContainer().getCustomDescription());
    // check status of node
    updateNodeMessage();
    // reset the tooltip text of the outports
    for (Object part : getChildren()) {
        if (part instanceof NodeOutPortEditPart) {
            NodeOutPortEditPart outPortPart = (NodeOutPortEditPart) part;
            outPortPart.rebuildTooltip();
        }
    }
    // for sub node refresh all tooltips
    if (getNodeContainer() instanceof SubNodeContainerUI) {
        for (Object part : getChildren()) {
            if (part instanceof NodeInPortEditPart) {
                NodeInPortEditPart inPortPart = (NodeInPortEditPart) part;
                inPortPart.rebuildTooltip();
            }
            if (part instanceof NodeOutPortEditPart) {
                NodeOutPortEditPart outPortPart = (NodeOutPortEditPart) part;
                outPortPart.rebuildTooltip();
            }
        }
    }
    // always refresh visuals
    refreshVisuals();
}
Also used : SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) NodeContainerFigure(org.knime.workbench.editor2.figures.NodeContainerFigure)

Example 7 with NodeInPortEditPart

use of org.knime.workbench.editor2.editparts.NodeInPortEditPart in project knime-core by knime.

the class SnapToPortGeometry method snapRectangle.

/**
 * {@inheritDoc}
 */
@Override
public int snapRectangle(final Request request, int snapOrientation, PrecisionRectangle baseRect, final PrecisionRectangle result) {
    assert (request instanceof ChangeBoundsRequest) : "Unexpected request type: " + request.getClass();
    ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest) request;
    baseRect = baseRect.getPreciseCopy();
    makeRelative(m_container.getContentPane(), baseRect);
    PrecisionRectangle correction = new PrecisionRectangle();
    makeRelative(m_container.getContentPane(), correction);
    // Recalculate snapping locations if needed
    boolean isClone = request.getType().equals(RequestConstants.REQ_CLONE);
    List exclusionSet = null;
    if (m_rows == null || m_cols == null || isClone != m_cachedCloneBool) {
        m_cachedCloneBool = isClone;
        exclusionSet = Collections.EMPTY_LIST;
        if (!isClone) {
            exclusionSet = changeBoundsRequest.getEditParts();
        }
        populateRowsAndCols(generateSnapPartsList(exclusionSet), exclusionSet);
    }
    if ((snapOrientation & HORIZONTAL) != 0) {
        double xcorrect = getCorrectionFor(m_cols, changeBoundsRequest.getExtendedData(), true, baseRect.preciseX, baseRect.preciseRight());
        if (xcorrect != THRESHOLD) {
            snapOrientation &= ~HORIZONTAL;
            correction.preciseX += xcorrect;
        }
    }
    // get y values of the draged node part ports
    if (exclusionSet != null) {
        List<AbstractPortEditPart> ports = getPorts(exclusionSet);
        Entry[] yValues = new Entry[ports.size()];
        int i = 0;
        for (AbstractPortEditPart port : ports) {
            boolean inport = false;
            if (port instanceof NodeInPortEditPart || port instanceof WorkflowInPortEditPart) {
                inport = true;
            }
            yValues[i] = new Entry(0, getFigureBounds(port).getLeft().y, inport, port.getType());
            i++;
        }
        m_yValues = yValues;
    }
    // get the move delta of the orignial location
    Point moveDeltaPoint = changeBoundsRequest.getMoveDelta();
    WorkflowEditor.adaptZoom(m_zoomManager, moveDeltaPoint, false);
    int moveDelta = moveDeltaPoint.y;
    if ((snapOrientation & VERTICAL) != 0) {
        double ycorrect = THRESHOLD;
        ycorrect = getCorrectionForY(m_rows, changeBoundsRequest.getExtendedData(), m_yValues, moveDelta);
        if (Math.abs(ycorrect) < THRESHOLD) {
            snapOrientation &= ~VERTICAL;
            correction.preciseY += ycorrect;
        }
    }
    if ((snapOrientation & EAST) != 0) {
        double rightCorrection = getCorrectionFor(m_cols, request.getExtendedData(), true, baseRect.preciseRight() - 1, 1);
        if (rightCorrection != THRESHOLD) {
            snapOrientation &= ~EAST;
            correction.preciseWidth += rightCorrection;
        }
    }
    if ((snapOrientation & WEST) != 0) {
        double leftCorrection = getCorrectionFor(m_cols, request.getExtendedData(), true, baseRect.preciseX, -1);
        if (leftCorrection != THRESHOLD) {
            snapOrientation &= ~WEST;
            correction.preciseWidth -= leftCorrection;
            correction.preciseX += leftCorrection;
        }
    }
    if ((snapOrientation & SOUTH) != 0) {
        double bottom = getCorrectionFor(m_rows, request.getExtendedData(), false, baseRect.preciseBottom() - 1, 1);
        if (bottom != THRESHOLD) {
            snapOrientation &= ~SOUTH;
            correction.preciseHeight += bottom;
        }
    }
    if ((snapOrientation & NORTH) != 0) {
        double topCorrection = getCorrectionFor(m_rows, request.getExtendedData(), false, baseRect.preciseY, -1);
        if (topCorrection != THRESHOLD) {
            snapOrientation &= ~NORTH;
            correction.preciseHeight -= topCorrection;
            correction.preciseY += topCorrection;
        }
    }
    correction.updateInts();
    makeAbsolute(m_container.getContentPane(), correction);
    result.preciseX += correction.preciseX;
    result.preciseY += correction.preciseY;
    result.preciseWidth += correction.preciseWidth;
    result.preciseHeight += correction.preciseHeight;
    result.updateInts();
    return snapOrientation;
}
Also used : PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) AbstractPortEditPart(org.knime.workbench.editor2.editparts.AbstractPortEditPart) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point) NodeInPortEditPart(org.knime.workbench.editor2.editparts.NodeInPortEditPart) ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) ArrayList(java.util.ArrayList) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) WorkflowInPortEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortEditPart)

Aggregations

NodeInPortEditPart (org.knime.workbench.editor2.editparts.NodeInPortEditPart)6 AbstractPortEditPart (org.knime.workbench.editor2.editparts.AbstractPortEditPart)5 WorkflowInPortEditPart (org.knime.workbench.editor2.editparts.WorkflowInPortEditPart)5 WorkflowOutPortEditPart (org.knime.workbench.editor2.editparts.WorkflowOutPortEditPart)4 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)3 MetaNodeOutPortEditPart (org.knime.workbench.editor2.editparts.MetaNodeOutPortEditPart)3 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)3 NodeOutPortEditPart (org.knime.workbench.editor2.editparts.NodeOutPortEditPart)3 WorkflowInPortBarEditPart (org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Point (org.eclipse.draw2d.geometry.Point)2 PointList (org.eclipse.draw2d.geometry.PointList)2 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)2 EditPart (org.eclipse.gef.EditPart)2 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)2 CreateConnectionCommand (org.knime.workbench.editor2.commands.CreateConnectionCommand)2 ConnectableEditPart (org.knime.workbench.editor2.editparts.ConnectableEditPart)2 WorkflowPortBar (org.knime.workbench.editor2.model.WorkflowPortBar)2 Connection (org.eclipse.draw2d.Connection)1