Search in sources :

Example 11 with MetaNodeTemplateInformation

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);
            }
        }
    }
}
Also used : ExplorerView(org.knime.workbench.explorer.view.ExplorerView) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) 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 12 with MetaNodeTemplateInformation

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

Example 13 with MetaNodeTemplateInformation

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

Example 14 with MetaNodeTemplateInformation

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

Example 15 with MetaNodeTemplateInformation

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