Search in sources :

Example 76 with WorkflowManager

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

the class DeleteCommand method canExecute.

/**
 * {@inheritDoc}
 */
@Override
public boolean canExecute() {
    if (!super.canExecute()) {
        return false;
    }
    boolean foundValid = false;
    WorkflowManager hostWFM = getHostWFM();
    for (NodeID id : m_nodeIDs) {
        foundValid = true;
        if (!hostWFM.canRemoveNode(id)) {
            return false;
        }
    }
    for (ConnectionContainer cc : m_connections) {
        foundValid = true;
        if (!hostWFM.canRemoveConnection(cc)) {
            return false;
        }
    }
    return foundValid || m_annotations.length > 0;
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID)

Example 77 with WorkflowManager

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

the class DeleteCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    WorkflowManager hostWFM = getHostWFM();
    // removed.
    if (m_nodeIDs.length > 0 || m_annotations.length > 0) {
        WorkflowCopyContent.Builder content = WorkflowCopyContent.builder();
        content.setNodeIDs(m_nodeIDs);
        content.setAnnotation(m_annotations);
        m_undoPersitor = hostWFM.copy(true, content.build());
    }
    for (WorkflowAnnotation anno : m_annotations) {
        hostWFM.removeAnnotation(anno);
    }
    for (NodeID id : m_nodeIDs) {
        hostWFM.removeNode(id);
    }
    for (ConnectionContainer cc : m_connections) {
        hostWFM.removeConnection(cc);
    }
}
Also used : WorkflowCopyContent(org.knime.core.node.workflow.WorkflowCopyContent) ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeID(org.knime.core.node.workflow.NodeID) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation)

Example 78 with WorkflowManager

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

the class ExpandMetaNodeCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    try {
        WorkflowManager hostWFM = getHostWFM();
        // close editor of metanode and children
        for (IEditorPart child : m_editor.getSubEditors(m_id)) {
            child.getEditorSite().getPage().closeEditor(child, false);
        }
        WorkflowCopyContent.Builder cnt = WorkflowCopyContent.builder();
        cnt.setNodeIDs(m_id);
        cnt.setIncludeInOutConnections(true);
        m_undoCopyPersistor = hostWFM.copy(true, cnt.build());
        WorkflowCopyContent wcc = hostWFM.expandMetaNode(m_id);
        m_pastedNodes = wcc.getNodeIDs();
        m_pastedAnnotations = wcc.getAnnotations();
        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(m_pastedNodes);
            rootEditPart.setFutureAnnotationSelection(Arrays.asList(m_pastedAnnotations));
        }
    } catch (Exception e) {
        String error = "Expanding Metanode failed: " + e.getMessage();
        LOGGER.error(error, e);
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "Expand failed", error);
    }
}
Also used : WorkflowCopyContent(org.knime.core.node.workflow.WorkflowCopyContent) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) EditPartViewer(org.eclipse.gef.EditPartViewer) IEditorPart(org.eclipse.ui.IEditorPart)

Example 79 with WorkflowManager

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

the class NodeOutputView method selectionChanged.

/**
 * The method updating the content of the monitor.
 *
 * {@inheritDoc}
 */
@Override
public void selectionChanged(final IWorkbenchPart part, final ISelection selection) {
    if (!(selection instanceof IStructuredSelection)) {
        // showErrorAndClear("");
        return;
    }
    IStructuredSelection structSel = (IStructuredSelection) selection;
    if (m_pinned) {
        m_lastSelectionWhilePinned = structSel;
        if (m_branchLocked && m_selectionWhenLocked == null) {
            m_selectionWhenLocked = structSel;
        }
        return;
    }
    if (structSel.equals(m_lastSelection)) {
        // selection hasn't changed - return.
        return;
    }
    m_lastSelection = structSel;
    if (structSel.size() < 1) {
        // Nothing selected
        showErrorAndClear("No node selected");
        return;
    }
    if (structSel.size() > 1) {
        // too many selected items
        showErrorAndClear("Multiple elements selected");
        return;
    }
    // retrieve first (and only!) selection:
    Iterator<?> selIt = structSel.iterator();
    Object sel = selIt.next();
    // 
    if (sel instanceof NodeContainerEditPart) {
        // a NodeContainer was selected, display it's name and status
        NodeContainer nc = Wrapper.unwrapNC(((NodeContainerEditPart) sel).getNodeContainer());
        WorkflowManager wfm = nc.getParent();
        checkWorkflowManagerListener(wfm);
        updateNodeContainerInfo(nc.getID());
    } else if (sel instanceof WorkflowInPortBarEditPart) {
        WorkflowManager wfm = Wrapper.unwrapWFM(((WorkflowInPortBarEditPart) sel).getNodeContainer());
        checkWorkflowManagerListener(wfm);
    } else {
        // unsupported selection
        showErrorAndClear("No info available for this selection");
        return;
    }
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) PortObject(org.knime.core.node.port.PortObject) NodeContainer(org.knime.core.node.workflow.NodeContainer) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WorkflowInPortBarEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart)

Example 80 with WorkflowManager

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

the class ReconfigureMetaNodeCommand method canExecute.

/**
 * {@inheritDoc}
 */
@Override
public boolean canExecute() {
    if (!super.canExecute()) {
        return false;
    }
    if (m_metanodeID == null) {
        return false;
    }
    NodeContainer nc = getHostWFM().getNodeContainer(m_metanodeID);
    boolean isWriteProtected;
    if (nc instanceof WorkflowManager) {
        isWriteProtected = ((WorkflowManager) nc).isWriteProtected();
    } else if (nc instanceof SubNodeContainer) {
        isWriteProtected = ((SubNodeContainer) nc).isWriteProtected();
    } else {
        return false;
    }
    if (!(nc instanceof WorkflowManager) && !(nc instanceof SubNodeContainer)) {
        return false;
    }
    if (isWriteProtected) {
        return false;
    }
    // at least one thing to change should be set
    return (m_inPorts != null || m_outPorts != null || m_name != null);
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeContainer(org.knime.core.node.workflow.NodeContainer) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer)

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