Search in sources :

Example 6 with WorkflowManager

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

the class ExpandMetaNodeAction method runOnNodes.

/**
 * Expand metanode!
 *
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    if (nodeParts.length < 1) {
        return;
    }
    LOGGER.debug("Creating 'Expand MetaNode' job for " + nodeParts.length + " node(s)...");
    try {
        WorkflowManager manager = getManager();
        WorkflowManagerUI metaNode = (WorkflowManagerUI) nodeParts[0].getNodeContainer();
        if (!Wrapper.unwrapWFM(metaNode).unlock(new GUIWorkflowCipherPrompt())) {
            return;
        }
        // reset the metanode
        if (manager.canResetNode(metaNode.getID())) {
            // yes: ask if we can reset, otherwise bail
            MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.OK | SWT.CANCEL);
            mb.setMessage("Executed Nodes inside Metanode will be reset" + " - are you sure?");
            mb.setText("Reset Executed Nodes");
            int dialogreturn = mb.open();
            if (dialogreturn == SWT.CANCEL) {
                return;
            }
            // perform reset
            if (manager.canResetNode(metaNode.getID())) {
                manager.resetAndConfigureNode(metaNode.getID());
            }
        }
        String res = manager.canExpandMetaNode(metaNode.getID());
        if (res != null) {
            throw new IllegalArgumentException(res);
        }
        ExpandMetaNodeCommand emnc = new ExpandMetaNodeCommand(manager, metaNode.getID(), getEditor());
        execute(emnc);
    } catch (IllegalArgumentException e) {
        MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR);
        mb.setMessage("Sorry, expanding Metanode failed: " + e.getMessage());
        mb.setText("Expand failed");
        mb.open();
    }
    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 : WorkflowManager(org.knime.core.node.workflow.WorkflowManager) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) GUIWorkflowCipherPrompt(org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt) MessageBox(org.eclipse.swt.widgets.MessageBox) ExpandMetaNodeCommand(org.knime.workbench.editor2.commands.ExpandMetaNodeCommand)

Example 7 with WorkflowManager

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

the class MetaNodeReconfigureAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    if (nodeParts.length < 1) {
        return;
    }
    NodeContainerEditPart ep = nodeParts[0];
    WorkflowManager metanode = Wrapper.unwrapWFM(ep.getNodeContainer());
    if (!metanode.unlock(new GUIWorkflowCipherPrompt())) {
        return;
    }
    ReconfigureMetaNodeWizard wizard = new ReconfigureMetaNodeWizard(ep.getViewer(), metanode);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
    dlg.create();
    dlg.open();
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) ReconfigureMetaNodeWizard(org.knime.workbench.editor2.meta.ReconfigureMetaNodeWizard) GUIWorkflowCipherPrompt(org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 8 with WorkflowManager

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

the class ConnectionBendpointEditPolicy method getDeleteBendpointCommand.

/**
 * {@inheritDoc}
 */
protected Command getDeleteBendpointCommand(final BendpointRequest req) {
    // get the index of the bendpoint to delete
    int index = req.getIndex();
    ConnectionContainerEditPart editPart = (ConnectionContainerEditPart) getHost();
    WorkflowManager wfm = getWorkflowManager();
    return new NewBendpointDeleteCommand(editPart, wfm, index);
}
Also used : ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NewBendpointDeleteCommand(org.knime.workbench.editor2.commands.NewBendpointDeleteCommand) AbsoluteBendpoint(org.eclipse.draw2d.AbsoluteBendpoint) Point(org.eclipse.draw2d.geometry.Point) Bendpoint(org.eclipse.draw2d.Bendpoint)

Example 9 with WorkflowManager

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

the class SubnodeLayoutWizard method addPages.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void addPages() {
    setWindowTitle("Node Usage and Layout");
    setDefaultPageImageDescriptor(ImageRepository.getImageDescriptor(KNIMEEditorPlugin.PLUGIN_ID, "icons/layout_55.png"));
    WorkflowManager wfManager = m_subNodeContainer.getWorkflowManager();
    // Map<NodeID, SubNodeContainer> nestedSubnodes = wfManager.findNodes(SubNodeContainer.class, false);
    Map<NodeID, WizardNode> viewNodes = wfManager.findNodes(WizardNode.class, false);
    LinkedHashMap<NodeIDSuffix, WizardNode> resultMap = new LinkedHashMap<>();
    for (Map.Entry<NodeID, WizardNode> entry : viewNodes.entrySet()) {
        NodeID.NodeIDSuffix idSuffix = NodeID.NodeIDSuffix.create(wfManager.getID(), entry.getKey());
        resultMap.put(idSuffix, entry.getValue());
    }
    List<NodeID> nodeIDs = new ArrayList<NodeID>();
    nodeIDs.addAll(viewNodes.keySet());
    /*for (NodeID subnodeID : nestedSubnodes.keySet()) {
            WorkflowManager nestedWFManager = nestedSubnodes.get(subnodeID).getWorkflowManager();
            if (!nestedWFManager.findNodes(WizardNode.class, true).isEmpty()) {
                nodeIDs.add(subnodeID);
            }
        }*/
    Collections.sort(nodeIDs);
    m_page = new SubnodeLayoutJSONEditorPage("Change the layout configuration");
    m_page.setNodes(wfManager, m_subNodeContainer, resultMap);
    addPage(m_page);
}
Also used : WorkflowManager(org.knime.core.node.workflow.WorkflowManager) ArrayList(java.util.ArrayList) WizardNode(org.knime.core.node.wizard.WizardNode) NodeIDSuffix(org.knime.core.node.workflow.NodeID.NodeIDSuffix) LinkedHashMap(java.util.LinkedHashMap) NodeIDSuffix(org.knime.core.node.workflow.NodeID.NodeIDSuffix) NodeID(org.knime.core.node.workflow.NodeID) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 10 with WorkflowManager

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

the class RepositoryFactory method loadMetaNode.

private static WorkflowManagerUI loadMetaNode(final String pluginId, final String workflowDir) {
    LOGGER.debug("found pre-installed template " + workflowDir);
    Bundle bundle = Platform.getBundle(pluginId);
    URL url = FileLocator.find(bundle, new Path(workflowDir), null);
    if (url != null) {
        try {
            File f = new File(FileLocator.toFileURL(url).getFile());
            LOGGER.debug("meta node template name: " + f.getName());
            WorkflowLoadHelper loadHelper = new WorkflowLoadHelper(true) {

                /**
                 * {@inheritDoc}
                 */
                @Override
                public String getDotKNIMEFileName() {
                    return WorkflowPersistor.WORKFLOW_FILE;
                }
            };
            // don't lock workflow dir
            FileWorkflowPersistor persistor = WorkflowManager.createLoadPersistor(f, loadHelper);
            WorkflowManager metaNode = WorkflowManager.META_NODE_ROOT.load(persistor, new ExecutionMonitor(), false).getWorkflowManager();
            return WorkflowManagerWrapper.wrap(metaNode);
        } catch (CanceledExecutionException cee) {
            LOGGER.error("Unexpected canceled execution exception", cee);
        } catch (Exception e) {
            LOGGER.error("Failed to load meta workflow repository", e);
        }
    }
    return null;
}
Also used : Path(org.eclipse.core.runtime.Path) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) Bundle(org.osgi.framework.Bundle) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) WorkflowLoadHelper(org.knime.core.node.workflow.WorkflowLoadHelper) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) File(java.io.File) URL(java.net.URL) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) FileWorkflowPersistor(org.knime.core.node.workflow.FileWorkflowPersistor)

Aggregations

WorkflowManager (org.knime.core.node.workflow.WorkflowManager)99 NodeID (org.knime.core.node.workflow.NodeID)38 NodeContainer (org.knime.core.node.workflow.NodeContainer)22 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)19 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)15 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)15 File (java.io.File)14 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)14 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 SingleNodeContainer (org.knime.core.node.workflow.SingleNodeContainer)10 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)10 MessageBox (org.eclipse.swt.widgets.MessageBox)9 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)9 List (java.util.List)8 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)8 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)8 WorkflowContext (org.knime.core.node.workflow.WorkflowContext)8 WorkflowCopyContent (org.knime.core.node.workflow.WorkflowCopyContent)8