Search in sources :

Example 46 with NodeContainerEditPart

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

the class HorizAlignmentCenter method doLayout.

/**
 * @param wfm the manager holding the nodes to layout
 * @param nodeParts the nodes to align
 * @return a map with offsets for the nodes
 */
static Map<NodeContainerEditPart, Integer> doLayout(final WorkflowManagerUI wfm, final NodeContainerEditPart[] nodeParts) {
    if (nodeParts.length == 0) {
        return Collections.emptyMap();
    }
    NodeContainerEditPart[] nodes = nodeParts.clone();
    // sorts by the x position
    Arrays.sort(nodes, new Comparator<NodeContainerEditPart>() {

        @Override
        public int compare(final NodeContainerEditPart o1, final NodeContainerEditPart o2) {
            NodeUIInformation ui1 = o1.getNodeContainer().getUIInformation();
            NodeUIInformation ui2 = o2.getNodeContainer().getUIInformation();
            if (ui1 == null || ui2 == null) {
                return 0;
            }
            if (ui1.getBounds()[0] < ui2.getBounds()[0]) {
                return -1;
            } else {
                return (ui1.getBounds()[0] > ui2.getBounds()[0]) ? 1 : 0;
            }
        }
    });
    // most left node is the anchor that doesn't change
    HashMap<NodeContainerEditPart, Integer> offsets = new HashMap<NodeContainerEditPart, Integer>();
    NodeUIInformation nui = nodes[0].getNodeContainer().getUIInformation();
    if (nui == null) {
        LOGGER.warn("Only nodes with location information can be aligned.");
        return Collections.emptyMap();
    }
    int refY = nui.getBounds()[1];
    for (int i = 1; /* idx 0 is anchor */
    i < nodes.length; i++) {
        NodeContainerUI nc = nodes[i].getNodeContainer();
        NodeUIInformation ui = nc.getUIInformation();
        if (ui.getBounds()[1] != refY) {
            offsets.put(nodes[i], refY - ui.getBounds()[1]);
        }
    }
    return offsets;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) HashMap(java.util.HashMap) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation)

Example 47 with NodeContainerEditPart

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

the class HorizAlignManager method doLayout.

/**
 */
public void doLayout() {
    Map<NodeContainerEditPart, Integer> offsets = HorizAlignmentCenter.doLayout(m_wfm, m_nodeParts);
    // if emtpy - do some other alignement. May be port alignement?
    // preserver the old stuff for undoers
    m_oldBendpoints = new HashMap<ConnectionID, ConnectionUIInformation>();
    m_oldCoordinates = new HashMap<NodeID, NodeUIInformation>();
    if (offsets.isEmpty()) {
        LOGGER.debug("Nodes already aligned. Doing nothing.");
        return;
    }
    // transfer new coordinates into nodes
    for (Map.Entry<NodeContainerEditPart, Integer> e : offsets.entrySet()) {
        NodeContainerEditPart node = e.getKey();
        NodeContainerUI nc = node.getNodeContainer();
        NodeUIInformation uiInfo = nc.getUIInformation();
        int[] b = uiInfo.getBounds();
        NodeUIInformation newCoord = NodeUIInformation.builder().setNodeLocation(b[0], b[1] + e.getValue(), b[2], b[3]).setHasAbsoluteCoordinates(uiInfo.hasAbsoluteCoordinates()).build();
        LOGGER.debug("Node " + nc + " gets alignment coordinates " + newCoord);
        // save old coordinates for undo
        m_oldCoordinates.put(nc.getID(), uiInfo);
        // adjust first bendpoints at port position
        adjustBendPoints(node, e.getValue());
        // triggers gui update
        nc.setUIInformation(newCoord);
    }
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionID(org.knime.core.node.workflow.ConnectionID) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) NodeID(org.knime.core.node.workflow.NodeID) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) HashMap(java.util.HashMap) Map(java.util.Map)

Example 48 with NodeContainerEditPart

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

the class VerticAlignManager method doLayout.

/**
 */
public void doLayout() {
    Map<NodeContainerEditPart, Integer> offsets = VerticAlignmentCenter.doLayout(m_wfm, m_nodeParts);
    // preserver the old stuff for undoers
    m_oldBendpoints = new HashMap<ConnectionID, ConnectionUIInformation>();
    m_oldCoordinates = new HashMap<NodeID, NodeUIInformation>();
    if (offsets.isEmpty()) {
        LOGGER.debug("Nodes already aligned. Doing nothing.");
        return;
    }
    // transfer new coordinates into nodes
    for (Map.Entry<NodeContainerEditPart, Integer> e : offsets.entrySet()) {
        NodeContainerEditPart node = e.getKey();
        NodeContainerUI nc = node.getNodeContainer();
        NodeUIInformation uiInfo = nc.getUIInformation();
        int[] b = uiInfo.getBounds();
        NodeUIInformation newCoord = NodeUIInformation.builder().setNodeLocation(b[0] + e.getValue(), b[1], b[2], b[3]).setHasAbsoluteCoordinates(uiInfo.hasAbsoluteCoordinates()).build();
        LOGGER.debug("Node " + nc + " gets alignment coordinates " + newCoord);
        // save old coordinates for undo
        m_oldCoordinates.put(nc.getID(), uiInfo);
        // triggers gui update
        nc.setUIInformation(newCoord);
    }
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionID(org.knime.core.node.workflow.ConnectionID) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) NodeID(org.knime.core.node.workflow.NodeID) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) Map(java.util.Map) HashMap(java.util.HashMap)

Example 49 with NodeContainerEditPart

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

the class WorkflowCoachView method updateInput.

private void updateInput(final ISelection selection) {
    if (NodeRecommendationManager.getInstance().getNumLoadedProviders() == 0) {
        // if there is at least one enabled triple provider then the statistics might need to be download first
        if (NodeRecommendationManager.getInstance().getNodeTripleProviders().stream().anyMatch(ntp -> ntp.isEnabled())) {
            if (m_loadState.get() == LoadState.Disposed) {
                return;
            }
            m_loadState.set(LoadState.LoadingNodes);
            updateInput("Loading recommendations ...");
            // try updating the triple provider that are enabled and require an update
            updateTripleProviders(e -> {
                m_loadState.set(LoadState.Initizalized);
                if (e.isPresent()) {
                    updateInputNoProvider();
                } else {
                    try {
                        NodeRecommendationManager.getInstance().loadRecommendations();
                        if (NodeRecommendationManager.getInstance().getNumLoadedProviders() == 0) {
                            // if there are still no triple provider, show link
                            updateInputNoProvider();
                        } else {
                            updateInput("Statistics successfully loaded. Select a node...");
                        }
                    } catch (Exception e1) {
                        updateInputNoProvider();
                    }
                }
            }, true, false);
        } else {
            // no triple provider enabled -> needs to be configured
            updateInputNoProvider();
            return;
        }
    }
    IStructuredSelection structSel = (IStructuredSelection) selection;
    if (structSel.size() > 1) {
        updateInput("No recommendation for multiple selected nodes.");
        return;
    }
    // retrieve first (and only!) selection:
    Iterator<?> selIt = structSel.iterator();
    boolean nodeSelected = selIt.hasNext();
    NodeContainer nc = null;
    if (nodeSelected) {
        Object sel = selIt.next();
        nodeSelected &= (sel instanceof NodeContainerEditPart);
        if (nodeSelected) {
            NodeContainerUI uinc = ((NodeContainerEditPart) sel).getNodeContainer();
            if (!Wrapper.wraps(uinc, NodeContainer.class)) {
                updateInput("Worklfow coach only supports native nodes, so far.\nBut the selected one is of type '" + uinc.getClass().getSimpleName() + "'.");
                return;
            } else {
                nc = Wrapper.unwrapNC(uinc);
                nodeSelected &= nc instanceof NativeNodeContainer;
            }
        }
    }
    // -> in that case no redraw is required
    if (nodeSelected) {
        if (m_lastSelection.equals(nc.getNameWithID())) {
            return;
        } else {
            m_lastSelection = nc.getNameWithID();
        }
    } else {
        if (m_lastSelection.equals("no node selected")) {
            return;
        } else {
            m_lastSelection = "no node selected";
        }
    }
    List<NodeRecommendation>[] recommendations;
    if (nodeSelected) {
        // retrieve node recommendations if exactly one node is selected
        recommendations = NodeRecommendationManager.getInstance().getNodeRecommendationFor((NativeNodeContainer) nc);
    } else if (nc == null) {
        // retrieve node recommendations if no node is selected (most likely the source nodes etc.)
        recommendations = NodeRecommendationManager.getInstance().getNodeRecommendationFor();
    } else {
        Display.getDefault().syncExec(() -> {
            m_viewer.setInput("");
            m_viewer.refresh();
        });
        return;
    }
    if (recommendations == null) {
        // something went wrong with loading the node recommendations, show the configure link
        updateInputNoProvider();
        return;
    }
    // TODO: cache node recommendations??
    int maxSize = 0;
    for (List<NodeRecommendation> l : recommendations) {
        maxSize = Math.max(maxSize, l.size());
    }
    List<NodeRecommendation[]> recommendationsJoined = joinRecommendations(recommendations, maxSize);
    // remove duplicates from list
    Set<String> duplicates = new HashSet<>();
    List<NodeRecommendation[]> recommendationsWithoutDups = new ArrayList<>(recommendationsJoined.size());
    for (NodeRecommendation[] nrs : recommendationsJoined) {
        int idx = getNonNullIdx(nrs);
        if (duplicates.add(nrs[idx].toString())) {
            recommendationsWithoutDups.add(nrs);
        }
    }
    // update viewer
    changeViewerStateTo(ViewerState.RECOMMENDATIONS);
    Display.getDefault().syncExec(() -> {
        m_viewer.setInput(recommendationsWithoutDups);
        m_viewer.refresh();
        m_recommendationsAvailable = true;
        // scroll to the very top
        if (!recommendationsWithoutDups.isEmpty()) {
            m_viewer.getTable().setTopIndex(0);
        }
    });
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeRecommendation(org.knime.workbench.workflowcoach.NodeRecommendationManager.NodeRecommendation) ArrayList(java.util.ArrayList) NodeContainer(org.knime.core.node.workflow.NodeContainer) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) List(java.util.List) ArrayList(java.util.ArrayList) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) HashSet(java.util.HashSet)

Example 50 with NodeContainerEditPart

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

the class WorkflowContextMenuProvider method buildContextMenu.

/**
 * {@inheritDoc}
 */
@Override
public void buildContextMenu(final IMenuManager manager) {
    final String FLOW_VAR_PORT_GRP = "Flow Variable Ports";
    // add the groups (grouped by separators) in their order first
    manager.add(new Separator(IWorkbenchActionConstants.GROUP_APP));
    manager.add(new Separator(FLOW_VAR_PORT_GRP));
    GEFActionConstants.addStandardActionGroups(manager);
    IAction action;
    action = m_actionRegistry.getAction("cut");
    manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    ((UpdateAction) action).update();
    action = m_actionRegistry.getAction("copy");
    manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    ((UpdateAction) action).update();
    action = m_actionRegistry.getAction(PasteActionContextMenu.ID);
    manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    ((UpdateAction) action).update();
    action = m_actionRegistry.getAction("undo");
    manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    ((UpdateAction) action).update();
    action = m_actionRegistry.getAction("redo");
    manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    ((UpdateAction) action).update();
    action = m_actionRegistry.getAction("delete");
    manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    ((UpdateAction) action).update();
    // Add (some) available actions from the registry to the context menu
    // manager
    // openDialog
    action = m_actionRegistry.getAction(OpenDialogAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // execute
    action = m_actionRegistry.getAction(ExecuteAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // execute and open first view
    action = m_actionRegistry.getAction(ExecuteAndOpenViewAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // cancel execution
    action = m_actionRegistry.getAction(CancelAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // show some menu items on LoopEndNodes only
    List parts = m_viewer.getSelectedEditParts();
    if (parts.size() == 1) {
        EditPart p = (EditPart) parts.get(0);
        if (p instanceof NodeContainerEditPart) {
            NodeContainerUI container = (NodeContainerUI) ((NodeContainerEditPart) p).getModel();
            if (container instanceof SingleNodeContainerUI) {
                SingleNodeContainerUI snc = (SingleNodeContainerUI) container;
                Wrapper.unwrapOptional(snc, SingleNodeContainer.class).ifPresent(sncImpl -> {
                    if (sncImpl.isModelCompatibleTo(LoopEndNode.class)) {
                        // pause loop execution
                        IAction loopAction;
                        loopAction = m_actionRegistry.getAction(PauseLoopExecutionAction.ID);
                        manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, loopAction);
                        ((AbstractNodeAction) loopAction).update();
                        // step loop execution
                        loopAction = m_actionRegistry.getAction(StepLoopAction.ID);
                        manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, loopAction);
                        ((AbstractNodeAction) loopAction).update();
                        // resume loop execution
                        loopAction = m_actionRegistry.getAction(ResumeLoopAction.ID);
                        manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, loopAction);
                        ((AbstractNodeAction) loopAction).update();
                    }
                });
            }
        }
    }
    // reset
    action = m_actionRegistry.getAction(ResetAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // set name and description
    action = m_actionRegistry.getAction(SetNodeDescriptionAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // add workflow annotation
    action = m_actionRegistry.getAction(AddAnnotationAction.ID);
    AddAnnotationAction aaa = (AddAnnotationAction) action;
    aaa.setLocation(m_lastLocation.x, m_lastLocation.y);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // collapse metanodes
    action = m_actionRegistry.getAction(CollapseMetaNodeAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    action = m_actionRegistry.getAction(EncapsulateSubNodeAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // insert "select loop" if loop nodes are selected
    boolean addSelectLoop = true;
    for (Object p : parts) {
        if (!(p instanceof NodeContainerEditPart)) {
            addSelectLoop = false;
            break;
        }
        NodeContainerUI nc = ((NodeContainerEditPart) p).getNodeContainer();
        if (!(nc instanceof SingleNodeContainerUI)) {
            addSelectLoop = false;
            break;
        }
        if (!((SingleNodeContainerUI) nc).isMemberOfScope()) {
            addSelectLoop = false;
            break;
        }
    }
    if (addSelectLoop) {
        action = m_actionRegistry.getAction(SelectLoopAction.ID);
        manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
        ((AbstractNodeAction) action).update();
    }
    IMenuManager metanodeMenuMgr = null;
    IMenuManager subnodeMenuMgr = null;
    IMenuManager subnodeViewMgr = null;
    // depending on the current selection: add the actions for the port
    // views and the node views
    // also check whether this node part is a meta-node
    // if so offer the "edit meta-node" option
    // all these feature are only offered if exactly 1 part is selected
    parts = m_viewer.getSelectedEditParts();
    // by now, we only support one part...
    if (parts.size() == 1) {
        EditPart p = (EditPart) parts.get(0);
        if (p instanceof WorkflowInPortBarEditPart) {
            WorkflowInPortBarEditPart root = (WorkflowInPortBarEditPart) p;
            manager.add(new Separator("outPortViews"));
            for (Object o : p.getChildren()) {
                EditPart child = (EditPart) o;
                if (child instanceof WorkflowInPortEditPart && ((WorkflowInPortEditPart) child).isSelected()) {
                    final WorkflowManager wm = Wrapper.unwrapWFM(((WorkflowPortBar) root.getModel()).getWorkflowManager());
                    action = new OpenWorkflowPortViewAction(wm, ((WorkflowInPortEditPart) child).getIndex(), wm.getNrInPorts());
                    manager.appendToGroup("outPortViews", action);
                    ((WorkflowInPortEditPart) child).setSelected(false);
                }
            }
        }
        if (p instanceof NodeContainerEditPart) {
            NodeContainerUI container = null;
            container = (NodeContainerUI) ((NodeContainerEditPart) p).getModel();
            if (!(container instanceof WorkflowManagerUI)) {
                action = m_actionRegistry.getAction(ToggleFlowVarPortsAction.ID);
                manager.appendToGroup(FLOW_VAR_PORT_GRP, action);
                ((AbstractNodeAction) action).update();
            }
            // add for node views option if applicable
            int numNodeViews = container.getNrViews();
            for (int i = 0; i < numNodeViews; i++) {
                action = new OpenViewAction(unwrapNC(container), i);
                manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
            }
            // add interactive view options
            if (container.hasInteractiveView()) {
                action = new OpenInteractiveViewAction(unwrapNC(container));
                manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
            } else {
                // TODO for subnodes move to submenu?
                if (wraps(container, NativeNodeContainer.class)) {
                    InteractiveWebViewsResult interactiveWebViewsResult = unwrapNC(container).getInteractiveWebViews();
                    for (int i = 0; i < interactiveWebViewsResult.size(); i++) {
                        action = new OpenInteractiveWebViewAction(unwrapNC(container), interactiveWebViewsResult.get(i));
                        manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
                    }
                }
            }
            if (container instanceof WorkflowManagerUI) {
                metanodeMenuMgr = getMetaNodeMenuManager(metanodeMenuMgr, manager);
                // OPEN META NODE
                action = new OpenSubworkflowEditorAction((NodeContainerEditPart) p);
                metanodeMenuMgr.appendToGroup(GROUP_METANODE, action);
                // EXPAND META NODE
                action = m_actionRegistry.getAction(ExpandMetaNodeAction.ID);
                metanodeMenuMgr.appendToGroup(GROUP_METANODE, action);
                ((AbstractNodeAction) action).update();
                // RECONFIGURE META NODE
                if (parts.size() == 1) {
                    action = m_actionRegistry.getAction(MetaNodeReconfigureAction.ID);
                    metanodeMenuMgr.appendToGroup(GROUP_METANODE, action);
                    ((AbstractNodeAction) action).update();
                }
                // WRAP
                action = m_actionRegistry.getAction(ConvertMetaNodeToSubNodeAction.ID);
                metanodeMenuMgr.appendToGroup(GROUP_METANODE, action);
                ((AbstractNodeAction) action).update();
            }
            // SUBNODE
            if (container instanceof SubNodeContainerUI) {
                subnodeMenuMgr = getSubNodeMenuManager(subnodeMenuMgr, manager);
                // OPEN SUBNODE
                action = new OpenSubNodeEditorAction((NodeContainerEditPart) p);
                subnodeMenuMgr.appendToGroup(GROUP_SUBNODE, action);
                // EXPAND SUBNODE
                action = m_actionRegistry.getAction(ExpandSubNodeAction.ID);
                subnodeMenuMgr.appendToGroup(GROUP_SUBNODE, action);
                ((AbstractNodeAction) action).update();
                // RECONFIGURE SUBNODE
                action = m_actionRegistry.getAction(SubNodeReconfigureAction.ID);
                subnodeMenuMgr.appendToGroup(GROUP_SUBNODE, action);
                ((AbstractNodeAction) action).update();
                // UNWRAP
                action = m_actionRegistry.getAction(ConvertSubNodeToMetaNodeAction.ID);
                subnodeMenuMgr.appendToGroup(GROUP_SUBNODE, action);
                ((AbstractNodeAction) action).update();
                if (wraps(container, SubNodeContainer.class)) {
                    InteractiveWebViewsResult interactiveWebViewsResult = unwrapNC(container).getInteractiveWebViews();
                    if (interactiveWebViewsResult.size() > 0) {
                        subnodeViewMgr = getSingleSubNodeViewsMenuManager(subnodeViewMgr, subnodeMenuMgr);
                        for (int i = 0; i < interactiveWebViewsResult.size(); i++) {
                            action = new OpenInteractiveWebViewAction(unwrapNC(container), interactiveWebViewsResult.get(i));
                            subnodeViewMgr.appendToGroup(GROUP_SUBNODE_VIEWS, action);
                        }
                    }
                    action = new OpenSubnodeWebViewAction(Wrapper.unwrap(container, SubNodeContainer.class));
                    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
                }
            }
            // add port views
            manager.add(new Separator("outPortViews"));
            int numOutPorts = container.getNrOutPorts();
            for (int i = 0; i < numOutPorts; i++) {
                if (i == 0 && !(container instanceof WorkflowManagerUI)) {
                    // skip the implicit flow var ports on "normal" nodes
                    continue;
                }
                if (wraps(container, NodeContainer.class)) {
                    action = new OpenPortViewAction(unwrapNC(container), i, numOutPorts);
                    manager.appendToGroup("outPortViews", action);
                }
            }
        }
    }
    boolean addMetaNodeActions = false;
    boolean addSubNodeActions = false;
    for (Object p : parts) {
        if (p instanceof NodeContainerEditPart) {
            NodeContainerUI model = ((NodeContainerEditPart) p).getNodeContainer();
            if (model instanceof WorkflowManagerUI) {
                addMetaNodeActions = true;
            } else if (model instanceof SubNodeContainerUI) {
                addSubNodeActions = true;
            }
        }
    }
    if (addMetaNodeActions) {
        metanodeMenuMgr = getMetaNodeMenuManager(metanodeMenuMgr, manager);
        // SAVE AS TEMPLATE
        action = m_actionRegistry.getAction(SaveAsMetaNodeTemplateAction.ID);
        metanodeMenuMgr.appendToGroup(GROUP_METANODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // CHECK UPDATE
        action = m_actionRegistry.getAction(CheckUpdateMetaNodeLinkAction.ID);
        metanodeMenuMgr.appendToGroup(GROUP_METANODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // DISCONNECT
        action = m_actionRegistry.getAction(DisconnectMetaNodeLinkAction.ID);
        metanodeMenuMgr.appendToGroup(GROUP_METANODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // LINK TYPE
        action = m_actionRegistry.getAction(ChangeMetaNodeLinkAction.ID);
        metanodeMenuMgr.appendToGroup(GROUP_METANODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // REVEAL TEMPLATE
        action = m_actionRegistry.getAction(RevealMetaNodeTemplateAction.ID);
        metanodeMenuMgr.appendToGroup(GROUP_METANODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // LOCK
        if (Boolean.getBoolean(KNIMEConstants.PROPERTY_SHOW_METANODE_LOCK_ACTION)) {
            action = m_actionRegistry.getAction(LockMetaNodeAction.ID);
            metanodeMenuMgr.appendToGroup(GROUP_METANODE, action);
            ((AbstractNodeAction) action).update();
        }
    }
    if (addSubNodeActions) {
        subnodeMenuMgr = getSubNodeMenuManager(subnodeMenuMgr, manager);
        // SAVE AS TEMPLATE (SUBNODE)
        action = m_actionRegistry.getAction(SaveAsSubNodeTemplateAction.ID);
        subnodeMenuMgr.appendToGroup(GROUP_SUBNODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // CHECK UPDATE (SUBNODE)
        action = m_actionRegistry.getAction(CheckUpdateMetaNodeLinkAction.ID);
        subnodeMenuMgr.appendToGroup(GROUP_SUBNODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // DISCONNECT LINK (SUBNODE)
        action = m_actionRegistry.getAction(DisconnectSubNodeLinkAction.ID);
        subnodeMenuMgr.appendToGroup(GROUP_SUBNODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // CHANGE LINK (SUBNODE)
        action = m_actionRegistry.getAction(ChangeSubNodeLinkAction.ID);
        subnodeMenuMgr.appendToGroup(GROUP_SUBNODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // REVEAL TEMPLATE (SUBNODE)
        action = m_actionRegistry.getAction(RevealSubNodeTemplateAction.ID);
        subnodeMenuMgr.appendToGroup(GROUP_SUBNODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // LOCK SUBNODE
        if (Boolean.getBoolean(KNIMEConstants.PROPERTY_SHOW_METANODE_LOCK_ACTION)) {
            action = m_actionRegistry.getAction(LockSubNodeAction.ID);
            subnodeMenuMgr.appendToGroup(GROUP_SUBNODE, action);
            ((AbstractNodeAction) action).update();
        }
    }
    manager.updateAll(true);
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) SingleNodeContainerUI(org.knime.core.ui.node.workflow.SingleNodeContainerUI) SingleNodeContainerUI(org.knime.core.ui.node.workflow.SingleNodeContainerUI) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) ExecuteAndOpenViewAction(org.knime.workbench.editor2.actions.ExecuteAndOpenViewAction) OpenViewAction(org.knime.workbench.editor2.actions.OpenViewAction) OpenInteractiveWebViewAction(org.knime.workbench.editor2.actions.OpenInteractiveWebViewAction) AddAnnotationAction(org.knime.workbench.editor2.actions.AddAnnotationAction) WorkflowInPortBarEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) OpenPortViewAction(org.knime.workbench.editor2.actions.OpenPortViewAction) AbstractNodeAction(org.knime.workbench.editor2.actions.AbstractNodeAction) OpenSubNodeEditorAction(org.knime.workbench.editor2.actions.OpenSubNodeEditorAction) List(java.util.List) WorkflowInPortEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortEditPart) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer) IAction(org.eclipse.jface.action.IAction) OpenSubworkflowEditorAction(org.knime.workbench.editor2.actions.OpenSubworkflowEditorAction) UpdateAction(org.eclipse.gef.ui.actions.UpdateAction) OpenInteractiveViewAction(org.knime.workbench.editor2.actions.OpenInteractiveViewAction) WorkflowInPortBarEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart) EditPart(org.eclipse.gef.EditPart) WorkflowInPortEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) Point(org.eclipse.swt.graphics.Point) OpenSubnodeWebViewAction(org.knime.workbench.editor2.actions.OpenSubnodeWebViewAction) OpenWorkflowPortViewAction(org.knime.workbench.editor2.actions.OpenWorkflowPortViewAction) IMenuManager(org.eclipse.jface.action.IMenuManager) InteractiveWebViewsResult(org.knime.core.node.workflow.action.InteractiveWebViewsResult) Separator(org.eclipse.jface.action.Separator)

Aggregations

NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)77 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)28 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)24 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)16 EditPart (org.eclipse.gef.EditPart)15 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)14 Point (org.eclipse.draw2d.geometry.Point)11 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)11 NodeContainer (org.knime.core.node.workflow.NodeContainer)9 NodeID (org.knime.core.node.workflow.NodeID)9 AnnotationEditPart (org.knime.workbench.editor2.editparts.AnnotationEditPart)9 NodeAnnotationEditPart (org.knime.workbench.editor2.editparts.NodeAnnotationEditPart)9 WorkflowRootEditPart (org.knime.workbench.editor2.editparts.WorkflowRootEditPart)9 ArrayList (java.util.ArrayList)8 GUIWorkflowCipherPrompt (org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt)8 MetaNodeTemplateInformation (org.knime.core.node.workflow.MetaNodeTemplateInformation)6 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)6 WorkflowInPortBarEditPart (org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart)6 Rectangle (org.eclipse.draw2d.geometry.Rectangle)5 MessageBox (org.eclipse.swt.widgets.MessageBox)5