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