Search in sources :

Example 6 with MetaNodeTemplateInformation

use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.

the class DisconnectMetaNodeLinkCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    m_changedIDs = new ArrayList<NodeID>();
    m_oldTemplInfos = new ArrayList<MetaNodeTemplateInformation>();
    WorkflowManager hostWFM = getHostWFM();
    for (NodeID id : m_ids) {
        NodeContainer nc = hostWFM.getNodeContainer(id);
        if (nc instanceof WorkflowManager) {
            WorkflowManager wm = (WorkflowManager) nc;
            MetaNodeTemplateInformation lI = wm.getTemplateInformation();
            if (Role.Link.equals(lI.getRole())) {
                MetaNodeTemplateInformation old = hostWFM.setTemplateInformation(id, MetaNodeTemplateInformation.NONE);
                RECENTLY_USED_URIS.put(wm.getID(), old.getSourceURI());
                m_changedIDs.add(id);
                m_oldTemplInfos.add(old);
            }
        }
    }
}
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 7 with MetaNodeTemplateInformation

use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.

the class DisconnectSubNodeLinkCommand 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 SubNodeContainer) {
            SubNodeContainer snc = (SubNodeContainer) nc;
            MetaNodeTemplateInformation lI = snc.getTemplateInformation();
            if (Role.Link.equals(lI.getRole())) {
                return true;
            }
        }
    }
    return false;
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeID(org.knime.core.node.workflow.NodeID) NodeContainer(org.knime.core.node.workflow.NodeContainer) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

Example 8 with MetaNodeTemplateInformation

use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.

the class DisconnectSubNodeLinkCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    m_changedIDs = new ArrayList<NodeID>();
    m_oldTemplInfos = new ArrayList<MetaNodeTemplateInformation>();
    WorkflowManager hostWFM = getHostWFM();
    for (NodeID id : m_ids) {
        NodeContainer nc = hostWFM.getNodeContainer(id);
        if (nc instanceof SubNodeContainer) {
            SubNodeContainer snc = (SubNodeContainer) nc;
            MetaNodeTemplateInformation lI = snc.getTemplateInformation();
            if (Role.Link.equals(lI.getRole())) {
                MetaNodeTemplateInformation old = hostWFM.setTemplateInformation(id, MetaNodeTemplateInformation.NONE);
                RECENTLY_USED_URIS.put(snc.getID(), old.getSourceURI());
                m_changedIDs.add(id);
                m_oldTemplInfos.add(old);
            }
        }
    }
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) NodeContainer(org.knime.core.node.workflow.NodeContainer) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

Example 9 with MetaNodeTemplateInformation

use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.

the class DisconnectMetaNodeLinkAction 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 (model instanceof WorkflowManagerUI) {
            WorkflowManagerUI wm = (WorkflowManagerUI) model;
            MetaNodeTemplateInformation i = unwrapWFM(wm).getTemplateInformation();
            if (Role.Link.equals(i.getRole())) {
                return true;
            }
        }
    }
    return false;
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

Example 10 with MetaNodeTemplateInformation

use of org.knime.core.node.workflow.MetaNodeTemplateInformation in project knime-core by knime.

the class DisconnectMetaNodeLinkAction 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 (model instanceof WorkflowManagerUI) {
            WorkflowManagerUI wm = (WorkflowManagerUI) model;
            MetaNodeTemplateInformation i = unwrapWFM(wm).getTemplateInformation();
            if (Role.Link.equals(i.getRole())) {
                idList.add(wm.getID());
            }
        }
    }
    NodeID[] ids = idList.toArray(new NodeID[idList.size()]);
    DisconnectMetaNodeLinkCommand disCmd = new DisconnectMetaNodeLinkCommand(getManager(), ids);
    execute(disCmd);
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) NodeID(org.knime.core.node.workflow.NodeID) ArrayList(java.util.ArrayList) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) DisconnectMetaNodeLinkCommand(org.knime.workbench.editor2.commands.DisconnectMetaNodeLinkCommand) 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