Search in sources :

Example 71 with WorkflowManager

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

the class CreateMetaNodeCommand method undo.

/**
 * {@inheritDoc}
 */
@Override
public void undo() {
    NodeID[] ids = m_copyContent.getNodeIDs();
    if (LOGGER.isDebugEnabled()) {
        String debug = "Removing node";
        if (ids.length == 1) {
            debug = debug + " " + ids[0];
        } else {
            debug = debug + "s " + Arrays.asList(ids);
        }
        LOGGER.debug(debug);
    }
    WorkflowManager wm = getHostWFM();
    if (canUndo()) {
        for (NodeID id : ids) {
            wm.removeNode(id);
        }
        for (WorkflowAnnotation anno : m_copyContent.getAnnotations()) {
            wm.removeAnnotation(anno);
        }
    } else {
        MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Operation no allowed", "The node(s) " + Arrays.asList(ids) + " can currently not be removed");
    }
}
Also used : WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation)

Example 72 with WorkflowManager

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

the class CreateNewConnectedMetaNodeCommand method createNewNode.

/**
 * {@inheritDoc}
 */
@Override
protected NodeID createNewNode() {
    WorkflowCopyContent.Builder content = WorkflowCopyContent.builder();
    content.setNodeIDs(m_sourceID);
    WorkflowManager hostWFM = getHostWFM();
    NodeID[] copied = hostWFM.copyFromAndPasteHere(m_source, content.build()).getNodeIDs();
    assert copied.length == 1;
    return copied[0];
}
Also used : WorkflowCopyContent(org.knime.core.node.workflow.WorkflowCopyContent) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID)

Example 73 with WorkflowManager

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

the class CreateNodeCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    WorkflowManager hostWFM = getHostWFM();
    // Add node to workflow and get the container
    try {
        NodeID id = hostWFM.createAndAddNode(m_factory);
        m_container = hostWFM.getNodeContainer(id);
        NodeTimer.GLOBAL_TIMER.addNodeCreation(m_container);
    } catch (Throwable t) {
        // if fails notify the user
        LOGGER.debug("Node cannot be created.", t);
        MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_WARNING | SWT.OK);
        mb.setText("Node cannot be created.");
        mb.setMessage("The selected node could not be created " + "due to the following reason:\n" + t.getMessage());
        mb.open();
        return;
    }
    // create extra info and set it
    NodeUIInformation info = NodeUIInformation.builder().setNodeLocation(m_location.x, m_location.y, -1, -1).setHasAbsoluteCoordinates(false).setSnapToGrid(m_snapToGrid).setIsDropLocation(true).build();
    m_container.setUIInformation(info);
}
Also used : NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 74 with WorkflowManager

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

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

the class ExpandSubNodeCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    try {
        WorkflowManager hostWFM = getHostWFM();
        // close editor of subnode and children
        NodeID wfmID = ((SubNodeContainer) hostWFM.getNodeContainer(m_id)).getWorkflowManager().getID();
        for (IEditorPart child : m_editor.getSubEditors(m_id)) {
            child.getEditorSite().getPage().closeEditor(child, false);
        }
        m_expandResult = hostWFM.expandSubWorkflow(m_id);
        WorkflowAnnotation[] annotations = m_expandResult.getExpandedCopyContent().getAnnotations();
        NodeID[] nodeIDs = m_expandResult.getExpandedCopyContent().getNodeIDs();
        EditPartViewer partViewer = m_editor.getViewer();
        partViewer.deselectAll();
        // select the new ones....
        if (partViewer.getRootEditPart().getContents() != null && partViewer.getRootEditPart().getContents() instanceof WorkflowRootEditPart) {
            WorkflowRootEditPart rootEditPart = (WorkflowRootEditPart) partViewer.getRootEditPart().getContents();
            rootEditPart.setFutureSelection(nodeIDs);
            rootEditPart.setFutureAnnotationSelection(Arrays.asList(annotations));
        }
    } catch (Exception e) {
        String error = "Expanding Wrapped Metanode failed: " + e.getMessage();
        LOGGER.error(error, e);
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "Expand failed", error);
    }
}
Also used : WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) EditPartViewer(org.eclipse.gef.EditPartViewer) IEditorPart(org.eclipse.ui.IEditorPart) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation)

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