Skip to content

New Connection is not working when targeting the Done Action node #2208

@jerome-obeo

Description

@jerome-obeo

Steps to reproduce

  1. In a General View diagram, create an Action
  2. Open action flow compartment
  3. Create a nested action inside the first one
  4. Create a Done Action
  5. Create an edge starting the action to the Done action.
  6. In the edge menu choose New Connection (connect)

Expected behavior

A new connection edge appears between action usage and done action.

Actual behavior

Nothing happens: the menu does not close, and no edge is created.
The project is corrupted and can no longer be opened.

Fix

This issue is caused by the fact that the connection creation service (org.eclipse.syson.diagram.services.DiagramMutationElementService#createConnectionUsage) uses the semantic parents of the given source and target elements.
In the pathological case, the target element belongs to a library because the start and end actions are directly those defined in Actions.
The proposed fix is to retrieve the parents using the graphical nodes instead.
First, we need to look up the parent nodes of the edge source and target nodes. Then, using the object IDs from those nodes, we can retrieve the semantic elements associated with those IDs.
This way, we ensure that the parents of the library elements represented in the diagram are correct.
In the org.eclipse.syson.diagram.common.view.services.ViewCreateService class, there is a method that already does this parent retrieval:

    private Element getSourceOwner(Node sourceNode, IEditingContext editingContext, IDiagramService diagramService) {
        Diagram diagram = diagramService.getDiagramContext().diagram();
        String id;
        var parentNode = new NodeFinder(diagram).getParent(sourceNode);
        if (parentNode instanceof Node node) {
            id = node.getTargetObjectId();
        } else {
            // parent is diagram
            id = diagram.getTargetObjectId();
        }
        return this.objectSearchService.getObject(editingContext, id)
                .filter(Element.class::isInstance)
                .map(Element.class::cast)
                .orElse(null);
    }

We might need to expose the method above in order to use it in org.eclipse.syson.diagram.services.DiagramMutationElementService#createConnectionUsage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions