use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.
the class NodeContainerEditPart method checkMetaNodeTemplateIcon.
private void checkMetaNodeTemplateIcon() {
NodeContainerUI nc = getNodeContainer();
MetaNodeTemplateInformation templInfo = null;
if (Wrapper.wraps(nc, NodeContainerTemplate.class)) {
NodeContainerTemplate t = Wrapper.unwrap(nc, NodeContainerTemplate.class);
templInfo = t.getTemplateInformation();
}
if (templInfo != null) {
NodeContainerFigure fig = (NodeContainerFigure) getFigure();
switch(templInfo.getRole()) {
case Link:
Image i;
switch(templInfo.getUpdateStatus()) {
case HasUpdate:
i = META_NODE_LINK_RED_ICON;
break;
case UpToDate:
i = META_NODE_LINK_GREEN_ICON;
break;
default:
i = META_NODE_LINK_PROBLEM_ICON;
}
fig.setMetaNodeLinkIcon(i);
break;
default:
fig.setMetaNodeLinkIcon(null);
}
}
}
use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.
the class DisconnectSubNodeLinkAction method internalCalculateEnabled.
/**
* @return true, if underlying model instance of
* <code>WorkflowManager</code>, otherwise false
*/
@Override
protected boolean internalCalculateEnabled() {
if (getManager().isWriteProtected()) {
return false;
}
NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
for (NodeContainerEditPart p : nodes) {
Object model = p.getModel();
if (Wrapper.wraps(model, SubNodeContainer.class)) {
SubNodeContainer snc = Wrapper.unwrap((UI) model, SubNodeContainer.class);
MetaNodeTemplateInformation i = snc.getTemplateInformation();
if (Role.Link.equals(i.getRole())) {
return true;
}
}
}
return false;
}
use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.
the class DisconnectSubNodeLinkAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
List<NodeID> idList = new ArrayList<NodeID>();
for (NodeContainerEditPart p : nodeParts) {
Object model = p.getModel();
if (Wrapper.wraps(model, SubNodeContainer.class)) {
SubNodeContainer snc = Wrapper.unwrap((UI) model, SubNodeContainer.class);
MetaNodeTemplateInformation i = snc.getTemplateInformation();
if (Role.Link.equals(i.getRole())) {
idList.add(snc.getID());
}
}
}
NodeID[] ids = idList.toArray(new NodeID[idList.size()]);
DisconnectSubNodeLinkCommand disCmd = new DisconnectSubNodeLinkCommand(getManager(), ids);
execute(disCmd);
}
use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.
the class RevealSubNodeTemplateAction 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 (wraps(model, SubNodeContainer.class)) {
NodeContext.pushContext(Wrapper.unwrapNC(p.getNodeContainer()));
try {
SubNodeContainer snc = unwrap((UI) model, SubNodeContainer.class);
MetaNodeTemplateInformation i = snc.getTemplateInformation();
if (Role.Link.equals(i.getRole())) {
candidateList.add(snc.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 ChangeMetaNodeLinkCommand method setLink.
private boolean setLink(final URI link) {
NodeContainer metaNode = getHostWFM().getNodeContainer(m_metaNodeID);
if (!(metaNode instanceof WorkflowManager)) {
LOGGER.error("Command failed: Specified node is not a metanode");
return false;
}
MetaNodeTemplateInformation templateInfo = ((WorkflowManager) metaNode).getTemplateInformation();
MetaNodeTemplateInformation newInfo;
try {
newInfo = templateInfo.createLinkWithUpdatedSource(m_newLink);
} catch (InvalidSettingsException e1) {
// will not happen.
LOGGER.error("Command failed: Specified node is not a metanode with a link." + e1.getMessage(), e1);
return false;
}
getHostWFM().setTemplateInformation(m_metaNodeID, newInfo);
return true;
}
Aggregations