Search in sources :

Example 36 with NodeContainerEditPart

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

the class ResetAction method internalCalculateEnabled.

/**
 * @return <code>true</code> if at least one node is resetable
 * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
 */
@Override
protected boolean internalCalculateEnabled() {
    NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
    for (int i = 0; i < parts.length; i++) {
        NodeContainerEditPart part = parts[i];
        NodeContainerUI nc = part.getNodeContainer();
        if (getManager().canResetNode(nc.getID())) {
            return true;
        }
    }
    return false;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart)

Example 37 with NodeContainerEditPart

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

the class OpenFirstOutPortViewAction method runOnNodes.

/**
 * This opens the first view of all the selected nodes.
 *
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    LOGGER.debug("Creating open first out-port view job for " + nodeParts.length + " node(s)...");
    for (NodeContainerEditPart p : nodeParts) {
        final NodeContainerUI cont = p.getNodeContainer();
        final java.awt.Rectangle knimeWindowBounds = OpenViewAction.getAppBoundsAsAWTRec();
        // first port is flow var port
        final OptionalInt portIndex = getPortIndex(cont);
        if (portIndex.isPresent()) {
            SwingUtilities.invokeLater(new Runnable() {

                /**
                 * {inheritDoc}
                 */
                @Override
                public void run() {
                    NodeOutPort port = Wrapper.unwrapNC(cont).getOutPort(portIndex.getAsInt());
                    LOGGER.debug("Open First Out-Port View " + cont.getName() + " on port " + port.getPortName());
                    port.openPortView(port.getPortName(), knimeWindowBounds);
                }
            });
        }
    }
    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 : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) NodeOutPort(org.knime.core.node.workflow.NodeOutPort) OptionalInt(java.util.OptionalInt)

Example 38 with NodeContainerEditPart

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

the class PauseLoopExecutionAction method internalCalculateEnabled.

/**
 * @return <code>true</code>, if just one loop end node part is selected
 *         which is executing.
 *
 * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
 */
@Override
protected boolean internalCalculateEnabled() {
    NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
    if (parts.length != 1) {
        return false;
    }
    // enabled if the one selected node is an executing LoopEndNode
    NodeContainerUI nc = parts[0].getNodeContainer();
    if (Wrapper.wraps(nc, SingleNodeContainer.class)) {
        SingleNodeContainer snc = Wrapper.unwrap(nc, SingleNodeContainer.class);
        if ((snc.isModelCompatibleTo(LoopEndNode.class)) && (nc.getNodeContainerState().isExecutionInProgress())) {
            return true;
        }
    }
    return false;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer)

Example 39 with NodeContainerEditPart

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

the class ResumeLoopAction method runOnNodes.

/**
 * Resume paused loop.
 *
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    LOGGER.debug("Creating 'Resume Loop Execution' job for " + nodeParts.length + " node(s)...");
    WorkflowManager manager = getManager();
    for (NodeContainerEditPart p : nodeParts) {
        NodeContainerUI nc = p.getNodeContainer();
        if (Wrapper.wraps(nc, NativeNodeContainer.class)) {
            NativeNodeContainer nnc = Wrapper.unwrap(nc, NativeNodeContainer.class);
            if (nnc.isModelCompatibleTo(LoopEndNode.class) && nnc.getLoopStatus().equals(LoopStatus.PAUSED)) {
                manager.resumeLoopExecution(nnc, /*oneStep=*/
                false);
            }
        }
    }
    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 : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) LoopEndNode(org.knime.core.node.workflow.LoopEndNode)

Example 40 with NodeContainerEditPart

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

the class RevealSubNodeTemplateAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodes) {
    List<NodeID> candidateList = new ArrayList<NodeID>();
    List<AbstractExplorerFileStore> templates = new ArrayList<AbstractExplorerFileStore>();
    for (NodeContainerEditPart p : nodes) {
        Object model = p.getModel();
        if (wraps(model, SubNodeContainer.class)) {
            NodeContext.pushContext(Wrapper.unwrapNC(p.getNodeContainer()));
            try {
                SubNodeContainer snc = unwrap((UI) model, SubNodeContainer.class);
                MetaNodeTemplateInformation i = snc.getTemplateInformation();
                if (Role.Link.equals(i.getRole())) {
                    candidateList.add(snc.getID());
                    AbstractExplorerFileStore template = ExplorerFileSystem.INSTANCE.getStore(i.getSourceURI());
                    if (template != null) {
                        templates.add(template);
                    }
                }
            } finally {
                NodeContext.removeLastContext();
            }
        }
    }
    List<Object> treeObjects = ContentDelegator.getTreeObjectList(templates);
    if (treeObjects != null && treeObjects.size() > 0) {
        IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
        for (IViewReference view : views) {
            if (ExplorerView.ID.equals(view.getId())) {
                ExplorerView explorerView = (ExplorerView) view.getView(true);
                explorerView.getViewer().setSelection(new StructuredSelection(treeObjects), true);
            }
        }
    }
}
Also used : ExplorerView(org.knime.workbench.explorer.view.ExplorerView) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AbstractExplorerFileStore(org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore) IViewReference(org.eclipse.ui.IViewReference) NodeID(org.knime.core.node.workflow.NodeID) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

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