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);
}
}
Aggregations