use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class WorkflowSelectionDragEditPartsTracker method handleDoubleClick.
/**
* {@inheritDoc}
*/
@Override
protected boolean handleDoubleClick(final int button) {
EditPart part = getSourceEditPart();
if (part instanceof NodeContainerEditPart && getCurrentInput().isModKeyDown(SWT.MOD1)) {
NodeContainerEditPart ncPart = ((NodeContainerEditPart) part);
NodeContainerUI container = (NodeContainerUI) ncPart.getModel();
if (container instanceof SubNodeContainerUI) {
ncPart.openSubWorkflowEditor();
return false;
}
}
return super.handleDoubleClick(button);
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart 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.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class ChangeMetaNodeLinkAction method internalCalculateEnabled.
/**
* @return true, if underlying model instance of <code>WorkflowManager</code>, otherwise false
*/
@Override
protected boolean internalCalculateEnabled() {
NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
if (nodes.length != 1) {
return false;
}
NodeContainerUI nc = nodes[0].getNodeContainer();
if (!(nc instanceof WorkflowManagerUI)) {
return false;
}
WorkflowManagerUI metaNode = (WorkflowManagerUI) nc;
if (!Role.Link.equals(unwrapWFM(metaNode).getTemplateInformation().getRole()) || metaNode.getParent().isWriteProtected()) {
// metanode must be linked and parent must not forbid the change
return false;
}
// we can reconfigure the template link - but only if template and flow are in the same mountpoint
URI targetURI = unwrapWFM(metaNode).getTemplateInformation().getSourceURI();
try {
if (ResolverUtil.isMountpointRelativeURL(targetURI) || ResolverUtil.isWorkflowRelativeURL(targetURI)) {
return true;
}
} catch (IOException e) {
return false;
}
// we can change absolute links if the mount points of flow and template are the same
AbstractContentProvider workflowMountPoint = null;
WorkflowContext wfc = metaNode.getProjectWFM().getContext();
LocalExplorerFileStore fs = ExplorerFileSystem.INSTANCE.fromLocalFile(wfc.getMountpointRoot());
if (fs != null) {
workflowMountPoint = fs.getContentProvider();
}
if (workflowMountPoint == null) {
return false;
}
AbstractExplorerFileStore targetfs = ExplorerFileSystem.INSTANCE.getStore(targetURI);
if (targetfs == null) {
return false;
}
return workflowMountPoint.equals(targetfs.getContentProvider());
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.
the class CheckUpdateMetaNodeLinkAction method getMetaNodesToCheck.
protected List<NodeID> getMetaNodesToCheck() {
List<NodeID> list = new ArrayList<NodeID>();
for (NodeContainerEditPart p : getSelectedParts(NodeContainerEditPart.class)) {
NodeContainerUI model = p.getNodeContainer();
if (Wrapper.wraps(model, NodeContainerTemplate.class)) {
NodeContainerTemplate tnc = Wrapper.unwrap(model, NodeContainerTemplate.class);
if (tnc.getTemplateInformation().getRole().equals(Role.Link)) {
if (!getManager().canUpdateMetaNodeLink(tnc.getID())) {
return Collections.emptyList();
}
list.add(tnc.getID());
}
list.addAll(getNCTemplatesToCheck(tnc));
}
}
return list;
}
use of org.knime.workbench.editor2.editparts.NodeContainerEditPart 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
}
}
Aggregations