Search in sources :

Example 21 with ConnectionContainer

use of org.knime.core.node.workflow.ConnectionContainer 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 22 with ConnectionContainer

use of org.knime.core.node.workflow.ConnectionContainer 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 23 with ConnectionContainer

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

the class NodeOutputView method workflowChanged.

/**
 * {@inheritDoc}
 */
@Override
public void workflowChanged(final WorkflowEvent event) {
    if (event.getType() == Type.NODE_REMOVED) {
        // unregister from the node removed
        Object oldValue = event.getOldValue();
        if (oldValue instanceof NodeContainer) {
            NodeContainer oldNode = (NodeContainer) oldValue;
            if (oldNode.getID().equals(m_workflow.getID())) {
                // our flow got removed (i.e. the editor or the workbench is closed)
                disconnectFromWFM();
                m_lastNode = null;
                m_workflow = null;
                m_parentWfm = null;
                updateNCinfoInSWT(null);
                return;
            }
            if (oldNode.getID().equals(m_lastNode)) {
                oldNode.removeNodeStateChangeListener(this);
                // pinned node is gone: unpin
                m_pinButton.setChecked(false);
            }
        }
        return;
    }
    if (!m_pinned || (m_pinned && !m_branchLocked)) {
        return;
    }
    Type type = event.getType();
    if (type == Type.CONNECTION_ADDED) {
        ConnectionContainer cc = (ConnectionContainer) event.getNewValue();
        if (cc.getSource().equals(m_lastNode)) {
            if (m_workflow.getOutgoingConnectionsFor(m_lastNode).size() == 1) {
                if (m_workflow.containsNodeContainer(cc.getDest())) {
                    // could be an outgoing metanode connection
                    // first connection: follow this new branch extension
                    updateNCinfoInSWT(cc.getDest());
                }
            }
        }
    } else if (type == Type.CONNECTION_REMOVED) {
        ConnectionContainer cc = (ConnectionContainer) event.getOldValue();
        if (cc.getDest().equals(m_lastNode)) {
            if (m_workflow.containsNodeContainer(m_lastNode)) {
                if (m_workflow.getOutgoingConnectionsFor(m_lastNode).size() == 0) {
                    updateNCinfoInSWT(cc.getSource());
                }
            } else {
                updateNCinfoInSWT(cc.getSource());
            }
        }
    } else {
        return;
    }
}
Also used : Type(org.knime.core.node.workflow.WorkflowEvent.Type) ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) PortObject(org.knime.core.node.port.PortObject) NodeContainer(org.knime.core.node.workflow.NodeContainer) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer)

Example 24 with ConnectionContainer

use of org.knime.core.node.workflow.ConnectionContainer 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 25 with ConnectionContainer

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

the class ReplaceHelper method replaceNode.

/**
 * Checks execution status of downstream nodes and pops up reset warning if enabled.
 *
 * @return if new node can be replaced
 */
public boolean replaceNode() {
    boolean hasExecutedSuccessor = false;
    for (ConnectionContainer connectionContainer : m_outgoingConnections) {
        hasExecutedSuccessor = hasExecutedSuccessor || m_wfm.findNodeContainer(connectionContainer.getDest()).getNodeContainerState().isExecuted() || !m_wfm.canRemoveNode(m_oldNode.getID());
    }
    if (hasExecutedSuccessor) {
        IPreferenceStore store = KNIMEUIPlugin.getDefault().getPreferenceStore();
        if (!store.contains(PreferenceConstants.P_CONFIRM_RESET) || store.getBoolean(PreferenceConstants.P_CONFIRM_RESET)) {
            MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(Display.getDefault().getActiveShell(), "Confirm reset...", "Do you really want to reset all downstream node(s) ?", "Do not ask again", false, null, null);
            if (dialog.getReturnCode() != IDialogConstants.OK_ID) {
                return false;
            }
            if (dialog.getToggleState()) {
                store.setValue(PreferenceConstants.P_CONFIRM_RESET, false);
                KNIMEUIPlugin.getDefault().savePluginPreferences();
            }
        }
    }
    return true;
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

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