Search in sources :

Example 1 with GUIWorkflowCipherPrompt

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

Example 2 with GUIWorkflowCipherPrompt

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

Example 3 with GUIWorkflowCipherPrompt

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();
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) ReconfigureMetaNodeWizard(org.knime.workbench.editor2.meta.ReconfigureMetaNodeWizard) GUIWorkflowCipherPrompt(org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 4 with GUIWorkflowCipherPrompt

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;
}
Also used : WorkflowEditor(org.knime.workbench.editor2.WorkflowEditor) WorkflowCipherPrompt(org.knime.core.node.workflow.WorkflowCipherPrompt) WorkflowManagerInput(org.knime.workbench.editor2.WorkflowManagerInput) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) PartInitException(org.eclipse.ui.PartInitException)

Example 5 with GUIWorkflowCipherPrompt

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

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