Skip to content

Commit 8b47e19

Browse files
committed
[2046] Fix ReferenceUsage tool on Package graphical node
Bug: #2046 Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
1 parent e4c795d commit 8b47e19

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ For example `ViewUsage` elements are no longer rendered in _parts_ compartments.
9191
- https://github.com/eclipse-syson/syson/issues/2031[#2031] [diagrams] Fix an issue where it was not possible to drag and drop a `LibraryPackage` from the _Explorer_ to a diagram.
9292
- https://github.com/eclipse-syson/syson/issues/2050[#2050] [diagrams] Fix an issue where creating a `PerformActionUsage` from the `ActionUsage` graphical node (or any other graphical node that allows to create it) was displaying it in the diagram background and its compartments every time.
9393
It now follows the same rule than all other graphical node: if a compartment that can display the new `PerformActionUsage` is displayed, then the new `PerformActionUsage` is displayed in this compartment, otherwise it is displayed in the diagram background.
94+
- https://github.com/eclipse-syson/syson/issues/2046[#2046] [diagrams] Fix an issue where the creation of a `RequirementUsage` from a `Package` graphical node was not revealing it.
9495

9596
=== Improvements
9697

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,4 +431,53 @@ public void testCreateItemInSubPackage() {
431431
.thenCancel()
432432
.verify(Duration.ofSeconds(10));
433433
}
434+
435+
@DisplayName("GIVEN a diagram with a Package node, WHEN a ReferenceUsage node is created, THEN the ReferenceUsage node is only visible inside the Package")
436+
@GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH })
437+
@Test
438+
public void testCreateReferenceInPackage() {
439+
var flux = this.givenSubscriptionToDiagram();
440+
441+
var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID,
442+
SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID);
443+
var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider);
444+
445+
var newReferenceToolId = diagramDescriptionIdProvider.getNodeToolId(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getPackage()), "New Reference");
446+
assertThat(newReferenceToolId).as("The tool 'New Reference' should exist on the Package").isNotNull();
447+
448+
var diagramId = new AtomicReference<String>();
449+
var packageNodeId = new AtomicReference<String>();
450+
451+
Consumer<Object> initialDiagramContentConsumer = assertRefreshedDiagramThat(diag -> {
452+
diagramId.set(diag.getId());
453+
454+
var packageNode = new DiagramNavigator(diag).nodeWithLabel(PACKAGE).getNode();
455+
packageNodeId.set(packageNode.getId());
456+
457+
assertThat(packageNode.getChildNodes()).hasSize(0);
458+
459+
assertThat(new DiagramNavigator(diag).findDiagramEdgeCount()).isEqualTo(3);
460+
});
461+
462+
Runnable newReferenceTool = () -> this.toolTester.invokeTool(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, diagramId.get(), packageNodeId.get(), newReferenceToolId,
463+
List.of());
464+
465+
Consumer<Object> updatedDiagramContentConsumerAfterNewPart = assertRefreshedDiagramThat(diag -> {
466+
var packageNode = new DiagramNavigator(diag).nodeWithLabel(PACKAGE).getNode();
467+
assertThat(packageNode.getChildNodes()).hasSize(1);
468+
469+
var referenceUsageNode = new DiagramNavigator(diag)
470+
.nodeWithLabel(LabelConstants.OPEN_QUOTE + "ref reference" + LabelConstants.CLOSE_QUOTE + LabelConstants.CR + "reference1").getNode();
471+
assertThat(referenceUsageNode).isNotNull();
472+
473+
assertThat(new DiagramNavigator(diag).findDiagramEdgeCount()).isEqualTo(3);
474+
});
475+
476+
StepVerifier.create(flux)
477+
.consumeNextWith(initialDiagramContentConsumer)
478+
.then(newReferenceTool)
479+
.consumeNextWith(updatedDiagramContentConsumerAfterNewPart)
480+
.thenCancel()
481+
.verify(Duration.ofSeconds(10));
482+
}
434483
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ private static Stream<Arguments> topNodeParameters() {
169169
Arguments.of(SysmlPackage.eINSTANCE.getPartUsage(), 11, 0, 0, 0, ViewConstants.DEFAULT_USAGE_NODE_HEIGHT, ViewConstants.DEFAULT_USAGE_NODE_WIDTH),
170170
Arguments.of(SysmlPackage.eINSTANCE.getPortDefinition(), 5, 0, 0, 0, ViewConstants.DEFAULT_DEFINITION_NODE_HEIGHT, ViewConstants.DEFAULT_DEFINITION_NODE_WIDTH),
171171
Arguments.of(SysmlPackage.eINSTANCE.getPortUsage(), 5, 0, 0, 0, ViewConstants.DEFAULT_USAGE_NODE_HEIGHT, ViewConstants.DEFAULT_USAGE_NODE_WIDTH),
172+
Arguments.of(SysmlPackage.eINSTANCE.getReferenceUsage(), 0, 0, 0, 0, ViewConstants.DEFAULT_USAGE_NODE_HEIGHT, ViewConstants.DEFAULT_USAGE_NODE_WIDTH),
172173
Arguments.of(SysmlPackage.eINSTANCE.getRequirementDefinition(), 8, 0, 0, 0, ViewConstants.DEFAULT_DEFINITION_NODE_HEIGHT, ViewConstants.DEFAULT_DEFINITION_NODE_WIDTH),
173174
Arguments.of(SysmlPackage.eINSTANCE.getRequirementUsage(), 8, 0, 0, 0, ViewConstants.DEFAULT_USAGE_NODE_HEIGHT, ViewConstants.DEFAULT_USAGE_NODE_WIDTH),
174175
Arguments.of(SysmlPackage.eINSTANCE.getUseCaseDefinition(), 5, 0, 0, 0, ViewConstants.DEFAULT_DEFINITION_NODE_HEIGHT, ViewConstants.DEFAULT_DEFINITION_NODE_WIDTH),

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2023, 2025 Obeo.
2+
* Copyright (c) 2023, 2026 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -50,6 +50,8 @@ protected List<NodeDescription> getReusedChildren(IViewDiagramElementFinder cach
5050
SDVDiagramDescriptionProvider.ANNOTATINGS.forEach(annotating -> cache.getNodeDescription(this.descriptionNameGenerator.getNodeName(annotating)).ifPresent(reusedChildren::add));
5151
cache.getNodeDescription(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getPackage())).ifPresent(reusedChildren::add);
5252
cache.getNodeDescription(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getNamespaceImport())).ifPresent(reusedChildren::add);
53+
cache.getNodeDescription(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getReferenceUsage())).ifPresent(reusedChildren::add);
54+
5355
return reusedChildren;
5456
}
5557

@@ -62,6 +64,7 @@ protected List<NodeDescription> getDroppableNodes(IViewDiagramElementFinder cach
6264
SDVDiagramDescriptionProvider.ANNOTATINGS.forEach(annotating -> cache.getNodeDescription(this.descriptionNameGenerator.getNodeName(annotating)).ifPresent(droppableNodes::add));
6365
cache.getNodeDescription(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getPackage())).ifPresent(droppableNodes::add);
6466
cache.getNodeDescription(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getNamespaceImport())).ifPresent(droppableNodes::add);
67+
cache.getNodeDescription(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getReferenceUsage())).ifPresent(droppableNodes::add);
6568

6669
return droppableNodes;
6770
}
@@ -75,6 +78,8 @@ protected List<NodeDescription> getAllNodeDescriptions(IViewDiagramElementFinder
7578
SDVDiagramDescriptionProvider.ANNOTATINGS.forEach(annotating -> cache.getNodeDescription(this.descriptionNameGenerator.getNodeName(annotating)).ifPresent(allNodes::add));
7679
cache.getNodeDescription(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getPackage())).ifPresent(allNodes::add);
7780
cache.getNodeDescription(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getNamespaceImport())).ifPresent(allNodes::add);
81+
cache.getNodeDescription(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getReferenceUsage())).ifPresent(allNodes::add);
82+
7883
return allNodes;
7984
}
8085

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
@@ -28,6 +28,7 @@ They can also add their own SysML-based validation rules by returning additional
2828
** Fix an issue where it was not possible to drag and drop a `LibraryPackage` from the _Explorer_ to a diagram.
2929
** Fix an issue where creating a `PerformActionUsage` from the `ActionUsage` graphical node (or any other graphical node that allows to create it) was displaying it in the diagram background and its compartments every time.
3030
It now follows the same rule than all other graphical node: if a compartment that can display the new `PerformActionUsage` is displayed, then the new `PerformActionUsage` is displayed in this compartment, otherwise it is displayed in the diagram background.
31+
** Fix an issue where the creation of a `RequirementUsage` from a `Package` graphical node was not revealing it.
3132

3233
* In textual import/export:
3334

0 commit comments

Comments
 (0)