Search in sources :

Example 1 with WorkflowCopyContent

use of org.knime.core.node.workflow.WorkflowCopyContent 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)

Aggregations

EditPartViewer (org.eclipse.gef.EditPartViewer)1 IEditorPart (org.eclipse.ui.IEditorPart)1 WorkflowCopyContent (org.knime.core.node.workflow.WorkflowCopyContent)1 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)1 WorkflowRootEditPart (org.knime.workbench.editor2.editparts.WorkflowRootEditPart)1