Search in sources :

Example 61 with WorkflowManager

use of org.knime.core.node.workflow.WorkflowManager 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 62 with WorkflowManager

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

the class PauseLoopExecutionAction method runOnNodes.

/**
 * Pause Execution on all selected nodes.
 *
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    LOGGER.debug("Creating 'Pause Execution' job for " + nodeParts.length + " node(s)...");
    WorkflowManager manager = getManager();
    for (NodeContainerEditPart p : nodeParts) {
        manager.pauseLoopExecution(Wrapper.unwrapNC(p.getNodeContainer()));
    }
    try {
        // Give focus to the editor again. Otherwise the actions (selection)
        // is not updated correctly.
        getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
    } catch (Exception e) {
    // ignore
    }
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager)

Example 63 with WorkflowManager

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

the class StepLoopAction method runOnNodes.

/**
 * Perform one step through the entire loop and pause again.
 *
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    LOGGER.debug("Creating 'Step Loop Execution' job for " + nodeParts.length + " node(s)...");
    WorkflowManager manager = getManager();
    for (NodeContainerEditPart p : nodeParts) {
        NodeContainerUI nc = p.getNodeContainer();
        if (Wrapper.wraps(nc, NativeNodeContainer.class)) {
            NativeNodeContainer nnc = Wrapper.unwrap(nc, NativeNodeContainer.class);
            if (nnc.isModelCompatibleTo(LoopEndNode.class) && nnc.getLoopStatus().equals(LoopStatus.PAUSED)) {
                manager.resumeLoopExecution(nnc, /*oneStep=*/
                true);
            } else if (manager.canExecuteNodeDirectly(nc.getID())) {
                manager.executeUpToHere(nc.getID());
                manager.pauseLoopExecution(nnc);
            }
        }
    }
    try {
        // Give focus to the editor again. Otherwise the actions (selection)
        // is not updated correctly.
        getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
    } catch (Exception e) {
    // ignore
    }
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) LoopEndNode(org.knime.core.node.workflow.LoopEndNode)

Example 64 with WorkflowManager

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

the class SubnodeLayoutAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    WorkflowManager manager = getManager();
    SubNodeContainer subnode = (SubNodeContainer) manager.getDirectNCParent();
    SubnodeLayoutWizard wizard = new SubnodeLayoutWizard(subnode);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
    dlg.create();
    dlg.open();
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) SubnodeLayoutWizard(org.knime.workbench.editor2.subnode.SubnodeLayoutWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 65 with WorkflowManager

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

the class AbstractCreateNewConnectedNodeCommand method autoConnectNewNode.

private void autoConnectNewNode() {
    if (m_newNode == null) {
        return;
    }
    if (m_connectTo == null) {
        return;
    }
    WorkflowManager hostWFM = getHostWFM();
    NodeContainer sourceNode = hostWFM.getNodeContainer(m_connectTo);
    NodeContainer nc = hostWFM.getNodeContainer(m_newNode);
    Map<Integer, Integer> matchingPorts = getMatchingPorts(sourceNode, nc);
    if (matchingPorts.size() == 0) {
        LOGGER.info("Can't auto-connect new node (" + m_newNode + "): " + "no matching port type found at node " + sourceNode.getNameWithID());
        return;
    }
    for (Map.Entry<Integer, Integer> entry : matchingPorts.entrySet()) {
        Integer leftPort = entry.getKey();
        Integer rightPort = entry.getValue();
        LOGGER.info("Autoconnect: Connecting new node " + m_newNode + " port " + rightPort + " with existing node " + sourceNode + " port " + leftPort);
        try {
            hostWFM.addConnection(m_connectTo, leftPort, m_newNode, rightPort).getID();
            NodeTimer.GLOBAL_TIMER.addConnectionCreation(sourceNode, nc);
        } catch (Exception e) {
            String from = sourceNode.getNameWithID();
            String to = nc.getNameWithID();
            String msg = "Unable to add connection from " + from + " port " + leftPort + " to " + to + "port " + rightPort + ": " + e.getMessage();
            LOGGER.error(msg);
        }
    }
}
Also used : WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeContainer(org.knime.core.node.workflow.NodeContainer) TreeMap(java.util.TreeMap) Map(java.util.Map)

Aggregations

WorkflowManager (org.knime.core.node.workflow.WorkflowManager)88 NodeID (org.knime.core.node.workflow.NodeID)31 NodeContainer (org.knime.core.node.workflow.NodeContainer)20 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)15 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)15 File (java.io.File)12 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)12 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)10 ArrayList (java.util.ArrayList)9 MessageBox (org.eclipse.swt.widgets.MessageBox)9 SingleNodeContainer (org.knime.core.node.workflow.SingleNodeContainer)9 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)9 IOException (java.io.IOException)8 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)8 Map (java.util.Map)7 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)7 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)7 WorkflowContext (org.knime.core.node.workflow.WorkflowContext)7 WorkflowCopyContent (org.knime.core.node.workflow.WorkflowCopyContent)7 WorkflowRootEditPart (org.knime.workbench.editor2.editparts.WorkflowRootEditPart)6