Search in sources :

Example 56 with NodeContainerUI

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

the class NodeContainerEditPart method updateJobManagerIcon.

private void updateJobManagerIcon() {
    NodeContainerUI nc = getNodeContainer();
    NodeExecutionJobManager jobManager = nc.getJobManager();
    URL iconURL;
    if (jobManager != null) {
        iconURL = jobManager.getIcon();
    } else {
        NodeExecutionJobManager parentJobManager = nc.findJobManager();
        if (parentJobManager instanceof AbstractNodeExecutionJobManager) {
            if (Wrapper.wraps(nc, NodeContainer.class)) {
                iconURL = ((AbstractNodeExecutionJobManager) parentJobManager).getIconForChild(Wrapper.unwrapNC(nc));
            } else {
                iconURL = null;
            }
        } else {
            iconURL = null;
        }
    }
    Image icon = null;
    if (iconURL != null) {
        icon = ImageDescriptor.createFromURL(iconURL).createImage();
    }
    ((NodeContainerFigure) getFigure()).setJobExecutorIcon(icon);
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) AbstractNodeExecutionJobManager(org.knime.core.node.workflow.AbstractNodeExecutionJobManager) Image(org.eclipse.swt.graphics.Image) URL(java.net.URL) AbstractNodeExecutionJobManager(org.knime.core.node.workflow.AbstractNodeExecutionJobManager) NodeExecutionJobManager(org.knime.core.node.workflow.NodeExecutionJobManager) NodeContainerFigure(org.knime.workbench.editor2.figures.NodeContainerFigure)

Example 57 with NodeContainerUI

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

the class NodeContainerEditPart method checkNodeLockIcon.

private void checkNodeLockIcon() {
    NodeContainerUI nc = getNodeContainer();
    Image i;
    StringBuilder toolTip = new StringBuilder();
    // node is considered being locked if it is either lock from being reseted, it's not deletable, or the dialog is locked
    if (nc.getNodeLocks().hasResetLock() || nc.getNodeLocks().hasDeleteLock() || nc.getNodeLocks().hasConfigureLock()) {
        toolTip.append("Node Locked (");
        i = NODE_LOCK_ICON;
        if (nc.getNodeLocks().hasResetLock()) {
            toolTip.append("Reset, ");
        }
        if (nc.getNodeLocks().hasDeleteLock()) {
            toolTip.append("Delete, ");
        }
        if (nc.getNodeLocks().hasConfigureLock()) {
            toolTip.append("Configure, ");
        }
        toolTip.setLength(toolTip.length() - 2);
        toolTip.append(")");
    } else {
        i = null;
    }
    NodeContainerFigure fig = (NodeContainerFigure) getFigure();
    fig.setNodeLockIcon(i, toolTip.toString());
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) Image(org.eclipse.swt.graphics.Image) NodeContainerFigure(org.knime.workbench.editor2.figures.NodeContainerFigure)

Example 58 with NodeContainerUI

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

the class KnimeResourceContentProvider method hasChildren.

/**
 * {@inheritDoc}
 */
@Override
public boolean hasChildren(final Object element) {
    if (element instanceof IFile) {
        return false;
    }
    if (isKNIMEWorkflow(element)) {
        IContainer project = (IContainer) element;
        NodeContainerUI workflow = ProjectWorkflowMap.getWorkflowUI(project.getLocationURI());
        if (workflow != null) {
            // the number of contained nodes is returned
            return ((WorkflowManagerUI) workflow).getNodeContainers().size() > 0;
        }
    } else if (element instanceof WorkflowManagerUI) {
        return ((WorkflowManagerUI) element).getNodeContainers().size() > 0;
    }
    // then it is a node and has no children
    if (element instanceof IContainer) {
        IContainer container = (IContainer) element;
        if (isKNIMEWorkflow(container.getParent())) {
            return false;
        }
    }
    return getFolders(element).length > 0;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) IFile(org.eclipse.core.resources.IFile) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) IContainer(org.eclipse.core.resources.IContainer)

Example 59 with NodeContainerUI

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

the class ProjectWorkflowMap method putWorkflowUI.

/**
 * Adds a {@link WorkflowManagerUI} of an opened workflow with the URI of
 * the workflow directory to the map. Used by the WorkflowEditor.
 *
 * @param path URI of the directory containing the workflow.knime file
 * @param manager {@link WorkflowManagerUI} in memory holding the workflow
 */
public static void putWorkflowUI(final URI path, final WorkflowManagerUI manager) {
    MapWFKey p = new MapWFKey(path);
    // in case the manager is replaced
    // -> unregister listeners from the old one
    NodeContainerUI oldOne = PROJECTS.get(p);
    if (oldOne != null) {
        oldOne.removeNodeStateChangeListener(NSC_LISTENER);
        ((WorkflowManagerUI) oldOne).removeListener(WF_LISTENER);
        oldOne.removeNodeMessageListener(MSG_LISTENER);
        oldOne.removeNodePropertyChangedListener(NODE_PROP_LISTENER);
    }
    PROJECTS.put(p, manager);
    manager.addNodeStateChangeListener(NSC_LISTENER);
    manager.addListener(WF_LISTENER);
    manager.addNodeMessageListener(MSG_LISTENER);
    manager.addNodePropertyChangedListener(NODE_PROP_LISTENER);
    // with WorkflowManagerUI instances, too!
    if (Wrapper.wraps(manager, WorkflowManager.class)) {
        WF_LISTENER.workflowChanged(new WorkflowEvent(WorkflowEvent.Type.NODE_ADDED, manager.getID(), null, Wrapper.unwrapWFM(manager)));
    }
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) WorkflowEvent(org.knime.core.node.workflow.WorkflowEvent)

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