use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class CancelAction method internalCalculateEnabled.
/**
* @return true if at least one selected node is executing or queued
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*/
@Override
protected boolean internalCalculateEnabled() {
NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
// enable if we have at least one executing or queued node in our
// selection
WorkflowManager wm = getEditor().getWorkflowManager().get();
for (int i = 0; i < parts.length; i++) {
// bugfix 1478
NodeContainerUI nc = parts[i].getNodeContainer();
if (wm.canCancelNode(nc.getID())) {
return true;
}
}
return false;
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class ConvertSubNodeToMetaNodeAction method runOnNodes.
/**
* Expand metanode!
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
if (nodeParts.length < 1) {
return;
}
try {
WorkflowManager manager = getManager();
SubNodeContainer subNode = Wrapper.unwrap(nodeParts[0].getNodeContainer(), SubNodeContainer.class);
if (!subNode.getWorkflowManager().unlock(new GUIWorkflowCipherPrompt())) {
return;
}
// before we do anything, let's see if the convert will reset the metanode
if (manager.canResetNode(subNode.getID())) {
// yes: ask if we can reset, otherwise bail
MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.OK | SWT.CANCEL);
mb.setMessage("Executed Nodes inside WrappedNode will be reset - are you sure?");
mb.setText("Reset Executed Nodes");
int dialogreturn = mb.open();
if (dialogreturn == SWT.CANCEL) {
return;
}
// perform reset
if (manager.canResetNode(subNode.getID())) {
manager.resetAndConfigureNode(subNode.getID());
}
}
ConvertSubNodeToMetaNodeCommand cmnc = new ConvertSubNodeToMetaNodeCommand(manager, subNode.getID());
execute(cmnc);
} catch (IllegalArgumentException e) {
MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR);
mb.setMessage("Sorry, Unwrapping WrappedNode failed: " + e.getMessage());
mb.setText("Convert failed");
mb.open();
}
try {
// Give focus to the editor again. Otherwise the actions (selection)
// is not updated correctly.
getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
} catch (Exception e) {
// ignore
}
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class MetaNodeCreationFactory method getNewObject.
/**
* {@inheritDoc}
*/
@Override
public Object getNewObject() {
NodeID id = m_template.getManager().getID();
WorkflowManager sourceManager = WorkflowManager.META_NODE_ROOT;
WorkflowCopyContent.Builder content = WorkflowCopyContent.builder();
content.setNodeIDs(id);
return sourceManager.copy(content.build());
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class CancelAllAction method runOnNodes.
/**
* This cancels all running jobs.
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
mb.setText("Confirm cancel all...");
mb.setMessage("Do you really want to cancel all running node(s) ?");
if (mb.open() != SWT.YES) {
return;
}
LOGGER.debug("(Cancel all) cancel all running jobs.");
WorkflowManager manager = getManager();
manager.getParent().cancelExecution(manager);
try {
// Give focus to the editor again. Otherwise the actions (selection)
// is not updated correctly.
getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
} catch (Exception e) {
// ignore
}
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class ChangeSubNodeLinkAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
if (nodeParts.length < 1) {
return;
}
SubNodeContainer subNode = Wrapper.unwrap(nodeParts[0].getNodeContainer(), SubNodeContainer.class);
if (Role.Link.equals(subNode.getTemplateInformation().getRole())) {
WorkflowManager wfm = subNode.getParent();
URI targetURI = subNode.getTemplateInformation().getSourceURI();
LinkType linkType = LinkType.None;
try {
if (ResolverUtil.isMountpointRelativeURL(targetURI)) {
linkType = LinkType.MountpointRelative;
} else if (ResolverUtil.isWorkflowRelativeURL(targetURI)) {
linkType = LinkType.WorkflowRelative;
} else {
linkType = LinkType.Absolute;
}
} catch (IOException e) {
LOGGER.error("Unable to resolve current link to template " + targetURI + ": " + e.getMessage(), e);
return;
}
String msg = "This is a linked (read-only) Wrapped Metanode. Only the link type can be changed.\n";
msg += "Please select the new type of the link to the Wrapped Metanode template.\n";
msg += "(current type: " + linkType + ", current link: " + targetURI + ")\n";
msg += "The origin of the template will not be changed - just the way it is referenced.";
LinkPrompt dlg = new LinkPrompt(getEditor().getSite().getShell(), msg, linkType);
dlg.open();
if (dlg.getReturnCode() == Window.CANCEL) {
return;
}
LinkType newLinkType = dlg.getLinkType();
if (linkType.equals(newLinkType)) {
LOGGER.info("Link type not changes as selected type equals existing type " + targetURI);
return;
}
// as the workflow is local and the template in the same mountID, it should resolve to a file
URI newURI = null;
NodeContext.pushContext(subNode);
try {
File targetFile = ResolverUtil.resolveURItoLocalFile(targetURI);
LocalExplorerFileStore targetfs = ExplorerFileSystem.INSTANCE.fromLocalFile(targetFile);
newURI = AbstractContentProvider.createMetanodeLinkUri(subNode, targetfs, newLinkType);
} catch (IOException e) {
LOGGER.error("Unable to resolve Wrapped Metanode template URI " + targetURI + ": " + e.getMessage(), e);
return;
} catch (URISyntaxException e) {
LOGGER.error("Unable to resolve Wrapped Metanode template URI " + targetURI + ": " + e.getMessage(), e);
return;
} catch (CoreException e) {
LOGGER.error("Unable to resolve Wrapped Metanode template URI " + targetURI + ": " + e.getMessage(), e);
return;
} finally {
NodeContext.removeLastContext();
}
ChangeSubNodeLinkCommand cmd = new ChangeSubNodeLinkCommand(wfm, subNode, targetURI, newURI);
getCommandStack().execute(cmd);
} else {
throw new IllegalStateException("Can only change the type of a template link if the Wrapped Metanode is actually linked to a template - " + subNode + " is not.");
}
}
Aggregations