Search in sources :

Example 16 with ConnectionUIInformation

use of org.knime.core.node.workflow.ConnectionUIInformation in project knime-core by knime.

the class HorizAlignCommand method undo.

/**
 * {@inheritDoc}
 */
@Override
public void undo() {
    Map<NodeID, NodeUIInformation> oldPositions = m_alignMgr.getOldNodeCoordinates();
    Map<ConnectionID, ConnectionUIInformation> oldBendpoints = m_alignMgr.getOldBendpoints();
    // re-position nodes
    for (Map.Entry<NodeID, NodeUIInformation> e : oldPositions.entrySet()) {
        NodeContainer nc = m_wfm.getNodeContainer(e.getKey());
        if (nc == null) {
            continue;
        }
        nc.setUIInformation(e.getValue());
    }
    // re-create bendpoints
    for (Map.Entry<ConnectionID, ConnectionUIInformation> e : oldBendpoints.entrySet()) {
        ConnectionContainer cc = m_wfm.getConnection(e.getKey());
        if (cc == null) {
            continue;
        }
        cc.setUIInfo(e.getValue());
    }
}
Also used : ConnectionID(org.knime.core.node.workflow.ConnectionID) ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) NodeID(org.knime.core.node.workflow.NodeID) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) NodeContainer(org.knime.core.node.workflow.NodeContainer) Map(java.util.Map)

Example 17 with ConnectionUIInformation

use of org.knime.core.node.workflow.ConnectionUIInformation in project knime-core by knime.

the class VerticAlignCommand method undo.

/**
 * {@inheritDoc}
 */
@Override
public void undo() {
    Map<NodeID, NodeUIInformation> oldPositions = m_alignMgr.getOldNodeCoordinates();
    Map<ConnectionID, ConnectionUIInformation> oldBendpoints = m_alignMgr.getOldBendpoints();
    // re-position nodes
    for (Map.Entry<NodeID, NodeUIInformation> e : oldPositions.entrySet()) {
        NodeContainer nc = m_wfm.getNodeContainer(e.getKey());
        if (nc == null) {
            continue;
        }
        nc.setUIInformation(e.getValue());
    }
    // re-create bendpoints
    for (Map.Entry<ConnectionID, ConnectionUIInformation> e : oldBendpoints.entrySet()) {
        ConnectionContainer cc = m_wfm.getConnection(e.getKey());
        if (cc == null) {
            continue;
        }
        cc.setUIInfo(e.getValue());
    }
}
Also used : ConnectionID(org.knime.core.node.workflow.ConnectionID) ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) NodeID(org.knime.core.node.workflow.NodeID) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) NodeContainer(org.knime.core.node.workflow.NodeContainer) Map(java.util.Map)

Example 18 with ConnectionUIInformation

use of org.knime.core.node.workflow.ConnectionUIInformation in project knime-core by knime.

the class NewBendpointMoveCommand method undo.

/**
 * {@inheritDoc}
 */
@Override
public void undo() {
    ConnectionContainer connection = getConnection();
    ConnectionUIInformation uiInfo = connection.getUIInfo();
    Point oldLocation = m_oldLocation.getCopy();
    Builder builder = ConnectionUIInformation.builder(uiInfo);
    builder.removeBendpoint(m_index);
    builder.addBendpoint(oldLocation.x, oldLocation.y, m_index);
    // issue notification
    connection.setUIInfo(builder.build());
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) Builder(org.knime.core.node.workflow.ConnectionUIInformation.Builder) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) Point(org.eclipse.draw2d.geometry.Point)

Example 19 with ConnectionUIInformation

use of org.knime.core.node.workflow.ConnectionUIInformation in project knime-core by knime.

the class AbstractWorkflowPortBarEditPart method getMinMaxXcoordInWorkflow.

/**
 * returns the minX coordinate and the maxX coordinate of all nodes, annotations and bendpoints in the flow (taking
 * the size of the elements into account). Or Integer.MIN/MAX_value if no elements exist.
 * @return new int[] {minX, maxX};
 */
protected int[] getMinMaxXcoordInWorkflow() {
    int maxX = Integer.MIN_VALUE;
    int minX = Integer.MAX_VALUE;
    // find the smallest and the biggest X coordinate in all the UI infos in the flow
    WorkflowManagerUI manager = ((WorkflowPortBar) getModel()).getWorkflowManager();
    for (NodeContainerUI nc : manager.getNodeContainers()) {
        int nodeWidth = NodeContainerFigure.WIDTH;
        NodeAnnotation nodeAnno = nc.getNodeAnnotation();
        if ((nodeAnno != null) && (nodeAnno.getWidth() > nodeWidth)) {
            nodeWidth = nodeAnno.getWidth();
        }
        NodeUIInformation uiInfo = nc.getUIInformation();
        if (uiInfo != null) {
            int x = uiInfo.getBounds()[0];
            // right border of node
            x = x + (nodeWidth / 2);
            if (maxX < x) {
                maxX = x;
            }
            // left border of node
            x = x - nodeWidth;
            if (minX > x) {
                minX = x;
            }
        }
    }
    for (WorkflowAnnotation anno : manager.getWorkflowAnnotations()) {
        int x = anno.getX();
        if (minX > x) {
            minX = x;
        }
        x = x + anno.getWidth();
        if (maxX < x) {
            maxX = x;
        }
    }
    for (ConnectionContainerUI conn : manager.getConnectionContainers()) {
        ConnectionUIInformation uiInfo = conn.getUIInfo();
        if (uiInfo != null) {
            int[][] bendpoints = uiInfo.getAllBendpoints();
            if (bendpoints != null) {
                for (int[] b : bendpoints) {
                    if (maxX < b[0]) {
                        maxX = b[0];
                    }
                    if (minX > b[0]) {
                        minX = b[0];
                    }
                }
            }
        }
    }
    return new int[] { minX, maxX };
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) WorkflowPortBar(org.knime.workbench.editor2.model.WorkflowPortBar) NodeAnnotation(org.knime.core.node.workflow.NodeAnnotation) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) ConnectionContainerUI(org.knime.core.ui.node.workflow.ConnectionContainerUI) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation)

Aggregations

ConnectionUIInformation (org.knime.core.node.workflow.ConnectionUIInformation)19 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)13 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)8 Point (org.eclipse.draw2d.geometry.Point)7 NodeID (org.knime.core.node.workflow.NodeID)7 ConnectionID (org.knime.core.node.workflow.ConnectionID)6 Map (java.util.Map)5 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)5 NodeContainer (org.knime.core.node.workflow.NodeContainer)4 HashMap (java.util.HashMap)3 ConnectionContainerUI (org.knime.core.ui.node.workflow.ConnectionContainerUI)3 ArrayList (java.util.ArrayList)2 Builder (org.knime.core.node.workflow.ConnectionUIInformation.Builder)2 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)2 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)2 Point2D (java.awt.geom.Point2D)1 HashSet (java.util.HashSet)1 AbsoluteBendpoint (org.eclipse.draw2d.AbsoluteBendpoint)1 EditPartViewer (org.eclipse.gef.EditPartViewer)1 EditorUIInformation (org.knime.core.node.workflow.EditorUIInformation)1