From 9da61cdb490f07332f869d113b1aafba184d3583 Mon Sep 17 00:00:00 2001 From: Axel RICHARD Date: Tue, 30 Sep 2025 16:32:53 +0200 Subject: [PATCH] [1550] Reveal action flow compartment on New Start Action Bug: https://github.com/eclipse-syson/syson/issues/1550 Signed-off-by: Axel RICHARD --- CHANGELOG.adoc | 1 + .../compartments/ActionFlowTests.java | 4 +- .../compartments/StartActionTests.java | 136 ++++++++++++++++++ .../services/NodeDescriptionService.java | 14 +- .../eclipse/syson/services/ToolService.java | 51 ++----- .../eclipse/syson/services/UtilService.java | 24 ++++ .../AnnotatingNodeDescriptionProvider.java | 4 +- .../common/view/services/ViewNodeService.java | 3 +- .../common/view/services/ViewToolService.java | 4 +- ...ctFreeFormCompartmentNodeToolProvider.java | 6 +- .../tools/StateSubactionNodeToolProvider.java | 4 +- ...TransitionCompartmentNodeToolProvider.java | 4 +- .../pages/release-notes/2025.10.0.adoc | 1 + 13 files changed, 198 insertions(+), 58 deletions(-) create mode 100644 backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/compartments/StartActionTests.java diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 5ff11b686..ad57dd355 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -83,6 +83,7 @@ Now it has been fixed in Sirius Web 2025.8.4, `SysONUpdateLibraryExecutor` has b - https://github.com/eclipse-syson/syson/issues/1522[#1522] [diagrams] To avoid edge blinking when refreshing the diagram, we need to set the properties `measured.height` and `measured.width` with the value of the node layout data when converting a custom node accordingly to the xyflow https://reactflow.dev/learn/advanced-use/ssr-ssg-configuration#node-dimensions[documentation]. - https://github.com/eclipse-syson/syson/issues/1545[#1545] [diagrams] Add _interconnection_ compartment to `PartDefinition` nodes in the standard diagrams. - https://github.com/eclipse-syson/syson/issues/1546[#1546] [diagrams] Fix drag and drop of a graphical node from the diagram background into a _Package_ graphical node. +- https://github.com/eclipse-syson/syson/issues/1550[#1550] [diagrams] Fix an issue where the _action flow_ compartment was not revealed when the _New Start Action_ was executed. === Improvements diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/compartments/ActionFlowTests.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/compartments/ActionFlowTests.java index 6f44213fd..84e931197 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/compartments/ActionFlowTests.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/compartments/ActionFlowTests.java @@ -154,7 +154,7 @@ public void tearDown() { config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) @Test - public void creatSuccesionBetweenNestedActions() { + public void createSuccesionBetweenNestedActions() { String creationToolId = this.diagramDescriptionIdProvider.getEdgeCreationToolId(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getActionUsage()), "New Succession"); this.verifier.then(() -> this.edgeCreationTester.runSingleClickOnTwoDiagramElementsTool(ActionFlowCompartmentTestProjectData.EDITING_CONTEXT_ID, this.diagram, @@ -182,7 +182,7 @@ public void creatSuccesionBetweenNestedActions() { config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) @Test - public void creatTransitionBetweenNestedActions() { + public void createTransitionBetweenNestedActions() { String creationToolId = this.diagramDescriptionIdProvider.getEdgeCreationToolId(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getActionUsage()), "New Transition"); this.verifier.then(() -> this.edgeCreationTester.runSingleClickOnTwoDiagramElementsTool(ActionFlowCompartmentTestProjectData.EDITING_CONTEXT_ID, this.diagram, diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/compartments/StartActionTests.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/compartments/StartActionTests.java new file mode 100644 index 000000000..2472ab6cb --- /dev/null +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/compartments/StartActionTests.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 2025 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.syson.application.controllers.diagrams.compartments; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.eclipse.sirius.components.diagrams.tests.DiagramEventPayloadConsumer.assertRefreshedDiagramThat; + +import java.time.Duration; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; + +import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramEventInput; +import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload; +import org.eclipse.sirius.components.diagrams.Diagram; +import org.eclipse.sirius.components.diagrams.ViewModifier; +import org.eclipse.sirius.components.diagrams.tests.navigation.DiagramNavigator; +import org.eclipse.sirius.components.view.emf.diagram.IDiagramIdProvider; +import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState; +import org.eclipse.syson.AbstractIntegrationTests; +import org.eclipse.syson.application.controllers.diagrams.testers.ToolTester; +import org.eclipse.syson.application.data.GeneralViewWithTopNodesTestProjectData; +import org.eclipse.syson.services.diagrams.DiagramDescriptionIdProvider; +import org.eclipse.syson.services.diagrams.api.IGivenDiagramDescription; +import org.eclipse.syson.services.diagrams.api.IGivenDiagramSubscription; +import org.eclipse.syson.standard.diagrams.view.SDVDescriptionNameGenerator; +import org.eclipse.syson.sysml.SysmlPackage; +import org.eclipse.syson.util.IDescriptionNameGenerator; +import org.eclipse.syson.util.SysONRepresentationDescriptionIdentifiers; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.jdbc.Sql; +import org.springframework.test.context.jdbc.SqlConfig; +import org.springframework.transaction.annotation.Transactional; + +import reactor.core.publisher.Flux; +import reactor.test.StepVerifier; + +/** + * Tests the Start Action inside the General View diagram. + * + * @author arichard + */ +@Transactional +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class StartActionTests extends AbstractIntegrationTests { + + public static final String START_ACTION_USAGE_ID = "9a0d2905-0f9c-5bb4-af74-9780d6db1817"; + + @Autowired + private IGivenInitialServerState givenInitialServerState; + + @Autowired + private IGivenDiagramSubscription givenDiagramSubscription; + + @Autowired + private IGivenDiagramDescription givenDiagramDescription; + + @Autowired + private IDiagramIdProvider diagramIdProvider; + + @Autowired + private ToolTester nodeCreationTester; + + private final IDescriptionNameGenerator descriptionNameGenerator = new SDVDescriptionNameGenerator(); + + private Flux givenSubscriptionToDiagram() { + var diagramEventInput = new DiagramEventInput(UUID.randomUUID(), + GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + GeneralViewWithTopNodesTestProjectData.GraphicalIds.DIAGRAM_ID); + var flux = this.givenDiagramSubscription.subscribe(diagramEventInput); + return flux; + } + + @BeforeEach + public void beforeEach() { + this.givenInitialServerState.initialize(); + } + + @DisplayName("GIVEN an ActionUsage action1, WHEN using the 'New Start Action' tool is executed on action1, THEN the action flow compartment of action1 is revealed.") + @Sql(scripts = { GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, + config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED)) + @Test + public void addStartNode() { + var flux = this.givenSubscriptionToDiagram(); + + var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, + SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID); + var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider); + + var toolId = diagramDescriptionIdProvider.getNodeCreationToolId(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getActionUsage()), + "New Start Action"); + assertThat(toolId).as("The tool 'New Start Action' should exist on ActionUsage").isNotNull(); + + var diagram = new AtomicReference(); + + Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diag -> { + diagram.set(diag); + var actionFlowCompartmentNode = new DiagramNavigator(diag).nodeWithLabel("\u00ABref action\u00BB\naction").childNodeWithLabel("action flow").getNode(); + assertThat(actionFlowCompartmentNode.getState()).isEqualTo(ViewModifier.Hidden); + }); + + Runnable invokeTool = () -> { + this.nodeCreationTester.invokeTool(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, diagram, "action", toolId); + }; + + Consumer updatedDiagramConsumer = assertRefreshedDiagramThat(diag -> { + var actionFlowCompartmentNode = new DiagramNavigator(diag).nodeWithLabel("\u00ABref action\u00BB\naction").childNodeWithLabel("action flow").getNode(); + assertThat(actionFlowCompartmentNode.getState()).isEqualTo(ViewModifier.Normal); + var startNode = new DiagramNavigator(diag).nodeWithLabel("\u00ABref action\u00BB\naction").childNodeWithLabel("action flow").childNodeWithTargetObjectId(START_ACTION_USAGE_ID).getNode(); + assertThat(startNode).isNotNull(); + + }); + + StepVerifier.create(flux) + .consumeNextWith(initialDiagramContentConsumer) + .then(invokeTool) + .consumeNextWith(updatedDiagramConsumer) + .thenCancel() + .verify(Duration.ofSeconds(100)); + } +} diff --git a/backend/services/syson-services/src/main/java/org/eclipse/syson/services/NodeDescriptionService.java b/backend/services/syson-services/src/main/java/org/eclipse/syson/services/NodeDescriptionService.java index 8d961dca5..ce8511a41 100644 --- a/backend/services/syson-services/src/main/java/org/eclipse/syson/services/NodeDescriptionService.java +++ b/backend/services/syson-services/src/main/java/org/eclipse/syson/services/NodeDescriptionService.java @@ -18,7 +18,7 @@ import java.util.Objects; import java.util.stream.Stream; -import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext; +import org.eclipse.sirius.components.collaborative.diagrams.DiagramContext; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IObjectSearchService; import org.eclipse.sirius.components.diagrams.description.NodeDescription; @@ -60,7 +60,7 @@ public NodeDescriptionService(IObjectSearchService objectSearchService) { * @return the child descriptions of {@code nodeDescriptions} that can render {@code element} */ public List getChildNodeDescriptionsForRendering(Element element, Object ownerObject, List nodeDescriptions, - Map convertedNodes, IEditingContext editingContext, IDiagramContext diagramContext) { + Map convertedNodes, IEditingContext editingContext, DiagramContext diagramContext) { List candidates = new ArrayList<>(); for (NodeDescription node : nodeDescriptions) { List allChildren = new ArrayList<>(); @@ -97,7 +97,7 @@ public List getChildNodeDescriptionsForRendering(Element elemen * @return the list of node descriptions that can be used to render the given semantic element. */ public List getNodeDescriptionsForRenderingElementAsChild(Element element, Object ownerObject, List nodeDescriptions, - Map convertedNodes, IEditingContext editingContext, IDiagramContext diagramContext) { + Map convertedNodes, IEditingContext editingContext, DiagramContext diagramContext) { List candidates = new ArrayList<>(); for (NodeDescription node : nodeDescriptions) { List allChildNodeDescriptions = Stream.concat( @@ -130,14 +130,14 @@ public List getNodeDescriptionsForRenderingElementAsChild(Eleme * @return true if the given node description can be used to render the given semantic element and * false otherwise. */ - public boolean canNodeDescriptionRenderElement(NodeDescription nodeDescription, Element element, Object ownerObject, IEditingContext editingContext, IDiagramContext diagramContext) { + public boolean canNodeDescriptionRenderElement(NodeDescription nodeDescription, Element element, Object ownerObject, IEditingContext editingContext, DiagramContext diagramContext) { boolean canNodeDescriptionRenderElement = false; VariableManager semanticElementsProviderVariableManager = new VariableManager(); semanticElementsProviderVariableManager.put(VariableManager.SELF, ownerObject); semanticElementsProviderVariableManager.put(IEditingContext.EDITING_CONTEXT, editingContext); - semanticElementsProviderVariableManager.put(IDiagramContext.DIAGRAM_CONTEXT, diagramContext); + semanticElementsProviderVariableManager.put(DiagramContext.DIAGRAM_CONTEXT, diagramContext); var ancestors = new ArrayList<>(); - this.objectSearchService.getObject(editingContext, diagramContext.getDiagram().getTargetObjectId()) + this.objectSearchService.getObject(editingContext, diagramContext.diagram().getTargetObjectId()) .filter(ViewUsage.class::isInstance) .map(ViewUsage.class::cast) .ifPresent(ancestors::add); @@ -149,7 +149,7 @@ public boolean canNodeDescriptionRenderElement(NodeDescription nodeDescription, VariableManager shouldRenderPredicateVariableManager = new VariableManager(); shouldRenderPredicateVariableManager.put(VariableManager.SELF, element); shouldRenderPredicateVariableManager.put(IEditingContext.EDITING_CONTEXT, editingContext); - shouldRenderPredicateVariableManager.put(IDiagramContext.DIAGRAM_CONTEXT, diagramContext); + shouldRenderPredicateVariableManager.put(DiagramContext.DIAGRAM_CONTEXT, diagramContext); shouldRenderPredicateVariableManager.put(NodeDescription.ANCESTORS, null); canNodeDescriptionRenderElement = nodeDescription.getShouldRenderPredicate().test(shouldRenderPredicateVariableManager); } diff --git a/backend/services/syson-services/src/main/java/org/eclipse/syson/services/ToolService.java b/backend/services/syson-services/src/main/java/org/eclipse/syson/services/ToolService.java index 5bbff3f01..2e160cc7b 100644 --- a/backend/services/syson-services/src/main/java/org/eclipse/syson/services/ToolService.java +++ b/backend/services/syson-services/src/main/java/org/eclipse/syson/services/ToolService.java @@ -41,7 +41,6 @@ import org.eclipse.sirius.components.diagrams.events.HideDiagramElementEvent; import org.eclipse.sirius.components.view.diagram.DiagramDescription; import org.eclipse.syson.services.api.ISysMLMoveElementService; -import org.eclipse.syson.sysml.AnnotatingElement; import org.eclipse.syson.sysml.Comment; import org.eclipse.syson.sysml.Documentation; import org.eclipse.syson.sysml.Element; @@ -114,7 +113,7 @@ public ToolService(IIdentityService identityService, IObjectSearchService object */ public Element expose(Element element, IEditingContext editingContext, DiagramContext diagramContext, Node selectedNode, Map convertedNodes) { - if (this.isUnsynchronized(element)) { + if (this.utilService.isUnsynchronized(element)) { final Element parentElement; if (selectedNode == null) { parentElement = this.objectSearchService.getObject(editingContext, diagramContext.diagram().getTargetObjectId()) @@ -158,7 +157,7 @@ public Element expose(Element element, IEditingContext editingContext, DiagramCo public Object getParentNode(Element element, Node selectedNode, Edge selectedEdge, DiagramContext diagramContext) { Object parentNode = null; if (selectedEdge != null) { - Node sourceNode = this.getSourceNode(selectedEdge, diagramContext.getDiagram()); + Node sourceNode = this.getSourceNode(selectedEdge, diagramContext.diagram()); if (sourceNode != null) { parentNode = this.getParentNode(element, sourceNode, diagramContext); } else { @@ -183,7 +182,7 @@ public Object getParentNode(Element element, Node selectedNode, Edge selectedEdg */ public Object getParentNode(Element element, IDiagramElement diagramElement, DiagramContext diagramContext) { Object parentNode = null; - var diagram = diagramContext.getDiagram(); + var diagram = diagramContext.diagram(); var nodes = diagram.getNodes(); var edges = diagram.getEdges(); if (nodes.contains(diagramElement)) { @@ -275,7 +274,7 @@ protected void handleUnsynchronizedElement(Element element, Element parentElemen * @return always true. */ public boolean removeFromExposedElements(Element element, Node selectedNode, IEditingContext editingContext, DiagramContext diagramContext) { - var optDiagramTargetObject = this.objectSearchService.getObject(editingContext, diagramContext.getDiagram().getTargetObjectId()); + var optDiagramTargetObject = this.objectSearchService.getObject(editingContext, diagramContext.diagram().getTargetObjectId()); if (optDiagramTargetObject.isPresent()) { var diagramTargetObject = optDiagramTargetObject.get(); if (diagramTargetObject instanceof ViewUsage viewUsage) { @@ -312,7 +311,7 @@ protected List getChildNodes(DiagramContext diagramContext, Object selecte node.getChildNodes().stream().forEach(cn -> childNodes.addAll(cn.getChildNodes())); } } else { - var diagram = diagramContext.getDiagram(); + var diagram = diagramContext.diagram(); childNodes.addAll(diagram.getNodes()); } return childNodes; @@ -342,7 +341,7 @@ protected ViewCreationRequest createView(Element element, IEditingContext editin protected ViewCreationRequest createView(Element element, String parentElementId, String descriptionId, IEditingContext editingContext, DiagramContext diagramContext, NodeContainmentKind nodeKind) { ViewCreationRequest request = null; - var diagramDescription = this.representationDescriptionSearchService.findById(editingContext, diagramContext.getDiagram().getDescriptionId()) + var diagramDescription = this.representationDescriptionSearchService.findById(editingContext, diagramContext.diagram().getDescriptionId()) .filter(org.eclipse.sirius.components.diagrams.description.DiagramDescription.class::isInstance) .map(org.eclipse.sirius.components.diagrams.description.DiagramDescription.class::cast); var nodeDescription = this.diagramDescriptionService.findDiagramElementDescriptionById(diagramDescription.get(), descriptionId) @@ -356,7 +355,7 @@ protected ViewCreationRequest createView(Element element, String parentElementId .parentElementId(parentElementId) .targetObjectId(this.identityService.getId(element)) .build(); - diagramContext.getViewCreationRequests().add(request); + diagramContext.viewCreationRequests().add(request); } return request; } @@ -383,7 +382,7 @@ protected String getParentElementId(Object graphicalElement, DiagramContext diag NodeContainmentKind.CHILD_NODE, viewCreationRequest.getTargetObjectId()); } else { - parentElementId = diagramContext.getDiagram().getId(); + parentElementId = diagramContext.diagram().getId(); } return parentElementId; } @@ -428,8 +427,8 @@ protected Optional getChildNodeDescriptionIdForRendering(Element element parentObject = this.objectSearchService.getObject(editingContext, viewCreationRequest.getTargetObjectId()).orElse(null); candidates = this.nodeDescriptionService.getChildNodeDescriptionsForRendering(element, parentObject, List.of(parentNodeDescription), convertedNodes, editingContext, diagramContext); } else { - var diagramDescription = this.representationDescriptionSearchService.findById(editingContext, diagramContext.getDiagram().getDescriptionId()); - parentObject = this.objectSearchService.getObject(editingContext, diagramContext.getDiagram().getTargetObjectId()).orElse(null); + var diagramDescription = this.representationDescriptionSearchService.findById(editingContext, diagramContext.diagram().getDescriptionId()); + parentObject = this.objectSearchService.getObject(editingContext, diagramContext.diagram().getTargetObjectId()).orElse(null); candidates = diagramDescription .filter(org.eclipse.sirius.components.diagrams.description.DiagramDescription.class::isInstance) .map(org.eclipse.sirius.components.diagrams.description.DiagramDescription.class::cast) @@ -570,13 +569,13 @@ protected void moveSubNodes(ViewCreationRequest parentViewCreationRequest, Node .parentElementId(this.getParentElementId(parentViewCreationRequest, diagramContext)) .targetObjectId(childNode.getTargetObjectId()) .build(); - diagramContext.getViewCreationRequests().add(childViewCreationRequest); + diagramContext.viewCreationRequests().add(childViewCreationRequest); this.moveSubNodes(childViewCreationRequest, childNode, diagramContext); if (childNode.getModifiers().contains(ViewModifier.Hidden)) { // Hide the new element if it was hidden before the drop, we want the new elements to look like the // dropped ones. We can't use DiagramServices here because we don't have access to the elements to hide // (only their IDs, they haven't been rendered yet). - diagramContext.getDiagramEvents().add(new HideDiagramElementEvent(Set.of(this.getParentElementId(childViewCreationRequest, diagramContext)), true)); + diagramContext.diagramEvents().add(new HideDiagramElementEvent(Set.of(this.getParentElementId(childViewCreationRequest, diagramContext)), true)); } } for (Node borderNode : parentNode.getBorderNodes()) { @@ -586,10 +585,10 @@ protected void moveSubNodes(ViewCreationRequest parentViewCreationRequest, Node .parentElementId(this.getParentElementId(parentViewCreationRequest, diagramContext)) .targetObjectId(borderNode.getTargetObjectId()) .build(); - diagramContext.getViewCreationRequests().add(childViewCreationRequest); + diagramContext.viewCreationRequests().add(childViewCreationRequest); this.moveSubNodes(childViewCreationRequest, borderNode, diagramContext); if (borderNode.getModifiers().contains(ViewModifier.Hidden)) { - diagramContext.getDiagramEvents().add(new HideDiagramElementEvent(Set.of(this.getParentElementId(childViewCreationRequest, diagramContext)), true)); + diagramContext.diagramEvents().add(new HideDiagramElementEvent(Set.of(this.getParentElementId(childViewCreationRequest, diagramContext)), true)); } } } @@ -650,28 +649,6 @@ protected boolean isExposed(Element element, ViewUsage viewUsage) { return viewUsage.getExposedElement().contains(element); } - /** - * Check if the given {@link Element} is represented by an unsynchronized node. - * - * @param element - * the given {@link Element} - * @return true if the given {@link Element} is represented by an unsynchronized node, - * false otherwise. - */ - protected boolean isUnsynchronized(Element element) { - boolean isUnsynchronized = false; - if (Objects.equals(element, this.utilService.retrieveStandardStartAction(element))) { - isUnsynchronized = true; - } else if (Objects.equals(element, this.utilService.retrieveStandardDoneAction(element))) { - isUnsynchronized = true; - } else if (element instanceof NamespaceImport) { - isUnsynchronized = true; - } else if (element instanceof AnnotatingElement) { - isUnsynchronized = true; - } - return isUnsynchronized; - } - protected void removeFromExposedElements(Node currentNode, IEditingContext editingContext, List exposed) { List childNodes = currentNode.getChildNodes(); for (Node childNode : childNodes) { diff --git a/backend/services/syson-services/src/main/java/org/eclipse/syson/services/UtilService.java b/backend/services/syson-services/src/main/java/org/eclipse/syson/services/UtilService.java index 23fa9961d..e3177d06a 100644 --- a/backend/services/syson-services/src/main/java/org/eclipse/syson/services/UtilService.java +++ b/backend/services/syson-services/src/main/java/org/eclipse/syson/services/UtilService.java @@ -34,6 +34,7 @@ import org.eclipse.syson.sysml.AcceptActionUsage; import org.eclipse.syson.sysml.ActionUsage; import org.eclipse.syson.sysml.AllocationUsage; +import org.eclipse.syson.sysml.AnnotatingElement; import org.eclipse.syson.sysml.Classifier; import org.eclipse.syson.sysml.ConjugatedPortTyping; import org.eclipse.syson.sysml.ConnectionUsage; @@ -53,6 +54,7 @@ import org.eclipse.syson.sysml.LibraryPackage; import org.eclipse.syson.sysml.Membership; import org.eclipse.syson.sysml.Namespace; +import org.eclipse.syson.sysml.NamespaceImport; import org.eclipse.syson.sysml.ObjectiveMembership; import org.eclipse.syson.sysml.Package; import org.eclipse.syson.sysml.PartDefinition; @@ -1025,6 +1027,28 @@ public long existingViewUsagesCountForRepresentationCreation(Namespace namespace return this.elementUtil.existingViewUsagesCountForRepresentationCreation(namespace); } + /** + * Check if the given {@link Element} is represented by an unsynchronized node. + * + * @param element + * the given {@link Element} + * @return true if the given {@link Element} is represented by an unsynchronized node, + * false otherwise. + */ + public boolean isUnsynchronized(Element element) { + boolean isUnsynchronized = false; + if (Objects.equals(element, this.retrieveStandardStartAction(element))) { + isUnsynchronized = true; + } else if (Objects.equals(element, this.retrieveStandardDoneAction(element))) { + isUnsynchronized = true; + } else if (element instanceof NamespaceImport) { + isUnsynchronized = true; + } else if (element instanceof AnnotatingElement) { + isUnsynchronized = true; + } + return isUnsynchronized; + } + private ReferenceUsage addConnectorEnd(ConnectorAsUsage connectorAsUsage, Feature end, Type connectorContainer) { FeatureChainComputer cmp = new FeatureChainComputer(); List sourceFeaturePath = cmp.computeShortestPath(connectorContainer, end).orElse(List.of()); diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/AnnotatingNodeDescriptionProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/AnnotatingNodeDescriptionProvider.java index 14890ec58..44dbe1d5a 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/AnnotatingNodeDescriptionProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/AnnotatingNodeDescriptionProvider.java @@ -17,7 +17,7 @@ import java.util.Objects; import org.eclipse.emf.ecore.EClass; -import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext; +import org.eclipse.sirius.components.collaborative.diagrams.DiagramContext; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.view.builder.IViewDiagramElementFinder; import org.eclipse.sirius.components.view.builder.generated.diagram.FreeFormLayoutStrategyDescriptionBuilder; @@ -78,7 +78,7 @@ public NodeDescription create() { .style(this.createNoteNodeStyle()) .userResizable(UserResizableDirection.BOTH) .synchronizationPolicy(SynchronizationPolicy.UNSYNCHRONIZED) - .preconditionExpression(AQLUtils.getSelfServiceCallExpression("showAnnotatingNode", List.of(IDiagramContext.DIAGRAM_CONTEXT, IEditingContext.EDITING_CONTEXT))) + .preconditionExpression(AQLUtils.getSelfServiceCallExpression("showAnnotatingNode", List.of(DiagramContext.DIAGRAM_CONTEXT, IEditingContext.EDITING_CONTEXT))) .build(); } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewNodeService.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewNodeService.java index 520b8dc70..5b7d24660 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewNodeService.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewNodeService.java @@ -301,7 +301,8 @@ public Element setAsView(ViewUsage viewUsage, String newViewDefinition) { public Node revealCompartment(Node node, Element targetElement, DiagramContext diagramContext, IEditingContext editingContext, Map convertedNodes) { - if (!this.needToRevealCompartment(targetElement, this.isView(targetElement, "StandardViewDefinitions::GeneralView", node, editingContext, diagramContext))) { + if (!this.utilService.isUnsynchronized(targetElement) + && !this.needToRevealCompartment(targetElement, this.isView(targetElement, "StandardViewDefinitions::GeneralView", node, editingContext, diagramContext))) { return node; } var nodeDescription = convertedNodes.values().stream() diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java index 07e13ab65..f0279c2ee 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java @@ -148,7 +148,7 @@ public Element addToExposedElements(Element element, boolean recursive, IEditing if (viewUsage != null) { var childElements = this.getChildElementsToRender(element, recursive); for (Element childElement : childElements) { - if (this.isUnsynchronized(childElement)) { + if (this.utilService.isUnsynchronized(childElement)) { this.handleUnsynchronizedElement(childElement, element, editingContext, diagramContext, selectedNode, convertedNodes); } else if (!Objects.equals(viewUsage, childElement) && !(childElement instanceof ViewUsage) && !this.isExposed(childElement, viewUsage)) { var membershipExpose = SysmlFactory.eINSTANCE.createMembershipExpose(); @@ -896,7 +896,7 @@ protected Set getChildElementsToRender(Element parentElement, boolean r if (recursive) { childElements.forEach(child -> { Set childElementsToRender = this.getChildElementsToRender(child, true); - childElementsToRender.removeIf(elt -> !this.isUnsynchronized(elt)); + childElementsToRender.removeIf(elt -> !this.utilService.isUnsynchronized(elt)); contents.addAll(childElementsToRender); }); } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/AbstractFreeFormCompartmentNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/AbstractFreeFormCompartmentNodeToolProvider.java index 197e9fc23..032d76307 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/AbstractFreeFormCompartmentNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/AbstractFreeFormCompartmentNodeToolProvider.java @@ -16,7 +16,7 @@ import java.util.Objects; import org.eclipse.emf.ecore.EClass; -import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext; +import org.eclipse.sirius.components.collaborative.diagrams.DiagramContext; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.diagrams.Node; import org.eclipse.sirius.components.view.builder.IViewDiagramElementFinder; @@ -112,12 +112,12 @@ public NodeTool create(IViewDiagramElementFinder cache) { var addToExposedElements = this.viewBuilderHelper.newChangeContext() .expression(AQLUtils.getSelfServiceCallExpression("expose", - List.of(IEditingContext.EDITING_CONTEXT, IDiagramContext.DIAGRAM_CONTEXT, Node.SELECTED_NODE, ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE))); + List.of(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT, Node.SELECTED_NODE, ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE))); var revealOperation = this.viewBuilderHelper.newChangeContext() .expression( AQLUtils.getServiceCallExpression(Node.SELECTED_NODE, "revealCompartment", - List.of("self", IDiagramContext.DIAGRAM_CONTEXT, IEditingContext.EDITING_CONTEXT, ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE))); + List.of("self", DiagramContext.DIAGRAM_CONTEXT, IEditingContext.EDITING_CONTEXT, ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE))); var creationServiceCall = this.viewBuilderHelper.newChangeContext() .expression(this.getCreationServiceCallExpression()) diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StateSubactionNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StateSubactionNodeToolProvider.java index f2b99bf96..bb5a5d0a3 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StateSubactionNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StateSubactionNodeToolProvider.java @@ -17,7 +17,7 @@ import java.util.List; import org.apache.commons.lang3.StringUtils; -import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext; +import org.eclipse.sirius.components.collaborative.diagrams.DiagramContext; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.diagrams.Node; import org.eclipse.sirius.components.view.ChangeContext; @@ -78,7 +78,7 @@ private String getNodeToolLabel() { private ChangeContext getCreateSubactionOperation() { var revealOperation = this.viewBuilderHelper.newChangeContext() .expression(AQLUtils.getServiceCallExpression(Node.SELECTED_NODE, "revealCompartment", - List.of("self", IDiagramContext.DIAGRAM_CONTEXT, IEditingContext.EDITING_CONTEXT, ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE))); + List.of("self", DiagramContext.DIAGRAM_CONTEXT, IEditingContext.EDITING_CONTEXT, ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE))); var params = new ArrayList(); if (this.isReferencing) { diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StateTransitionCompartmentNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StateTransitionCompartmentNodeToolProvider.java index 30f538ccf..c5b337902 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StateTransitionCompartmentNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StateTransitionCompartmentNodeToolProvider.java @@ -14,7 +14,7 @@ import java.util.List; -import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext; +import org.eclipse.sirius.components.collaborative.diagrams.DiagramContext; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.diagrams.Node; import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter; @@ -39,7 +39,7 @@ public StateTransitionCompartmentNodeToolProvider(boolean isParallel, boolean is @Override protected String getServiceCallExpression() { return AQLUtils.getSelfServiceCallExpression("createChildState", - List.of(IEditingContext.EDITING_CONTEXT, IDiagramContext.DIAGRAM_CONTEXT, Node.SELECTED_NODE, ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE, String.valueOf(this.isParallel), + List.of(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT, Node.SELECTED_NODE, ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE, String.valueOf(this.isParallel), String.valueOf(this.isExhibit))); } diff --git a/doc/content/modules/user-manual/pages/release-notes/2025.10.0.adoc b/doc/content/modules/user-manual/pages/release-notes/2025.10.0.adoc index c8c9bf361..9ce82c83c 100644 --- a/doc/content/modules/user-manual/pages/release-notes/2025.10.0.adoc +++ b/doc/content/modules/user-manual/pages/release-notes/2025.10.0.adoc @@ -74,6 +74,7 @@ Now it is only available on SysML model elements. - Fix library update performance and ensure it does not impact standard libraries. - Fix an issue where diagrams' edges were blinking when refreshing a diagram. - Fix drag and drop of a graphical node from the diagram background into a _Package_ graphical node. +- Fix an issue where the _action flow_ compartment was not revealed when the _New Start Action_ was executed. == Improvements