use of org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt 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
}
}
use of org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt 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.workbench.editor2.editparts.GUIWorkflowCipherPrompt 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.workbench.editor2.editparts.GUIWorkflowCipherPrompt 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.workbench.editor2.editparts.GUIWorkflowCipherPrompt in project knime-core by knime.
the class ExpandSubNodeAction method runOnNodes.
/**
* Expand sub node!
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
if (nodeParts.length < 1) {
return;
}
LOGGER.debug("Creating 'Expand Wrapped Metanode' job for " + nodeParts.length + " node(s)...");
try {
WorkflowManager manager = getManager();
SubNodeContainer subNode = Wrapper.unwrap(nodeParts[0].getNodeContainer(), SubNodeContainer.class);
if (!subNode.getWorkflowManager().unlock(new GUIWorkflowCipherPrompt())) {
return;
}
// 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 Wrapped 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(subNode.getID())) {
manager.resetAndConfigureNode(subNode.getID());
}
}
String res = manager.canExpandSubNode(subNode.getID());
if (res != null) {
throw new IllegalArgumentException(res);
}
ExpandSubNodeCommand emnc = new ExpandSubNodeCommand(manager, subNode.getID(), getEditor());
execute(emnc);
} catch (IllegalArgumentException e) {
MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR);
mb.setMessage("Expanding Wrapped 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
}
}
Aggregations