Search in sources :

Example 31 with NodeContainerUI

use of org.knime.core.ui.node.workflow.NodeContainerUI 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 32 with NodeContainerUI

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

the class KnimeResourceContentProvider method getChildren.

/**
 * {@inheritDoc}
 */
@Override
public Object[] getChildren(final Object element) {
    if (element instanceof IFile) {
        return EMPTY_ARRAY;
    }
    if (isKNIMEWorkflow(element)) {
        IContainer project = (IContainer) element;
        NodeContainerUI workflow = ProjectWorkflowMap.getWorkflowUI(project.getLocationURI());
        if (workflow != null) {
            // the number of contained nodes is returned
            return getSortedNodeContainers(((WorkflowManagerUI) workflow).getNodeContainers());
        }
    } else if (element instanceof WorkflowManager) {
        return getSortedNodeContainers(((WorkflowManagerUI) element).getNodeContainers());
    }
    return getFolders(element);
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) IFile(org.eclipse.core.resources.IFile) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) IContainer(org.eclipse.core.resources.IContainer)

Example 33 with NodeContainerUI

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

the class KnimeResourceLabelProvider method getText.

/**
 * {@inheritDoc}
 */
@Override
public String getText(final Object element) {
    if (element instanceof NodeContainerUI) {
        String output = ((NodeContainerUI) element).getName() + " (#" + ((NodeContainerUI) element).getID().getIndex() + ")";
        // then it cannot be found
        return output.replace(":", "_");
    }
    // query the element for its label
    IWorkbenchAdapter adapter = getAdapter(element);
    if (adapter == null) {
        // $NON-NLS-1$
        return "";
    }
    String label = adapter.getLabel(element);
    // return the decorated label
    return decorateText(label, element);
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) IWorkbenchAdapter(org.eclipse.ui.model.IWorkbenchAdapter)

Example 34 with NodeContainerUI

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

the class KnimeResourceLabelProvider method getImage.

/**
 * {@inheritDoc}
 */
@Override
public Image getImage(final Object element) {
    Image img = super.getImage(element);
    NodeContainerUI projectNode = null;
    if (element instanceof IContainer) {
        IContainer container = (IContainer) element;
        if (container.exists(WORKFLOW_FILE)) {
            // in any case a knime workflow or meta node (!)
            projectNode = ProjectWorkflowMap.getWorkflowUI(container.getLocationURI());
            if (projectNode == null && !isMetaNode(container)) {
                return CLOSED_WORKFLOW;
            }
        }
        if (projectNode == null) {
            if (isMetaNode(container)) {
                return NODE;
            } else if (container.exists(METAINFO_FILE)) {
                return WORKFLOW_GROUP;
            }
        }
    } else if (element instanceof NodeContainerUI) {
        projectNode = (NodeContainerUI) element;
    }
    if (projectNode != null) {
        if (projectNode instanceof WorkflowManagerUI && // are displayed with state
        ((WorkflowManagerUI) projectNode).getID().hasSamePrefix(WorkflowManager.ROOT.getID())) {
            NodeContainerState state = projectNode.getNodeContainerState();
            if (projectNode.getNodeMessage().getMessageType().equals(NodeMessage.Type.ERROR)) {
                return ERROR;
            }
            if (state.isExecuted()) {
                return EXECUTED;
            } else if (state.isExecutionInProgress()) {
                return EXECUTING;
            } else {
                return CONFIGURED;
            }
        } else {
            return NODE;
        }
    }
    return img;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerState(org.knime.core.node.workflow.NodeContainerState) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) Image(org.eclipse.swt.graphics.Image) IContainer(org.eclipse.core.resources.IContainer)

Example 35 with NodeContainerUI

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

the class ProjectWorkflowMap method replace.

/**
 * @param newPath the new path of the {@link IProject} after renaming
 * @param nc the {@link WorkflowManager} with a project new associated name
 * @param oldPath the old {@link IProject} path, under which the opened
 *  {@link WorkflowManager} is stored in the map
 */
public static void replace(final URI newPath, final WorkflowManagerUI nc, final URI oldPath) {
    if (oldPath == null) {
        throw new IllegalArgumentException("Old path must not be null (old is null, new is " + newPath + ")");
    }
    final MapWFKey oldKey = new MapWFKey(oldPath);
    NodeContainerUI removed = PROJECTS.remove(oldKey);
    if (removed == null) {
        throw new IllegalArgumentException("No project registered on URI " + oldPath);
    }
    Set<Object> clientList = WORKFLOW_CLIENTS.remove(oldKey);
    WF_LISTENER.workflowChanged(new WorkflowEvent(WorkflowEvent.Type.NODE_REMOVED, removed.getID(), Wrapper.unwrapNC(removed), null));
    putWorkflowUI(newPath, nc);
    if (clientList != null) {
        WORKFLOW_CLIENTS.put(new MapWFKey(newPath), clientList);
    }
    WF_LISTENER.workflowChanged(new WorkflowEvent(WorkflowEvent.Type.NODE_ADDED, nc.getID(), null, nc));
    NSC_LISTENER.stateChanged(new NodeStateEvent(nc.getID()));
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) WorkflowEvent(org.knime.core.node.workflow.WorkflowEvent) NodeStateEvent(org.knime.core.node.workflow.NodeStateEvent)

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