use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class ExpandMetaNodeAction method runOnNodes.
/**
* Expand metanode!
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
if (nodeParts.length < 1) {
return;
}
LOGGER.debug("Creating 'Expand MetaNode' job for " + nodeParts.length + " node(s)...");
try {
WorkflowManager manager = getManager();
WorkflowManagerUI metaNode = (WorkflowManagerUI) nodeParts[0].getNodeContainer();
if (!Wrapper.unwrapWFM(metaNode).unlock(new GUIWorkflowCipherPrompt())) {
return;
}
// reset the metanode
if (manager.canResetNode(metaNode.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 Metanode 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(metaNode.getID())) {
manager.resetAndConfigureNode(metaNode.getID());
}
}
String res = manager.canExpandMetaNode(metaNode.getID());
if (res != null) {
throw new IllegalArgumentException(res);
}
ExpandMetaNodeCommand emnc = new ExpandMetaNodeCommand(manager, metaNode.getID(), getEditor());
execute(emnc);
} catch (IllegalArgumentException e) {
MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR);
mb.setMessage("Sorry, expanding Metanode failed: " + e.getMessage());
mb.setText("Expand 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 MetaNodeReconfigureAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
if (nodeParts.length < 1) {
return;
}
NodeContainerEditPart ep = nodeParts[0];
WorkflowManager metanode = Wrapper.unwrapWFM(ep.getNodeContainer());
if (!metanode.unlock(new GUIWorkflowCipherPrompt())) {
return;
}
ReconfigureMetaNodeWizard wizard = new ReconfigureMetaNodeWizard(ep.getViewer(), metanode);
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 ConnectionBendpointEditPolicy method getDeleteBendpointCommand.
/**
* {@inheritDoc}
*/
protected Command getDeleteBendpointCommand(final BendpointRequest req) {
// get the index of the bendpoint to delete
int index = req.getIndex();
ConnectionContainerEditPart editPart = (ConnectionContainerEditPart) getHost();
WorkflowManager wfm = getWorkflowManager();
return new NewBendpointDeleteCommand(editPart, wfm, index);
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class SubnodeLayoutWizard method addPages.
/**
* {@inheritDoc}
*/
@SuppressWarnings("rawtypes")
@Override
public void addPages() {
setWindowTitle("Node Usage and Layout");
setDefaultPageImageDescriptor(ImageRepository.getImageDescriptor(KNIMEEditorPlugin.PLUGIN_ID, "icons/layout_55.png"));
WorkflowManager wfManager = m_subNodeContainer.getWorkflowManager();
// Map<NodeID, SubNodeContainer> nestedSubnodes = wfManager.findNodes(SubNodeContainer.class, false);
Map<NodeID, WizardNode> viewNodes = wfManager.findNodes(WizardNode.class, false);
LinkedHashMap<NodeIDSuffix, WizardNode> resultMap = new LinkedHashMap<>();
for (Map.Entry<NodeID, WizardNode> entry : viewNodes.entrySet()) {
NodeID.NodeIDSuffix idSuffix = NodeID.NodeIDSuffix.create(wfManager.getID(), entry.getKey());
resultMap.put(idSuffix, entry.getValue());
}
List<NodeID> nodeIDs = new ArrayList<NodeID>();
nodeIDs.addAll(viewNodes.keySet());
/*for (NodeID subnodeID : nestedSubnodes.keySet()) {
WorkflowManager nestedWFManager = nestedSubnodes.get(subnodeID).getWorkflowManager();
if (!nestedWFManager.findNodes(WizardNode.class, true).isEmpty()) {
nodeIDs.add(subnodeID);
}
}*/
Collections.sort(nodeIDs);
m_page = new SubnodeLayoutJSONEditorPage("Change the layout configuration");
m_page.setNodes(wfManager, m_subNodeContainer, resultMap);
addPage(m_page);
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class RepositoryFactory method loadMetaNode.
private static WorkflowManagerUI loadMetaNode(final String pluginId, final String workflowDir) {
LOGGER.debug("found pre-installed template " + workflowDir);
Bundle bundle = Platform.getBundle(pluginId);
URL url = FileLocator.find(bundle, new Path(workflowDir), null);
if (url != null) {
try {
File f = new File(FileLocator.toFileURL(url).getFile());
LOGGER.debug("meta node template name: " + f.getName());
WorkflowLoadHelper loadHelper = new WorkflowLoadHelper(true) {
/**
* {@inheritDoc}
*/
@Override
public String getDotKNIMEFileName() {
return WorkflowPersistor.WORKFLOW_FILE;
}
};
// don't lock workflow dir
FileWorkflowPersistor persistor = WorkflowManager.createLoadPersistor(f, loadHelper);
WorkflowManager metaNode = WorkflowManager.META_NODE_ROOT.load(persistor, new ExecutionMonitor(), false).getWorkflowManager();
return WorkflowManagerWrapper.wrap(metaNode);
} catch (CanceledExecutionException cee) {
LOGGER.error("Unexpected canceled execution exception", cee);
} catch (Exception e) {
LOGGER.error("Failed to load meta workflow repository", e);
}
}
return null;
}
Aggregations