Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Now it has been fixed in Sirius Web 2025.8.4, `SysONUpdateLibraryExecutor` has b
- 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.
- https://github.com/eclipse-syson/syson/issues/1547[#1547] [diagrams] Fix an issue where the _Delete from diagram_ action did nothing on elements inside a _Package_ in diagrams.

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.syson.application.controllers.diagrams.general.view;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.sirius.components.diagrams.tests.DiagramEventPayloadConsumer.assertRefreshedDiagramThat;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.time.Duration;
Expand All @@ -36,6 +37,7 @@
import org.eclipse.sirius.components.diagrams.Diagram;
import org.eclipse.sirius.components.diagrams.Node;
import org.eclipse.sirius.components.diagrams.tests.graphql.LayoutDiagramMutationRunner;
import org.eclipse.sirius.components.diagrams.tests.navigation.DiagramNavigator;
import org.eclipse.sirius.components.graphql.tests.ExecuteEditingContextFunctionInput;
import org.eclipse.sirius.components.graphql.tests.ExecuteEditingContextFunctionRunner;
import org.eclipse.sirius.components.graphql.tests.ExecuteEditingContextFunctionSuccessPayload;
Expand Down Expand Up @@ -213,7 +215,7 @@ public void addExistingElementsToolShouldUpdateExposedElements() {
this.verifier.then(semanticChecker);
}

@DisplayName("GIVEN a GV diagram on a ViewUsage, WHEN Add existing element(s) (recursive) tool is executed, THEN a the ViewUsage#exposedElements is updated with partA and partB")
@DisplayName("GIVEN a GV diagram on a ViewUsage, WHEN Add existing element(s) (recursive) tool is executed, THEN the ViewUsage#exposedElements is updated with partA and partB")
@Sql(scripts = { ViewUsageExposedElementsTestProjectData.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))
Expand Down Expand Up @@ -303,4 +305,47 @@ public void updateExposedElementsShouldUpdateTheDiagram() {

this.diagramCheckerService.checkDiagram(diagramChecker, this.diagram, this.verifier);
}

@DisplayName("GIVEN a GV diagram on a ViewUsage, WHEN an element is created inside a Package, THEN the element should only be visible inside the Package")
@Sql(scripts = { ViewUsageExposedElementsTestProjectData.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 exposePackageChildShouldDisplayChildOnlyinPAckage() {
var newPackageToolId = this.diagramDescriptionIdProvider.getDiagramCreationToolId("New Package");
assertThat(newPackageToolId).as("The tool 'New Package' should exist on the diagram").isNotNull();
var newInterfaceToolId = this.diagramDescriptionIdProvider.getNodeCreationToolId(this.descriptionNameGenerator.getNodeName(SysmlPackage.eINSTANCE.getPackage()), "New Interface");
assertThat(newInterfaceToolId).as("The tool 'New Interface' should exist on the Package").isNotNull();

Runnable newPackageTool = () -> this.toolTester.invokeTool(ViewUsageExposedElementsTestProjectData.EDITING_CONTEXT_ID, this.diagram, newPackageToolId);

var packageNodeId = new AtomicReference<String>();

Consumer<Object> updatedDiagramWithPackage = assertRefreshedDiagramThat(diag -> {
int diagramRootNodesCount = diag.getNodes().size();
assertThat(diagramRootNodesCount).isEqualTo(1);
var packageNode = new DiagramNavigator(diag).nodeWithLabel("Package1").getNode();
assertThat(packageNode).isNotNull();
assertThat(packageNode.getChildNodes()).hasSize(0);
packageNodeId.set(packageNode.getId());
});

Runnable newInterfaceTool = () -> this.toolTester.invokeTool(ViewUsageExposedElementsTestProjectData.EDITING_CONTEXT_ID, this.diagram.get().getId(), packageNodeId.get(), newInterfaceToolId,
List.of());

Consumer<Object> updatedDiagramWithInterface = assertRefreshedDiagramThat(diag -> {
int diagramRootNodesCount = diag.getNodes().size();
assertThat(diagramRootNodesCount).isEqualTo(1);
var packageNode = new DiagramNavigator(diag).nodeWithLabel("Package1").getNode();
assertThat(packageNode.getChildNodes()).hasSize(1);
var interfaceNode = new DiagramNavigator(diag).nodeWithLabel("Package1").childNodeWithLabel("\u00ABinterface\u00BB\ninterface1").getNode();
assertThat(interfaceNode).isNotNull();
});

this.verifier
.then(newPackageTool)
.consumeNextWith(updatedDiagramWithPackage)
.then(newInterfaceTool)
.consumeNextWith(updatedDiagramWithInterface);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ public Element expose(Element element, IEditingContext editingContext, DiagramCo
var membershipExpose = SysmlFactory.eINSTANCE.createMembershipExpose();
membershipExpose.setImportedMembership(element.getOwningMembership());
viewUsage.getOwnedRelationship().add(membershipExpose);
if (element instanceof Package) {
membershipExpose.setIsRecursive(true);
}
}
}
return element;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.eclipse.syson.sysml.Type;
import org.eclipse.syson.sysml.ViewDefinition;
import org.eclipse.syson.sysml.ViewUsage;
import org.eclipse.syson.sysml.helper.EMFUtils;
import org.eclipse.syson.sysml.util.ElementUtil;
import org.eclipse.syson.util.NodeFinder;
import org.slf4j.Logger;
Expand Down Expand Up @@ -512,21 +513,21 @@ public boolean showAnnotatingNode(Element element, DiagramContext diagramContext
*/
protected Set<Element> getDirectExposedElements(ViewUsage viewUsage) {
var directExposedElements = new HashSet<Element>();
List<Expose> exposes = viewUsage.getOwnedRelationship().stream()
List<Expose> exposedElements = viewUsage.getOwnedRelationship().stream()
.filter(Expose.class::isInstance)
.map(Expose.class::cast)
.toList();
for (Expose expose : exposes) {
Element importedElement = expose.getImportedElement();
for (Expose exposedElement : exposedElements) {
Element importedElement = exposedElement.getImportedElement();
if (importedElement instanceof Package) {
directExposedElements.add(importedElement);
} else if (expose instanceof MembershipExpose membershipExpose) {
} else if (exposedElement instanceof MembershipExpose membershipExpose) {
var importedMembership = membershipExpose.getImportedMembership();
if (importedMembership != null) {
var memberElement = importedMembership.getMemberElement();
if (memberElement != null) {
if (memberElement != null && !this.isChildOfExposedPackage(memberElement, exposedElements)) {
directExposedElements.add(memberElement);
if (expose.isIsRecursive()) {
if (exposedElement.isIsRecursive()) {
directExposedElements.addAll(this.getRecursiveContents(memberElement));
}
}
Expand All @@ -537,6 +538,29 @@ protected Set<Element> getDirectExposedElements(ViewUsage viewUsage) {
return directExposedElements;
}

/**
* Check if the given {@link Element} is a child of an exposed Package. In this case, we don't want to display it on
* the diagram background, or as a ViewUsage child node. It will be displayed inside another node.
*
* @param element
* the element that could be a child of an exposed element
* @param exposedElements
* the list of exposed elements
* @return <code>true</code> if the given {@link Element} is a child of an exposed element, <code>false</code>
* otherwise.
*/
protected boolean isChildOfExposedPackage(Element element, List<Expose> exposedElements) {
boolean isChildOfExposedElement = false;
for (Expose exposedElement : exposedElements) {
Element importedElement = exposedElement.getImportedElement();
if (importedElement instanceof Package && !Objects.equals(element, importedElement) && EMFUtils.isAncestor(importedElement, element)) {
isChildOfExposedElement = true;
break;
}
}
return isChildOfExposedElement;
}

protected List<Element> getRecursiveContents(Element element) {
var contents = new ArrayList<Element>();
var ownedElements = element.getOwnedElement().stream().filter(Objects::nonNull).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public Element addToExposedElements(Element element, boolean recursive, IEditing
var membershipExpose = SysmlFactory.eINSTANCE.createMembershipExpose();
membershipExpose.setImportedMembership(childElement.getOwningMembership());
viewUsage.getOwnedRelationship().add(membershipExpose);
if (childElement instanceof Package || recursive) {
if (recursive) {
membershipExpose.setIsRecursive(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Now it is only available on SysML model elements.
- 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.
- Fix an issue where the _Delete from diagram_ action did nothing on elements inside a _Package_ in diagrams.

== Improvements

Expand Down
Loading