Search in sources :

Example 1 with MetaNodeTemplateInformation

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);
        }
    }
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) NodeContainerTemplate(org.knime.core.node.workflow.NodeContainerTemplate) Image(org.eclipse.swt.graphics.Image) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation) NodeContainerFigure(org.knime.workbench.editor2.figures.NodeContainerFigure)

Example 2 with MetaNodeTemplateInformation

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;
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

Example 3 with MetaNodeTemplateInformation

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);
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) NodeID(org.knime.core.node.workflow.NodeID) ArrayList(java.util.ArrayList) DisconnectSubNodeLinkCommand(org.knime.workbench.editor2.commands.DisconnectSubNodeLinkCommand) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

Example 4 with MetaNodeTemplateInformation

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);
            }
        }
    }
}
Also used : ExplorerView(org.knime.workbench.explorer.view.ExplorerView) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AbstractExplorerFileStore(org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore) IViewReference(org.eclipse.ui.IViewReference) NodeID(org.knime.core.node.workflow.NodeID) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

Example 5 with MetaNodeTemplateInformation

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;
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeContainer(org.knime.core.node.workflow.NodeContainer) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

Aggregations

MetaNodeTemplateInformation (org.knime.core.node.workflow.MetaNodeTemplateInformation)15 NodeID (org.knime.core.node.workflow.NodeID)10 NodeContainer (org.knime.core.node.workflow.NodeContainer)6 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)6 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)6 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)5 ArrayList (java.util.ArrayList)4 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 IViewReference (org.eclipse.ui.IViewReference)2 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)2 AbstractExplorerFileStore (org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore)2 ExplorerView (org.knime.workbench.explorer.view.ExplorerView)2 Image (org.eclipse.swt.graphics.Image)1 NodeContainerTemplate (org.knime.core.node.workflow.NodeContainerTemplate)1 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)1 SubNodeContainerUI (org.knime.core.ui.node.workflow.SubNodeContainerUI)1 DisconnectMetaNodeLinkCommand (org.knime.workbench.editor2.commands.DisconnectMetaNodeLinkCommand)1 DisconnectSubNodeLinkCommand (org.knime.workbench.editor2.commands.DisconnectSubNodeLinkCommand)1 NodeContainerFigure (org.knime.workbench.editor2.figures.NodeContainerFigure)1