use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.
the class RevealMetaNodeTemplateAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodes) {
List<NodeID> candidateList = new ArrayList<NodeID>();
List<AbstractExplorerFileStore> templates = new ArrayList<AbstractExplorerFileStore>();
for (NodeContainerEditPart p : nodes) {
Object model = p.getModel();
if (model instanceof WorkflowManagerUI) {
NodeContext.pushContext(Wrapper.unwrapNC(p.getNodeContainer()));
try {
WorkflowManager wm = Wrapper.unwrapWFM((UI) model);
MetaNodeTemplateInformation i = wm.getTemplateInformation();
if (Role.Link.equals(i.getRole())) {
candidateList.add(wm.getID());
AbstractExplorerFileStore template = ExplorerFileSystem.INSTANCE.getStore(i.getSourceURI());
if (template != null) {
templates.add(template);
}
}
} finally {
NodeContext.removeLastContext();
}
}
}
List<Object> treeObjects = ContentDelegator.getTreeObjectList(templates);
if (treeObjects != null && treeObjects.size() > 0) {
IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
for (IViewReference view : views) {
if (ExplorerView.ID.equals(view.getId())) {
ExplorerView explorerView = (ExplorerView) view.getView(true);
explorerView.getViewer().setSelection(new StructuredSelection(treeObjects), true);
}
}
}
}
use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.
the class ChangeSubNodeLinkCommand method setLink.
private boolean setLink(final URI link) {
NodeContainer subNode = getHostWFM().getNodeContainer(m_subNodeID);
if (!(subNode instanceof SubNodeContainer)) {
LOGGER.error("Command failed: Specified node is not a Wrapped Metanode");
return false;
}
MetaNodeTemplateInformation templateInfo = ((SubNodeContainer) subNode).getTemplateInformation();
MetaNodeTemplateInformation newInfo;
try {
newInfo = templateInfo.createLinkWithUpdatedSource(m_newLink);
} catch (InvalidSettingsException e1) {
// will not happen.
LOGGER.error("Command failed: Specified node is not a Wrapped Metanode with a link." + e1.getMessage(), e1);
return false;
}
getHostWFM().setTemplateInformation(m_subNodeID, newInfo);
return true;
}
use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.
the class DisconnectMetaNodeLinkCommand 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;
}
for (NodeID id : m_ids) {
NodeContainer nc = getHostWFM().getNodeContainer(id);
if (nc instanceof WorkflowManager) {
WorkflowManager wm = (WorkflowManager) nc;
MetaNodeTemplateInformation lI = wm.getTemplateInformation();
if (Role.Link.equals(lI.getRole())) {
return true;
}
}
}
return false;
}
use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.
the class DisconnectMetaNodeLinkCommand method undo.
/**
* {@inheritDoc}
*/
@Override
public void undo() {
LOGGER.debug("Undo: Reconnecting metanode links (" + m_changedIDs.size() + " metanode(s))");
for (int i = 0; i < m_changedIDs.size(); i++) {
NodeID id = m_changedIDs.get(i);
MetaNodeTemplateInformation old = m_oldTemplInfos.get(i);
getHostWFM().setTemplateInformation(id, old);
}
m_changedIDs = null;
m_oldTemplInfos = null;
}
use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.
the class DisconnectSubNodeLinkCommand method undo.
/**
* {@inheritDoc}
*/
@Override
public void undo() {
LOGGER.debug("Undo: Reconnecting Wrapped Metanode links (" + m_changedIDs.size() + " Wrapped Metanode(s))");
for (int i = 0; i < m_changedIDs.size(); i++) {
NodeID id = m_changedIDs.get(i);
MetaNodeTemplateInformation old = m_oldTemplInfos.get(i);
getHostWFM().setTemplateInformation(id, old);
}
m_changedIDs = null;
m_oldTemplInfos = null;
}
Aggregations