Search in sources :

Example 1 with NodeContainerUI

use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.

the class WorkflowSelectionDragEditPartsTracker method handleDoubleClick.

/**
 * {@inheritDoc}
 */
@Override
protected boolean handleDoubleClick(final int button) {
    EditPart part = getSourceEditPart();
    if (part instanceof NodeContainerEditPart && getCurrentInput().isModKeyDown(SWT.MOD1)) {
        NodeContainerEditPart ncPart = ((NodeContainerEditPart) part);
        NodeContainerUI container = (NodeContainerUI) ncPart.getModel();
        if (container instanceof SubNodeContainerUI) {
            ncPart.openSubWorkflowEditor();
            return false;
        }
    }
    return super.handleDoubleClick(button);
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AbstractPortEditPart(org.knime.workbench.editor2.editparts.AbstractPortEditPart) AbstractWorkflowPortBarEditPart(org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) EditPart(org.eclipse.gef.EditPart) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI)

Example 2 with NodeContainerUI

use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.

the class CancelAction method internalCalculateEnabled.

/**
 * @return true if at least one selected node is executing or queued
 * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
 */
@Override
protected boolean internalCalculateEnabled() {
    NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
    // enable if we have at least one executing or queued node in our
    // selection
    WorkflowManager wm = getEditor().getWorkflowManager().get();
    for (int i = 0; i < parts.length; i++) {
        // bugfix 1478
        NodeContainerUI nc = parts[i].getNodeContainer();
        if (wm.canCancelNode(nc.getID())) {
            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)

Example 3 with NodeContainerUI

use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.

the class ChangeMetaNodeLinkAction method internalCalculateEnabled.

/**
 * @return true, if underlying model instance of <code>WorkflowManager</code>, otherwise false
 */
@Override
protected boolean internalCalculateEnabled() {
    NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
    if (nodes.length != 1) {
        return false;
    }
    NodeContainerUI nc = nodes[0].getNodeContainer();
    if (!(nc instanceof WorkflowManagerUI)) {
        return false;
    }
    WorkflowManagerUI metaNode = (WorkflowManagerUI) nc;
    if (!Role.Link.equals(unwrapWFM(metaNode).getTemplateInformation().getRole()) || metaNode.getParent().isWriteProtected()) {
        // metanode must be linked and parent must not forbid the change
        return false;
    }
    // we can reconfigure the template link - but only if template and flow are in the same mountpoint
    URI targetURI = unwrapWFM(metaNode).getTemplateInformation().getSourceURI();
    try {
        if (ResolverUtil.isMountpointRelativeURL(targetURI) || ResolverUtil.isWorkflowRelativeURL(targetURI)) {
            return true;
        }
    } catch (IOException e) {
        return false;
    }
    // we can change absolute links if the mount points of flow and template are the same
    AbstractContentProvider workflowMountPoint = null;
    WorkflowContext wfc = metaNode.getProjectWFM().getContext();
    LocalExplorerFileStore fs = ExplorerFileSystem.INSTANCE.fromLocalFile(wfc.getMountpointRoot());
    if (fs != null) {
        workflowMountPoint = fs.getContentProvider();
    }
    if (workflowMountPoint == null) {
        return false;
    }
    AbstractExplorerFileStore targetfs = ExplorerFileSystem.INSTANCE.getStore(targetURI);
    if (targetfs == null) {
        return false;
    }
    return workflowMountPoint.equals(targetfs.getContentProvider());
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AbstractExplorerFileStore(org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore) LocalExplorerFileStore(org.knime.workbench.explorer.filesystem.LocalExplorerFileStore) WorkflowContext(org.knime.core.node.workflow.WorkflowContext) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) AbstractContentProvider(org.knime.workbench.explorer.view.AbstractContentProvider) IOException(java.io.IOException) URI(java.net.URI)

Example 4 with NodeContainerUI

use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.

the class CheckUpdateMetaNodeLinkAction method getMetaNodesToCheck.

protected List<NodeID> getMetaNodesToCheck() {
    List<NodeID> list = new ArrayList<NodeID>();
    for (NodeContainerEditPart p : getSelectedParts(NodeContainerEditPart.class)) {
        NodeContainerUI model = p.getNodeContainer();
        if (Wrapper.wraps(model, NodeContainerTemplate.class)) {
            NodeContainerTemplate tnc = Wrapper.unwrap(model, NodeContainerTemplate.class);
            if (tnc.getTemplateInformation().getRole().equals(Role.Link)) {
                if (!getManager().canUpdateMetaNodeLink(tnc.getID())) {
                    return Collections.emptyList();
                }
                list.add(tnc.getID());
            }
            list.addAll(getNCTemplatesToCheck(tnc));
        }
    }
    return list;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) NodeContainerTemplate(org.knime.core.node.workflow.NodeContainerTemplate) NodeID(org.knime.core.node.workflow.NodeID) ArrayList(java.util.ArrayList)

Example 5 with NodeContainerUI

use of org.knime.core.ui.node.workflow.NodeContainerUI in project knime-core by knime.

the class NodeContainerEditPart method deactivate.

/**
 * {@inheritDoc}
 */
@Override
public void deactivate() {
    NodeContainerUI nc = getNodeContainer();
    IPreferenceStore store = KNIMEUIPlugin.getDefault().getPreferenceStore();
    store.removePropertyChangeListener(this);
    nc.removeNodeStateChangeListener(this);
    nc.removeNodeMessageListener(this);
    nc.removeNodeProgressListener(this);
    nc.removeUIInformationListener(this);
    nc.removeNodePropertyChangedListener(this);
    removeEditPartListener(this);
    for (Object o : getChildren()) {
        EditPart editPart = (EditPart) o;
        editPart.deactivate();
    }
    EditPolicyIterator editPolicyIterator = getEditPolicyIterator();
    while (editPolicyIterator.hasNext()) {
        editPolicyIterator.next().deactivate();
    }
    super.deactivate();
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) EditPart(org.eclipse.gef.EditPart) NodeEditPart(org.eclipse.gef.NodeEditPart) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)59 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)28 SubNodeContainerUI (org.knime.core.ui.node.workflow.SubNodeContainerUI)17 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)16 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)10 NodeContainerFigure (org.knime.workbench.editor2.figures.NodeContainerFigure)9 SingleNodeContainerUI (org.knime.core.ui.node.workflow.SingleNodeContainerUI)8 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)7 HashMap (java.util.HashMap)5 Point (org.eclipse.draw2d.geometry.Point)5 Image (org.eclipse.swt.graphics.Image)5 ConnectionUIInformation (org.knime.core.node.workflow.ConnectionUIInformation)5 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)5 NodeID (org.knime.core.node.workflow.NodeID)5 ArrayList (java.util.ArrayList)4 EditPart (org.eclipse.gef.EditPart)4 LoopEndNode (org.knime.core.node.workflow.LoopEndNode)4 IContainer (org.eclipse.core.resources.IContainer)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3