Search in sources :

Example 6 with NodeContainerTemplate

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

the class UpdateMetaNodeLinkCommand method undo.

/**
 * {@inheritDoc}
 */
@Override
public void undo() {
    LOGGER.debug("Undo: Reverting metanode links (" + m_newIDs.size() + " metanode(s))");
    WorkflowManager hostWFM = getHostWFM();
    for (int i = 0; i < m_newIDs.size(); i++) {
        NodeID id = m_newIDs.get(i);
        WorkflowPersistor p = m_undoPersistors.get(i);
        NodeContainerTemplate nodeToBeDeleted = (NodeContainerTemplate) hostWFM.findNodeContainer(id);
        WorkflowManager parent = nodeToBeDeleted.getParent();
        parent.removeNode(nodeToBeDeleted.getID());
        parent.paste(p);
    }
}
Also used : NodeContainerTemplate(org.knime.core.node.workflow.NodeContainerTemplate) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) WorkflowPersistor(org.knime.core.node.workflow.WorkflowPersistor)

Example 7 with NodeContainerTemplate

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

the class UpdateMetaNodeLinkCommand method canExecute.

/**
 * We can execute, if all components were 'non-null' in the constructor.
 * {@inheritDoc}
 */
@Override
public boolean canExecute() {
    if (!super.canExecute()) {
        return false;
    }
    if (m_ids == null) {
        return false;
    }
    boolean containsUpdateableMN = false;
    WorkflowManager hostWFM = getHostWFM();
    for (NodeID id : m_ids) {
        NodeContainer nc = hostWFM.findNodeContainer(id);
        if (nc instanceof NodeContainerTemplate) {
            NodeContainerTemplate tnc = (NodeContainerTemplate) nc;
            final WorkflowManager parent = tnc.getParent();
            if (parent.hasUpdateableMetaNodeLink(id)) {
                containsUpdateableMN = true;
            }
            if (!parent.canUpdateMetaNodeLink(id)) {
                return false;
            }
        }
    }
    return containsUpdateableMN;
}
Also used : NodeContainerTemplate(org.knime.core.node.workflow.NodeContainerTemplate) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) NodeContainer(org.knime.core.node.workflow.NodeContainer)

Aggregations

NodeContainerTemplate (org.knime.core.node.workflow.NodeContainerTemplate)7 NodeID (org.knime.core.node.workflow.NodeID)6 ArrayList (java.util.ArrayList)2 IStatus (org.eclipse.core.runtime.IStatus)2 NodeContainer (org.knime.core.node.workflow.NodeContainer)2 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)2 WorkflowPersistor (org.knime.core.node.workflow.WorkflowPersistor)2 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 Status (org.eclipse.core.runtime.Status)1 Image (org.eclipse.swt.graphics.Image)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1 IWorkbench (org.eclipse.ui.IWorkbench)1 IProgressService (org.eclipse.ui.progress.IProgressService)1 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)1 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)1 MetaNodeTemplateInformation (org.knime.core.node.workflow.MetaNodeTemplateInformation)1 NodeContainerTemplateLinkUpdateResult (org.knime.core.node.workflow.WorkflowPersistor.NodeContainerTemplateLinkUpdateResult)1