use of org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt in project knime-core by knime.
the class LockSubNodeAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodes) {
if (nodes.length != 1) {
return;
}
Object model = nodes[0].getModel();
if (!(Wrapper.wraps(model, SubNodeContainer.class))) {
return;
}
WorkflowManager metaNodeWFM = Wrapper.unwrap((UI) model, SubNodeContainer.class).getWorkflowManager();
final Shell shell = Display.getCurrent().getActiveShell();
if (!metaNodeWFM.unlock(new GUIWorkflowCipherPrompt())) {
return;
}
LockMetaNodeDialog lockDialog = new LockMetaNodeDialog(shell, metaNodeWFM);
if (lockDialog.open() != Window.OK) {
return;
}
String password = lockDialog.getPassword();
String hint = lockDialog.getPasswordHint();
try {
metaNodeWFM.setWorkflowPassword(password, hint);
} catch (NoSuchAlgorithmException e) {
String msg = "Unable to encrypt Wrapped Metanode: " + e.getMessage();
LOGGER.error(msg, e);
MessageDialog.openError(shell, "Wrapped Metanode encrypt", msg);
}
}
use of org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt in project knime-core by knime.
the class ConvertMetaNodeToSubNodeAction method runOnNodes.
/**
* Expand metanode!
*
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
if (nodeParts.length < 1) {
return;
}
try {
WorkflowManager manager = getManager();
WorkflowManager metaNode = Wrapper.unwrapWFM(nodeParts[0].getNodeContainer());
if (!metaNode.unlock(new GUIWorkflowCipherPrompt())) {
return;
}
// before we do anything, let's see if the convert will 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());
}
}
ConvertMetaNodeToSubNodeCommand cmnc = new ConvertMetaNodeToSubNodeCommand(manager, metaNode.getID());
execute(cmnc);
} catch (IllegalArgumentException e) {
MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR);
mb.setMessage("Sorry, converting Metanode 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 LockMetaNodeAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodes) {
if (nodes.length != 1) {
return;
}
Object model = nodes[0].getModel();
if (!(model instanceof WorkflowManagerUI)) {
return;
}
WorkflowManagerUI metaNodeWFM = (WorkflowManagerUI) model;
final Shell shell = Display.getCurrent().getActiveShell();
if (!unwrapWFM(metaNodeWFM).unlock(new GUIWorkflowCipherPrompt())) {
return;
}
LockMetaNodeDialog lockDialog = new LockMetaNodeDialog(shell, unwrapWFM(metaNodeWFM));
if (lockDialog.open() != Window.OK) {
return;
}
String password = lockDialog.getPassword();
String hint = lockDialog.getPasswordHint();
try {
metaNodeWFM.setWorkflowPassword(password, hint);
} catch (NoSuchAlgorithmException e) {
String msg = "Unable to encrypt metanode: " + e.getMessage();
LOGGER.error(msg, e);
MessageDialog.openError(shell, "Metanode encrypt", msg);
}
}
use of org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt in project knime-core by knime.
the class SubNodeReconfigureAction method runOnNodes.
/**
* {@inheritDoc}
*/
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
if (nodeParts.length < 1) {
return;
}
NodeContainerEditPart ep = nodeParts[0];
SubNodeContainerUI subnodeNC = (SubNodeContainerUI) ep.getModel();
if (!Wrapper.unwrap(subnodeNC, SubNodeContainer.class).getWorkflowManager().unlock(new GUIWorkflowCipherPrompt())) {
return;
}
SetupSubnodeWizard wizard = new SetupSubnodeWizard(ep.getViewer(), Wrapper.unwrap(subnodeNC, SubNodeContainer.class));
SubnodeWizardDialog dlg = new SubnodeWizardDialog(Display.getCurrent().getActiveShell(), wizard);
dlg.create();
dlg.open();
}
Aggregations