Search in sources :

Example 1 with WorkflowEditor

use of org.knime.workbench.editor2.WorkflowEditor 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 2 with WorkflowEditor

use of org.knime.workbench.editor2.WorkflowEditor in project knime-core by knime.

the class LoadWorkflowRunnable method postLoadCheckForMetaNodeUpdates.

static void postLoadCheckForMetaNodeUpdates(final WorkflowEditor editor, final WorkflowManager parent, final List<NodeID> links) {
    StringBuilder m = new StringBuilder("The workflow contains ");
    if (links.size() == 1) {
        m.append("one metanode link (\"");
        m.append(parent.findNodeContainer(links.get(0)).getNameWithID());
        m.append("\").");
    } else {
        m.append(links.size()).append(" metanode links.");
    }
    m.append("\n\n").append("Do you want to check for updates now?");
    final String message = m.toString();
    final AtomicBoolean result = new AtomicBoolean(false);
    final IPreferenceStore corePrefStore = KNIMEUIPlugin.getDefault().getPreferenceStore();
    final String pKey = PreferenceConstants.P_META_NODE_LINK_UPDATE_ON_LOAD;
    String pref = corePrefStore.getString(pKey);
    boolean showInfoMsg = true;
    if (MessageDialogWithToggle.ALWAYS.equals(pref)) {
        result.set(true);
        showInfoMsg = false;
    } else if (MessageDialogWithToggle.NEVER.equals(pref)) {
        result.set(false);
    } else {
        final Display display = Display.getDefault();
        display.syncExec(new Runnable() {

            @Override
            public void run() {
                Shell activeShell = display.getActiveShell();
                MessageDialogWithToggle dlg = MessageDialogWithToggle.openYesNoCancelQuestion(activeShell, "Metanode Link Update", message, "Remember my decision", false, corePrefStore, pKey);
                switch(dlg.getReturnCode()) {
                    case IDialogConstants.YES_ID:
                        result.set(true);
                        break;
                    default:
                        result.set(false);
                }
            }
        });
    }
    if (result.get()) {
        new CheckUpdateMetaNodeLinkAllAction(editor, showInfoMsg).run();
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Shell(org.eclipse.swt.widgets.Shell) CheckUpdateMetaNodeLinkAllAction(org.knime.workbench.editor2.actions.CheckUpdateMetaNodeLinkAllAction) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Display(org.eclipse.swt.widgets.Display)

Example 3 with WorkflowEditor

use of org.knime.workbench.editor2.WorkflowEditor in project knime-core by knime.

the class WorkflowEditor method updateTempRemoteWorkflowMessage.

/**
 * Places the message at the top of the editor - above all other contents.
 */
private void updateTempRemoteWorkflowMessage() {
    WorkflowFigure workflowFigure = ((WorkflowRootEditPart) getViewer().getRootEditPart().getContents()).getFigure();
    if (isTempRemoteWorkflowEditor()) {
        URI origRemoteLocation = m_origRemoteLocation;
        WorkflowEditor parentEditor = m_parentEditor;
        while (origRemoteLocation == null && parentEditor != null) {
            origRemoteLocation = parentEditor.m_origRemoteLocation;
            parentEditor = parentEditor.m_parentEditor;
        }
        workflowFigure.setMessage("  This is a temporary copy of \"" + URIUtil.toDecodedString(origRemoteLocation) + "\".\n  Use \"Save\" to upload it back to its original location on the server or \"Save As...\" to " + "store it in a different location.");
    } else if (!getWorkflowManager().isPresent()) {
        workflowFigure.setMessage("This is a remotely opened job workflow. It can neither be stored locally nor edited." + " It also just represents a static snapshot of the job workflow and won't get" + " updated automatically (use context menu to refresh).");
    } else {
        workflowFigure.setMessage(null);
    }
    List<IEditorPart> subEditors = getSubEditors();
    for (IEditorPart ep : subEditors) {
        if (ep instanceof WorkflowEditor) {
            ((WorkflowEditor) ep).updateTempRemoteWorkflowMessage();
        }
    }
}
Also used : WorkflowFigure(org.knime.workbench.editor2.figures.WorkflowFigure) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) IEditorPart(org.eclipse.ui.IEditorPart) URI(java.net.URI)

Example 4 with WorkflowEditor

use of org.knime.workbench.editor2.WorkflowEditor in project knime-core by knime.

the class NewWorkflowContainerEditPolicy method handleNodeDrop.

/**
 * @param manager the workflow manager
 * @param factory the ndoe factory
 * @param request the drop request
 */
private Command handleNodeDrop(final WorkflowManager manager, final NodeFactory<? extends NodeModel> factory, final CreateDropRequest request) {
    RequestType requestType = request.getRequestType();
    Point location = request.getLocation();
    boolean snapToGrid = WorkflowEditor.getActiveEditorSnapToGrid();
    if (requestType.equals(RequestType.CREATE)) {
        // create a new node
        return new CreateNodeCommand(manager, factory, location, snapToGrid);
    } else {
        AbstractEditPart editPart = request.getEditPart();
        if (requestType.equals(RequestType.INSERT)) {
            // insert new node into connection
            InsertNodeCommand insertCommand = new InsertNodeCommand(manager, factory, location, snapToGrid, (ConnectionContainerEditPart) editPart);
            if (request.createSpace()) {
                CreateSpaceAction csa = new CreateSpaceAction((WorkflowEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(), request.getDirection(), request.getDistance());
                return insertCommand.chain(csa.createCompoundCommand(csa.selectedParts()));
            } else {
                return insertCommand;
            }
        } else if (requestType.equals(RequestType.REPLACE)) {
            // replace node with a node
            return new ReplaceNodeCommand(manager, factory, location, snapToGrid, (NodeContainerEditPart) editPart);
        } else {
            return null;
        }
    }
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) ReplaceNodeCommand(org.knime.workbench.editor2.commands.ReplaceNodeCommand) Point(org.eclipse.draw2d.geometry.Point) CreateNodeCommand(org.knime.workbench.editor2.commands.CreateNodeCommand) InsertNodeCommand(org.knime.workbench.editor2.commands.InsertNodeCommand) CreateSpaceAction(org.knime.workbench.editor2.actions.CreateSpaceAction) RequestType(org.knime.workbench.editor2.CreateDropRequest.RequestType)

Example 5 with WorkflowEditor

use of org.knime.workbench.editor2.WorkflowEditor in project knime-core by knime.

the class NewWorkflowContainerEditPolicy method handleMetaNodeTemplateDrop.

/**
 * @param manager the workflow manager
 * @param request the drop request
 * @param filestore the location of the metanode template
 */
private Command handleMetaNodeTemplateDrop(final WorkflowManager manager, final CreateDropRequest request, final AbstractExplorerFileStore filestore) {
    RequestType requestType = request.getRequestType();
    Point location = request.getLocation();
    boolean snapToGrid = WorkflowEditor.getActiveEditorSnapToGrid();
    if (requestType.equals(RequestType.CREATE)) {
        // create metanode from template
        return new CreateMetaNodeTemplateCommand(manager, filestore, location, snapToGrid);
    } else {
        AbstractEditPart editPart = request.getEditPart();
        if (requestType.equals(RequestType.INSERT)) {
            // insert metanode from template into connection
            InsertMetaNodeTempalteCommand insertCommand = new InsertMetaNodeTempalteCommand(manager, filestore, location, snapToGrid, (ConnectionContainerEditPart) editPart);
            if (request.createSpace()) {
                CreateSpaceAction csa = new CreateSpaceAction((WorkflowEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(), request.getDirection(), request.getDistance());
                return insertCommand.chain(csa.createCompoundCommand(csa.selectedParts()));
            } else {
                return insertCommand;
            }
        } else if (requestType.equals(RequestType.REPLACE)) {
            // replace node with metanode from template
            return new ReplaceMetaNodeTemplateCommand(manager, filestore, location, snapToGrid, (NodeContainerEditPart) editPart);
        } else {
            return null;
        }
    }
}
Also used : ReplaceMetaNodeTemplateCommand(org.knime.workbench.editor2.commands.ReplaceMetaNodeTemplateCommand) CreateMetaNodeTemplateCommand(org.knime.workbench.editor2.commands.CreateMetaNodeTemplateCommand) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) Point(org.eclipse.draw2d.geometry.Point) InsertMetaNodeTempalteCommand(org.knime.workbench.editor2.commands.InsertMetaNodeTempalteCommand) CreateSpaceAction(org.knime.workbench.editor2.actions.CreateSpaceAction) RequestType(org.knime.workbench.editor2.CreateDropRequest.RequestType)

Aggregations

WorkflowEditor (org.knime.workbench.editor2.WorkflowEditor)3 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)3 WorkflowRootEditPart (org.knime.workbench.editor2.editparts.WorkflowRootEditPart)3 Point (org.eclipse.draw2d.geometry.Point)2 AbstractEditPart (org.eclipse.gef.editparts.AbstractEditPart)2 RequestType (org.knime.workbench.editor2.CreateDropRequest.RequestType)2 CreateSpaceAction (org.knime.workbench.editor2.actions.CreateSpaceAction)2 URI (java.net.URI)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 EditPart (org.eclipse.gef.EditPart)1 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1 IEditorPart (org.eclipse.ui.IEditorPart)1 PartInitException (org.eclipse.ui.PartInitException)1 EditorUIInformation (org.knime.core.node.workflow.EditorUIInformation)1 WorkflowCipherPrompt (org.knime.core.node.workflow.WorkflowCipherPrompt)1 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)1 SubNodeContainerUI (org.knime.core.ui.node.workflow.SubNodeContainerUI)1