use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class RevealMetaNodeTemplateAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodes) {
List<NodeID> candidateList = new ArrayList<NodeID>();
List<AbstractExplorerFileStore> templates = new ArrayList<AbstractExplorerFileStore>();
for (NodeContainerEditPart p : nodes) {
Object model = p.getModel();
if (model instanceof WorkflowManagerUI) {
NodeContext.pushContext(Wrapper.unwrapNC(p.getNodeContainer()));
try {
WorkflowManager wm = Wrapper.unwrapWFM((UI) model);
MetaNodeTemplateInformation i = wm.getTemplateInformation();
if (Role.Link.equals(i.getRole())) {
candidateList.add(wm.getID());
AbstractExplorerFileStore template = ExplorerFileSystem.INSTANCE.getStore(i.getSourceURI());
if (template != null) {
templates.add(template);
}
}
} finally {
NodeContext.removeLastContext();
}
}
}
List<Object> treeObjects = ContentDelegator.getTreeObjectList(templates);
if (treeObjects != null && treeObjects.size() > 0) {
IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
for (IViewReference view : views) {
if (ExplorerView.ID.equals(view.getId())) {
ExplorerView explorerView = (ExplorerView) view.getView(true);
explorerView.getViewer().setSelection(new StructuredSelection(treeObjects), true);
}
}
}
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class PauseLoopExecutionAction method runOnNodes.
/**
* Pause Execution on all selected nodes.
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
LOGGER.debug("Creating 'Pause Execution' job for " + nodeParts.length + " node(s)...");
WorkflowManager manager = getManager();
for (NodeContainerEditPart p : nodeParts) {
manager.pauseLoopExecution(Wrapper.unwrapNC(p.getNodeContainer()));
}
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 StepLoopAction method runOnNodes.
/**
* Perform one step through the entire loop and pause again.
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
LOGGER.debug("Creating 'Step Loop Execution' job for " + nodeParts.length + " node(s)...");
WorkflowManager manager = getManager();
for (NodeContainerEditPart p : nodeParts) {
NodeContainerUI nc = p.getNodeContainer();
if (Wrapper.wraps(nc, NativeNodeContainer.class)) {
NativeNodeContainer nnc = Wrapper.unwrap(nc, NativeNodeContainer.class);
if (nnc.isModelCompatibleTo(LoopEndNode.class) && nnc.getLoopStatus().equals(LoopStatus.PAUSED)) {
manager.resumeLoopExecution(nnc, /*oneStep=*/
true);
} else if (manager.canExecuteNodeDirectly(nc.getID())) {
manager.executeUpToHere(nc.getID());
manager.pauseLoopExecution(nnc);
}
}
}
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 SubnodeLayoutAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
WorkflowManager manager = getManager();
SubNodeContainer subnode = (SubNodeContainer) manager.getDirectNCParent();
SubnodeLayoutWizard wizard = new SubnodeLayoutWizard(subnode);
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
dlg.create();
dlg.open();
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class AbstractCreateNewConnectedNodeCommand method autoConnectNewNode.
private void autoConnectNewNode() {
if (m_newNode == null) {
return;
}
if (m_connectTo == null) {
return;
}
WorkflowManager hostWFM = getHostWFM();
NodeContainer sourceNode = hostWFM.getNodeContainer(m_connectTo);
NodeContainer nc = hostWFM.getNodeContainer(m_newNode);
Map<Integer, Integer> matchingPorts = getMatchingPorts(sourceNode, nc);
if (matchingPorts.size() == 0) {
LOGGER.info("Can't auto-connect new node (" + m_newNode + "): " + "no matching port type found at node " + sourceNode.getNameWithID());
return;
}
for (Map.Entry<Integer, Integer> entry : matchingPorts.entrySet()) {
Integer leftPort = entry.getKey();
Integer rightPort = entry.getValue();
LOGGER.info("Autoconnect: Connecting new node " + m_newNode + " port " + rightPort + " with existing node " + sourceNode + " port " + leftPort);
try {
hostWFM.addConnection(m_connectTo, leftPort, m_newNode, rightPort).getID();
NodeTimer.GLOBAL_TIMER.addConnectionCreation(sourceNode, nc);
} catch (Exception e) {
String from = sourceNode.getNameWithID();
String to = nc.getNameWithID();
String msg = "Unable to add connection from " + from + " port " + leftPort + " to " + to + "port " + rightPort + ": " + e.getMessage();
LOGGER.error(msg);
}
}
}
Aggregations