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);
}
}
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;
}
Aggregations