Search in sources :

Example 6 with GUIWorkflowCipherPrompt

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);
    }
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) Shell(org.eclipse.swt.widgets.Shell) UI(org.knime.core.ui.UI) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) GUIWorkflowCipherPrompt(org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt)

Example 7 with GUIWorkflowCipherPrompt

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
    }
}
Also used : ConvertMetaNodeToSubNodeCommand(org.knime.workbench.editor2.commands.ConvertMetaNodeToSubNodeCommand) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) GUIWorkflowCipherPrompt(org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 8 with GUIWorkflowCipherPrompt

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);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) GUIWorkflowCipherPrompt(org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt)

Example 9 with GUIWorkflowCipherPrompt

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();
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) SubnodeWizardDialog(org.knime.workbench.editor2.subnode.SubnodeWizardDialog) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) GUIWorkflowCipherPrompt(org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt) SetupSubnodeWizard(org.knime.workbench.editor2.subnode.SetupSubnodeWizard)

Aggregations

GUIWorkflowCipherPrompt (org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt)8 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)6 MessageBox (org.eclipse.swt.widgets.MessageBox)4 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)4 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 Shell (org.eclipse.swt.widgets.Shell)2 SubNodeContainerUI (org.knime.core.ui.node.workflow.SubNodeContainerUI)2 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 PartInitException (org.eclipse.ui.PartInitException)1 WorkflowCipherPrompt (org.knime.core.node.workflow.WorkflowCipherPrompt)1 UI (org.knime.core.ui.UI)1 WorkflowEditor (org.knime.workbench.editor2.WorkflowEditor)1 WorkflowManagerInput (org.knime.workbench.editor2.WorkflowManagerInput)1 ConvertMetaNodeToSubNodeCommand (org.knime.workbench.editor2.commands.ConvertMetaNodeToSubNodeCommand)1 ConvertSubNodeToMetaNodeCommand (org.knime.workbench.editor2.commands.ConvertSubNodeToMetaNodeCommand)1 ExpandMetaNodeCommand (org.knime.workbench.editor2.commands.ExpandMetaNodeCommand)1 ExpandSubNodeCommand (org.knime.workbench.editor2.commands.ExpandSubNodeCommand)1 ReconfigureMetaNodeWizard (org.knime.workbench.editor2.meta.ReconfigureMetaNodeWizard)1