Skip to content

Commit 0e18073

Browse files
committed
[1938] Fix Flow creation between parameters
Bug: #1938 Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
1 parent ac0a5fe commit 0e18073

4 files changed

Lines changed: 80 additions & 3 deletions

File tree

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ It now follows the same rule than all other graphical node: if a compartment tha
9797
Now the _end_ keyword is not displayed anymore in the label of these graphical nodes, and the direct edit only allows to edit the name of the end instead of the full label which was confusing for users.
9898
- https://github.com/eclipse-syson/syson/issues/2054[#2054] [diagrams] Fix an error when invoking the tools _New Start Action_ or _New Done Action_ from inside a package named `Actions`.
9999
- https://github.com/eclipse-syson/syson/issues/2057[#2057] [diagrams] Fix the support for removing the multiplicity using the direct edit.
100+
- https://github.com/eclipse-syson/syson/issues/1938[#1938] [diagrams] Fix an issue where the _New Flow (flow)_ tool between two parameters was broken.
100101

101102
=== Improvements
102103

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVFlowUsageTests.java

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.eclipse.syson.application.controllers.diagrams.checkers.CheckDiagramElementCount;
5656
import org.eclipse.syson.application.controllers.diagrams.testers.EdgeCreationTester;
5757
import org.eclipse.syson.application.controllers.diagrams.testers.EdgeReconnectionTester;
58+
import org.eclipse.syson.application.controllers.diagrams.testers.ToolTester;
5859
import org.eclipse.syson.application.data.GeneralViewFlowConnectionItemUsagesProjectData;
5960
import org.eclipse.syson.application.data.GeneralViewFlowUsageProjectData;
6061
import org.eclipse.syson.services.SemanticRunnableFactory;
@@ -69,6 +70,7 @@
6970
import org.eclipse.syson.sysml.FlowUsage;
7071
import org.eclipse.syson.sysml.PayloadFeature;
7172
import org.eclipse.syson.sysml.SysmlPackage;
73+
import org.eclipse.syson.sysml.helper.LabelConstants;
7274
import org.eclipse.syson.util.IDescriptionNameGenerator;
7375
import org.eclipse.syson.util.SysONRepresentationDescriptionIdentifiers;
7476
import org.junit.jupiter.api.BeforeEach;
@@ -131,6 +133,9 @@ public class GVFlowUsageTests extends AbstractIntegrationTests {
131133
@Autowired
132134
private IIdentityService identityService;
133135

136+
@Autowired
137+
private ToolTester toolTester;
138+
134139
private SemanticCheckerService semanticCheckerService;
135140

136141
private Flux<DiagramRefreshedEventPayload> givenSubscriptionToDiagram() {
@@ -195,6 +200,73 @@ public void checkFlowConnectionCreation() {
195200
.verify(Duration.ofSeconds(10));
196201
}
197202

203+
@DisplayName("GIVEN a SysML Project with ActionUsages with parameters (ReferenceUsages), WHEN creating a FlowUsage between parameters, THEN an edge should be displayed to represent that new flow")
204+
@GivenSysONServer({ GeneralViewFlowConnectionItemUsagesProjectData.SCRIPT_PATH })
205+
@Test
206+
public void checkFlowConnectionBetweenParametersCreation() {
207+
var flux = this.givenSubscriptionToDiagram();
208+
209+
AtomicReference<Diagram> diagram = new AtomicReference<>();
210+
Consumer<Object> initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set);
211+
212+
var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewFlowConnectionItemUsagesProjectData.EDITING_CONTEXT_ID,
213+
SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID);
214+
var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider);
215+
216+
var parameterCreationToolId = diagramDescriptionIdProvider.getNodeToolId(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getActionUsage()), "New Parameter In");
217+
var flowCreationToolId = diagramDescriptionIdProvider.getEdgeCreationToolId(this.descriptionNameGenerator.getBorderNodeName(SysmlPackage.eINSTANCE.getReferenceUsage()), "New Flow (flow)");
218+
219+
Runnable parameterOnAction1CreationTool = () -> this.toolTester.invokeTool(GeneralViewFlowConnectionItemUsagesProjectData.EDITING_CONTEXT_ID,
220+
GeneralViewFlowConnectionItemUsagesProjectData.GraphicalIds.DIAGRAM_ID,
221+
GeneralViewFlowConnectionItemUsagesProjectData.GraphicalIds.ACTION_USAGE_1_ID, parameterCreationToolId, List.of());
222+
223+
var parameterOnAction1BorderNodeId = new AtomicReference<String>();
224+
Consumer<Object> diagramContentConsumerAfterNewParameterOnAction1 = assertRefreshedDiagramThat(newDiagram -> {
225+
var parameterOnAction1BorderNode = new DiagramNavigator(newDiagram).nodeWithLabel(LabelConstants.OPEN_QUOTE + "action" + LabelConstants.CLOSE_QUOTE + LabelConstants.CR + "action1")
226+
.getNode().getBorderNodes().stream().filter(bn -> bn.getOutsideLabels().get(0).text().equals("parameter1")).findFirst().orElseThrow();
227+
parameterOnAction1BorderNodeId.set(parameterOnAction1BorderNode.getId());
228+
});
229+
230+
Runnable parameterOnAction2CreationTool = () -> this.toolTester.invokeTool(GeneralViewFlowConnectionItemUsagesProjectData.EDITING_CONTEXT_ID,
231+
GeneralViewFlowConnectionItemUsagesProjectData.GraphicalIds.DIAGRAM_ID,
232+
GeneralViewFlowConnectionItemUsagesProjectData.GraphicalIds.ACTION_USAGE_2_ID, parameterCreationToolId, List.of());
233+
234+
var parameterOnAction2BorderNodeId = new AtomicReference<String>();
235+
Consumer<Object> diagramContentConsumerAfterNewParameterOnAction2 = assertRefreshedDiagramThat(newDiagram -> {
236+
var parameterOnAction2BorderNode = new DiagramNavigator(newDiagram).nodeWithLabel(LabelConstants.OPEN_QUOTE + "action" + LabelConstants.CLOSE_QUOTE + LabelConstants.CR + "action2")
237+
.getNode().getBorderNodes().stream().filter(bn -> bn.getOutsideLabels().get(0).text().equals("parameter1")).findFirst().orElseThrow();
238+
parameterOnAction2BorderNodeId.set(parameterOnAction2BorderNode.getId());
239+
});
240+
241+
Runnable flowCreationTool = () -> this.edgeCreationTester.createEdgeUsingNodeId(GeneralViewFlowConnectionItemUsagesProjectData.EDITING_CONTEXT_ID,
242+
diagram,
243+
parameterOnAction1BorderNodeId.get(),
244+
parameterOnAction2BorderNodeId.get(),
245+
flowCreationToolId);
246+
247+
AtomicReference<String> newFlow = new AtomicReference<>();
248+
Consumer<Object> diagramCheck = assertRefreshedDiagramThat(newDiagram -> {
249+
var initialDiagram = diagram.get();
250+
assertThat(this.diagramComparator.newEdges(initialDiagram, newDiagram)).hasSize(1);
251+
Edge newEdge = this.diagramComparator.newEdges(initialDiagram, newDiagram).get(0);
252+
newFlow.set(newEdge.getTargetObjectId());
253+
assertThat(newEdge).hasSourceId(parameterOnAction1BorderNodeId.get());
254+
assertThat(newEdge).hasTargetId(parameterOnAction2BorderNodeId.get());
255+
assertThat(newEdge.getStyle()).hasTargetArrow(ArrowStyle.InputFillClosedArrow);
256+
});
257+
258+
StepVerifier.create(flux)
259+
.consumeNextWith(initialDiagramContentConsumer)
260+
.then(parameterOnAction1CreationTool)
261+
.consumeNextWith(diagramContentConsumerAfterNewParameterOnAction1)
262+
.then(parameterOnAction2CreationTool)
263+
.consumeNextWith(diagramContentConsumerAfterNewParameterOnAction2)
264+
.then(flowCreationTool)
265+
.consumeNextWith(diagramCheck)
266+
.thenCancel()
267+
.verify(Duration.ofSeconds(10));
268+
}
269+
198270
@DisplayName("GIVEN a SysML Project with ItemUsages on ActionUsage, WHEN creating a BindingConnectorAsUsage between them, THEN an edge should be displayed to represent that new binding")
199271
@GivenSysONServer({ GeneralViewFlowConnectionItemUsagesProjectData.SCRIPT_PATH })
200272
@Test

backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/nodes/ReferenceUsageBorderNodeDescriptionProvider.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ protected EdgeTool createBindingConnectorAsUsageEdgeTool(List<NodeDescription> t
177177

178178
var body = this.viewBuilderHelper.newChangeContext()
179179
.expression(ServiceMethod.of5(DiagramMutationAQLService::createBindingConnectorAsUsage)
180-
.aql(EdgeDescription.SEMANTIC_EDGE_SOURCE, EdgeDescription.SEMANTIC_EDGE_TARGET,
180+
.aql(EdgeDescription.SEMANTIC_EDGE_SOURCE,
181+
EdgeDescription.SEMANTIC_EDGE_TARGET,
181182
EdgeDescription.EDGE_SOURCE,
182183
EdgeDescription.EDGE_TARGET,
183184
IEditingContext.EDITING_CONTEXT,
@@ -196,9 +197,11 @@ protected EdgeTool createFlowUsageEdgeTool(List<NodeDescription> targetElementDe
196197

197198
var body = this.viewBuilderHelper.newChangeContext()
198199
.expression(ServiceMethod.of5(DiagramMutationAQLService::createFlowUsage)
199-
.aqlSelf(EdgeDescription.SEMANTIC_EDGE_TARGET,
200+
.aql(EdgeDescription.SEMANTIC_EDGE_SOURCE,
201+
EdgeDescription.SEMANTIC_EDGE_TARGET,
200202
EdgeDescription.EDGE_SOURCE,
201-
EdgeDescription.EDGE_TARGET, IEditingContext.EDITING_CONTEXT,
203+
EdgeDescription.EDGE_TARGET,
204+
IEditingContext.EDITING_CONTEXT,
202205
DiagramContext.DIAGRAM_CONTEXT));
203206

204207
return builder

doc/content/modules/user-manual/pages/release-notes/2026.3.0.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Now the _end_ keyword is not displayed anymore in the label of these graphical n
3535
** Fix an error when invoking the tools _New Start Action_ or _New Done Action_ from inside a package named `Actions`.
3636
** Fix the support for removing the multiplicity using the direct edit.
3737
+ During the direct edit, typing `[]` will remove the multiplicity if it exists, as it is supposed to do.
38+
** Fix an issue where the _New Flow (flow)_ tool between two parameters was broken.
3839

3940
* In textual import/export:
4041

0 commit comments

Comments
 (0)