Search in sources :

Example 41 with NodeContainerEditPart

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

the class SelectLoopAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    WorkflowManager wfm = getManager();
    for (NodeContainerEditPart selNode : nodeParts) {
        NodeContainerUI selNC = selNode.getNodeContainer();
        if (selNC instanceof SingleNodeContainerUI) {
            EditPartViewer viewer = selNode.getViewer();
            List<NodeContainer> loopNodes = wfm.getNodesInScope(Wrapper.unwrap(selNC, SingleNodeContainer.class));
            for (NodeContainer nc : loopNodes) {
                NodeContainerEditPart sel = (NodeContainerEditPart) viewer.getEditPartRegistry().get(NodeContainerWrapper.wrap(nc));
                viewer.appendSelection(sel);
            }
        }
    }
    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) SingleNodeContainerUI(org.knime.core.ui.node.workflow.SingleNodeContainerUI) SingleNodeContainerUI(org.knime.core.ui.node.workflow.SingleNodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) EditPartViewer(org.eclipse.gef.EditPartViewer) NodeContainer(org.knime.core.node.workflow.NodeContainer) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer)

Example 42 with NodeContainerEditPart

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

the class ShowNodeIdsAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public synchronized void runOnNodes(final NodeContainerEditPart[] parts) {
    ScrollingGraphicalViewer provider = (ScrollingGraphicalViewer) getEditor().getEditorSite().getSelectionProvider();
    if (provider == null) {
        return;
    }
    // get parent of the node parts
    WorkflowRootEditPart editorPart = (WorkflowRootEditPart) provider.getRootEditPart().getChildren().get(0);
    editorPart.changeShowNodeID();
    for (NodeContainerEditPart edit : getAllParts(NodeContainerEditPart.class)) {
        edit.updateHeaderField();
    }
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart)

Example 43 with NodeContainerEditPart

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

the class AbstractEditorAction method selectionChanged.

/**
 * {@inheritDoc}
 */
@Override
public final void selectionChanged(final IAction action, final ISelection selection) {
    if (m_decoratedAction != null) {
        m_decoratedAction.dispose();
        m_decoratedAction = null;
        // and unregister from old selection
        for (NodeContainerEditPart cont : m_currentSelection) {
            cont.getNodeContainer().removeNodeStateChangeListener(this);
        }
        m_currentSelection.clear();
    }
    if (m_editor != null) {
        m_decoratedAction = createAction(m_editor);
        StructuredSelection sel = ((StructuredSelection) selection);
        if (sel != null) {
            // register to new selection
            for (Iterator itr = sel.iterator(); itr.hasNext(); ) {
                Object o = itr.next();
                if (o instanceof NodeContainerEditPart) {
                    NodeContainerEditPart ncEP = (NodeContainerEditPart) o;
                    m_currentSelection.add(ncEP);
                    ncEP.getNodeContainer().addNodeStateChangeListener(this);
                }
            }
        }
        action.setEnabled(m_decoratedAction.isEnabled());
        action.setChecked(m_decoratedAction.isChecked());
    }
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Iterator(java.util.Iterator)

Example 44 with NodeContainerEditPart

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

the class StepLoopAction method internalCalculateEnabled.

/**
 * @return <code>true</code>, if just one loop end node part is selected
 *         which is executable and a loop is in progress.
 *
 * @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 a configured and "in progress"
    // LoopEndNode
    NodeContainerUI nc = parts[0].getNodeContainer();
    if (Wrapper.wraps(nc, NativeNodeContainer.class)) {
        NativeNodeContainer nnc = Wrapper.unwrap(nc, NativeNodeContainer.class);
        if (nnc.isModelCompatibleTo(LoopEndNode.class) && nnc.getLoopStatus().equals(LoopStatus.PAUSED)) {
            // either the node is paused...
            return true;
        }
        WorkflowManager wm = getEditor().getWorkflowManager().get();
        if (wm.canExecuteNodeDirectly(nc.getID())) {
            // ...or we can execute it (then this will be the first step)
            return true;
        }
    }
    return false;
}
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 45 with NodeContainerEditPart

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

the class ToggleGridAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    final WorkflowEditor editor = getEditor();
    EditorUIInformation settings = editor.getCurrentEditorSettings();
    EditorUIInformation newSet = EditorUIInformation.builder().setSnapToGrid(!settings.getSnapToGrid()).build();
    editor.applyEditorSettings(newSet);
    editor.markDirty();
}
Also used : WorkflowEditor(org.knime.workbench.editor2.WorkflowEditor) EditorUIInformation(org.knime.core.node.workflow.EditorUIInformation)

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