Search in sources :

Example 6 with ConnectionContainer

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

the class DeleteCommand method undo.

/**
 * {@inheritDoc}
 */
@Override
public void undo() {
    // select the new ones....
    if (m_viewer != null && m_viewer.getRootEditPart().getContents() instanceof WorkflowRootEditPart) {
        ((WorkflowRootEditPart) m_viewer.getRootEditPart().getContents()).setFutureSelection(m_nodeIDs);
        m_viewer.deselectAll();
    }
    WorkflowManager hostWFM = getHostWFM();
    if (m_undoPersitor != null) {
        hostWFM.paste(m_undoPersitor);
    }
    for (ConnectionContainer cc : m_connections) {
        ConnectionContainer newCC = hostWFM.addConnection(cc.getSource(), cc.getSourcePort(), cc.getDest(), cc.getDestPort());
        newCC.setUIInfo(cc.getUIInfo());
    }
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager)

Example 7 with ConnectionContainer

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

the class NewBendpointDeleteCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    ConnectionContainer connection = getConnectionContainer();
    ConnectionUIInformation uiInfo = getUIInfo(connection);
    m_point = uiInfo.getBendpoint(m_index);
    uiInfo = ConnectionUIInformation.builder(uiInfo).removeBendpoint(m_index).build();
    // issue notification
    connection.setUIInfo(uiInfo);
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation)

Example 8 with ConnectionContainer

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

the class PasteFromWorkflowPersistorCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    WorkflowManager manager = m_editor.getWorkflowManager().get();
    WorkflowPersistor copyPersistor = m_clipboardObject.getCopyPersistor();
    m_pastedContent = manager.paste(copyPersistor);
    NodeID[] pastedNodes = m_pastedContent.getNodeIDs();
    WorkflowAnnotation[] pastedAnnos = m_pastedContent.getAnnotations();
    // fast lookup below
    Set<NodeID> newIDs = new HashSet<NodeID>();
    List<int[]> insertedElementBounds = new ArrayList<int[]>();
    for (NodeID i : pastedNodes) {
        NodeContainer nc = manager.getNodeContainer(i);
        NodeUIInformation ui = nc.getUIInformation();
        int[] bounds = ui.getBounds();
        insertedElementBounds.add(bounds);
    }
    for (WorkflowAnnotation a : pastedAnnos) {
        int[] bounds = new int[] { a.getX(), a.getY(), a.getWidth(), a.getHeight() };
        insertedElementBounds.add(bounds);
    }
    int[] moveDist = m_shiftCalculator.calculateShift(insertedElementBounds, manager, m_clipboardObject);
    // for redo-operations we need the exact same shift.
    m_shiftCalculator = new FixedShiftCalculator(moveDist);
    for (NodeID id : pastedNodes) {
        newIDs.add(id);
        NodeContainer nc = manager.getNodeContainer(id);
        NodeUIInformation oldUI = nc.getUIInformation();
        NodeUIInformation newUI = NodeUIInformation.builder(oldUI).translate(moveDist).build();
        nc.setUIInformation(newUI);
    }
    for (ConnectionContainer conn : manager.getConnectionContainers()) {
        if (newIDs.contains(conn.getDest()) && newIDs.contains(conn.getSource())) {
            // get bend points and move them
            ConnectionUIInformation oldUI = conn.getUIInfo();
            if (oldUI != null) {
                ConnectionUIInformation newUI = ConnectionUIInformation.builder(oldUI).translate(moveDist).build();
                conn.setUIInfo(newUI);
            }
        }
    }
    for (WorkflowAnnotation a : pastedAnnos) {
        a.shiftPosition(moveDist[0], moveDist[1]);
    }
    EditPartViewer partViewer = m_editor.getViewer();
    partViewer.deselectAll();
    // select the new ones....
    if (partViewer.getRootEditPart().getContents() != null && partViewer.getRootEditPart().getContents() instanceof WorkflowRootEditPart) {
        WorkflowRootEditPart rootEditPart = (WorkflowRootEditPart) partViewer.getRootEditPart().getContents();
        rootEditPart.setFutureSelection(pastedNodes);
        rootEditPart.setFutureAnnotationSelection(Arrays.asList(pastedAnnos));
    }
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) WorkflowPersistor(org.knime.core.node.workflow.WorkflowPersistor) ArrayList(java.util.ArrayList) EditPartViewer(org.eclipse.gef.EditPartViewer) NodeContainer(org.knime.core.node.workflow.NodeContainer) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) NodeID(org.knime.core.node.workflow.NodeID) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) HashSet(java.util.HashSet)

Example 9 with ConnectionContainer

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

the class AutoLayoutCommand method undo.

/**
 * {@inheritDoc}
 */
@Override
public void undo() {
    Map<NodeID, NodeUIInformation> oldPositions = m_layoutMgr.getOldNodeCoordinates();
    Map<ConnectionID, ConnectionUIInformation> oldBendpoints = m_layoutMgr.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 10 with ConnectionContainer

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

the class SandboxedNodeCreator method setupConnectionProgressEventListeners.

/**
 * For each connection in the sandbox add a progress listener that fires an event on the original connection.
 */
private void setupConnectionProgressEventListeners(final NodeContainer origNC, final NodeContainer sandboxNC) {
    WorkflowManager origWFM;
    WorkflowManager sandboxWFM;
    if (origNC instanceof WorkflowManager) {
        origWFM = (WorkflowManager) origNC;
        sandboxWFM = (WorkflowManager) sandboxNC;
    } else if (origNC instanceof SubNodeContainer) {
        origWFM = ((SubNodeContainer) origNC).getWorkflowManager();
        sandboxWFM = ((SubNodeContainer) sandboxNC).getWorkflowManager();
    } else {
        return;
    }
    for (ConnectionContainer cc : origWFM.getConnectionContainers()) {
        NodeID sandboxTargetID = sandboxWFM.getID();
        if (!cc.getDest().equals(origWFM.getID())) {
            // real connection, not a wfm out or through connection
            sandboxTargetID = new NodeID(sandboxTargetID, cc.getDest().getIndex());
        }
        ConnectionContainer sbCC = sandboxWFM.getConnection(new ConnectionID(sandboxTargetID, cc.getDestPort()));
        sbCC.addProgressListener(pe -> cc.progressChanged(pe));
    }
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) ConnectionID(org.knime.core.node.workflow.ConnectionID) ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID)

Aggregations

ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)28 ConnectionUIInformation (org.knime.core.node.workflow.ConnectionUIInformation)14 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)9 NodeID (org.knime.core.node.workflow.NodeID)8 Point (org.eclipse.draw2d.geometry.Point)6 NodeContainer (org.knime.core.node.workflow.NodeContainer)6 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)5 ConnectionID (org.knime.core.node.workflow.ConnectionID)4 Map (java.util.Map)3 Builder (org.knime.core.node.workflow.ConnectionUIInformation.Builder)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)2 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)2 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)2 WorkflowRootEditPart (org.knime.workbench.editor2.editparts.WorkflowRootEditPart)2 List (java.util.List)1 Set (java.util.Set)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 EditPartViewer (org.eclipse.gef.EditPartViewer)1