use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class SaveAsSubNodeTemplateAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodes) {
if (nodes.length < 1) {
return;
}
SubNodeContainer snc = unwrap(nodes[0].getNodeContainer(), SubNodeContainer.class);
WorkflowManager wm = snc.getWorkflowManager();
List<String> validMountPointList = new ArrayList<String>();
for (Map.Entry<String, AbstractContentProvider> entry : ExplorerMountTable.getMountedContent().entrySet()) {
AbstractContentProvider contentProvider = entry.getValue();
if (contentProvider.isWritable() && contentProvider.canHostMetaNodeTemplates()) {
validMountPointList.add(entry.getKey());
}
}
if (validMountPointList.isEmpty()) {
throw new IllegalStateException("No valid mount points found - " + "this is inconsistent with calculateEnabled()");
}
String[] validMountPoints = validMountPointList.toArray(new String[0]);
final Shell shell = Display.getCurrent().getActiveShell();
ContentObject defSel = getDefaultSaveLocation(wm);
SpaceResourceSelectionDialog dialog = new SpaceResourceSelectionDialog(shell, validMountPoints, defSel);
dialog.setTitle("Save As Wrapped Metanode Template");
dialog.setHeader("Select destination workflow group for Wrapped Metanode template");
dialog.setValidator(new Validator() {
@Override
public String validateSelectionValue(final AbstractExplorerFileStore selection, final String name) {
final AbstractExplorerFileInfo info = selection.fetchInfo();
if (info.isWorkflowGroup()) {
return null;
}
return "Only workflow groups can be selected as target.";
}
});
if (dialog.open() != Window.OK) {
return;
}
AbstractExplorerFileStore target = dialog.getSelection();
AbstractContentProvider contentProvider = target.getContentProvider();
contentProvider.saveSubNodeTemplate(snc, target);
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class StepLoopAction method internalCalculateEnabled.
/**
* @return <code>true</code>, if just one loop end node part is selected
* which is executable and a loop is in progress.
*
* @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
*/
@Override
protected boolean internalCalculateEnabled() {
NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
if (parts.length != 1) {
return false;
}
// enabled if the one selected node is a configured and "in progress"
// LoopEndNode
NodeContainerUI nc = parts[0].getNodeContainer();
if (Wrapper.wraps(nc, NativeNodeContainer.class)) {
NativeNodeContainer nnc = Wrapper.unwrap(nc, NativeNodeContainer.class);
if (nnc.isModelCompatibleTo(LoopEndNode.class) && nnc.getLoopStatus().equals(LoopStatus.PAUSED)) {
// either the node is paused...
return true;
}
WorkflowManager wm = getEditor().getWorkflowManager().get();
if (wm.canExecuteNodeDirectly(nc.getID())) {
// ...or we can execute it (then this will be the first step)
return true;
}
}
return false;
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class ChangeNodeBoundsCommand method execute.
/**
* Sets the new bounds.
*
* @see org.eclipse.gef.commands.Command#execute()
*/
@Override
public void execute() {
if (!Arrays.equals(m_oldBounds, m_newBounds)) {
WorkflowManager wm = getHostWFM();
NodeUIInformation information = NodeUIInformation.builder().setNodeLocation(m_newBounds[0], m_newBounds[1], m_newBounds[2], m_newBounds[3]).build();
NodeContainer container = wm.getNodeContainer(m_nodeID);
// must set explicitly so that event is fired by container
container.setUIInformation(information);
}
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class ChangeMetaNodeLinkCommand method setLink.
private boolean setLink(final URI link) {
NodeContainer metaNode = getHostWFM().getNodeContainer(m_metaNodeID);
if (!(metaNode instanceof WorkflowManager)) {
LOGGER.error("Command failed: Specified node is not a metanode");
return false;
}
MetaNodeTemplateInformation templateInfo = ((WorkflowManager) metaNode).getTemplateInformation();
MetaNodeTemplateInformation newInfo;
try {
newInfo = templateInfo.createLinkWithUpdatedSource(m_newLink);
} catch (InvalidSettingsException e1) {
// will not happen.
LOGGER.error("Command failed: Specified node is not a metanode with a link." + e1.getMessage(), e1);
return false;
}
getHostWFM().setTemplateInformation(m_metaNodeID, newInfo);
return true;
}
use of org.knime.core.node.workflow.WorkflowManager in project knime-core by knime.
the class DisconnectMetaNodeLinkCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute() {
m_changedIDs = new ArrayList<NodeID>();
m_oldTemplInfos = new ArrayList<MetaNodeTemplateInformation>();
WorkflowManager hostWFM = getHostWFM();
for (NodeID id : m_ids) {
NodeContainer nc = hostWFM.getNodeContainer(id);
if (nc instanceof WorkflowManager) {
WorkflowManager wm = (WorkflowManager) nc;
MetaNodeTemplateInformation lI = wm.getTemplateInformation();
if (Role.Link.equals(lI.getRole())) {
MetaNodeTemplateInformation old = hostWFM.setTemplateInformation(id, MetaNodeTemplateInformation.NONE);
RECENTLY_USED_URIS.put(wm.getID(), old.getSourceURI());
m_changedIDs.add(id);
m_oldTemplInfos.add(old);
}
}
}
}
Aggregations