use of org.knime.core.ui.node.workflow.WorkflowManagerUI in project knime-core by knime.
the class AddMetaNodeAction method setActiveEditor.
/**
* {@inheritDoc}
*/
@Override
public void setActiveEditor(final IAction action, final IEditorPart targetEditor) {
m_editor = (WorkflowEditor) targetEditor;
boolean enabled = false;
if (m_editor != null) {
WorkflowManagerUI wm = m_editor.getWorkflowManagerUI();
enabled = wm != null && !wm.isWriteProtected();
}
action.setEnabled(enabled);
}
use of org.knime.core.ui.node.workflow.WorkflowManagerUI 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.core.ui.node.workflow.WorkflowManagerUI 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.ui.node.workflow.WorkflowManagerUI in project knime-core by knime.
the class NodeContainerEditPart method openSubWorkflowEditor.
public void openSubWorkflowEditor() {
WorkflowCipherPrompt prompt = new GUIWorkflowCipherPrompt();
Object obj = getModel();
WorkflowManagerUI wm;
if (obj instanceof WorkflowManagerUI) {
wm = (WorkflowManagerUI) getModel();
} else if (obj instanceof SubNodeContainerUI) {
wm = ((SubNodeContainerUI) obj).getWorkflowManager();
} else {
return;
}
// if workflow manager is encrypted, try unlocking it
if (wm.isEncrypted()) {
if (!Wrapper.unwrapWFM(wm).unlock(prompt)) {
return;
}
}
// open new editor for subworkflow
LOGGER.debug("opening new editor for sub-workflow");
try {
final WorkflowEditor parent = (WorkflowEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
WorkflowManagerInput input = new WorkflowManagerInput(wm, parent);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, "org.knime.workbench.editor.WorkflowEditor");
} catch (PartInitException e) {
LOGGER.error("Error while opening new editor", e);
}
return;
}
use of org.knime.core.ui.node.workflow.WorkflowManagerUI in project knime-core by knime.
the class NodeContainerEditPart method checkMetaNodeLockIcon.
private void checkMetaNodeLockIcon() {
NodeContainerUI nc = getNodeContainer();
if (nc instanceof WorkflowManagerUI) {
WorkflowManagerUI wm = (WorkflowManagerUI) nc;
Image i;
if (wm.isEncrypted()) {
if (wm.isUnlocked()) {
i = META_NODE_UNLOCK_ICON;
} else {
i = META_NODE_LOCK_ICON;
}
} else {
i = null;
}
NodeContainerFigure fig = (NodeContainerFigure) getFigure();
fig.setMetaNodeLockIcon(i);
}
}
Aggregations