diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 88038b2e6b..bd96e662c1 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -42,6 +42,7 @@ In any case, it is strongly recommended to back up your data before proceeding w - https://github.com/eclipse-syson/syson/issues/2399[#2399] [details] Fix the _Typed by_ selection dialog so a `Usage` can only be typed by its corresponding `Definition` kind. - https://github.com/eclipse-syson/syson/issues/2407[#2407] [diagrams] Fix the nested composition edge tool label on `ConcernUsage` graphical nodes in _General View_ diagrams. It is now _Become nested Concern_ instead of _Become nested Requirement_. +- https://github.com/eclipse-syson/syson/issues/2369[#2369] [diagrams] Remove the _New Subclassification_ edge tool from `EnumerationDefinition` graphical nodes, which cannot subclassify another `EnumerationDefinition`. - https://github.com/eclipse-syson/syson/issues/2388[#2388] [search] Fix concurrent creation of SysML model search indices. - https://github.com/eclipse-syson/syson/issues/2397[#2397] [metamodel] Fix the resolution of the ends of a connector so the ends declared with the `end` keyword inside a connection body are taken into account. Following KerML, where `endFeature` is defined as the owned features having `isEnd = true`, the ends owned through a plain `FeatureMembership` are now collected as well, and not only those owned through an `EndFeatureMembership`. diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewEdgeToolSwitch.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewEdgeToolSwitch.java index 709d4ec264..a6e811e6b5 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewEdgeToolSwitch.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewEdgeToolSwitch.java @@ -178,7 +178,10 @@ public List caseDefinition(Definition object) { addAttributeAsNestedOfDefinition.forEach(nodeDesc -> edgeTools.add(this.edgeToolService.createAddAsNestedEdgeTool(nodeDesc))); edgeTools.add(this.edgeToolService.createDependencyEdgeTool(this.allNodeDescriptions)); - edgeTools.add(this.edgeToolService.createSubclassificationEdgeTool(List.of(this.nodeDescription))); + // SysML forbids an EnumerationDefinition from subclassifying another EnumerationDefinition. + if (!SysmlPackage.eINSTANCE.getEnumerationDefinition().isInstance(object)) { + edgeTools.add(this.edgeToolService.createSubclassificationEdgeTool(List.of(this.nodeDescription))); + } return edgeTools; } diff --git a/backend/views/syson-diagram-common-view/src/test/java/org/eclipse/syson/diagram/common/view/services/ViewEdgeToolSwitchTest.java b/backend/views/syson-diagram-common-view/src/test/java/org/eclipse/syson/diagram/common/view/services/ViewEdgeToolSwitchTest.java new file mode 100644 index 0000000000..4a369e0535 --- /dev/null +++ b/backend/views/syson-diagram-common-view/src/test/java/org/eclipse/syson/diagram/common/view/services/ViewEdgeToolSwitchTest.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2026 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.diagram.common.view.services; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.sirius.components.view.builder.generated.diagram.DiagramBuilders; +import org.eclipse.sirius.components.view.diagram.EdgeTool; +import org.eclipse.sirius.components.view.diagram.NodeDescription; +import org.eclipse.syson.sysml.SysmlPackage; +import org.eclipse.syson.util.DescriptionNameGenerator; +import org.eclipse.syson.util.SysMLMetamodelHelper; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +/** + * Tests for {@link ViewEdgeToolSwitch}. + * + * @author arichard + */ +public class ViewEdgeToolSwitchTest { + + private final DescriptionNameGenerator descriptionNameGenerator = new DescriptionNameGenerator("test"); + + @Test + @DisplayName("GIVEN an EnumerationDefinition, WHEN its edge tools are created, THEN the New Subclassification tool is not available") + void enumerationDefinitionDoesNotProvideSubclassificationEdgeTool() { + var nodeDescription = this.createNodeDescription(SysmlPackage.eINSTANCE.getEnumerationDefinition()); + + var edgeTools = this.createEdgeToolSwitch(nodeDescription).doSwitch(SysmlPackage.eINSTANCE.getEnumerationDefinition()); + + assertThat(edgeTools) + .extracting(EdgeTool::getName) + .doesNotContain(this.descriptionNameGenerator.getCreationToolName(SysmlPackage.eINSTANCE.getSubclassification())); + } + + @Test + @DisplayName("GIVEN a PartDefinition, WHEN its edge tools are created, THEN the New Subclassification tool is available") + void partDefinitionProvidesSubclassificationEdgeTool() { + var nodeDescription = this.createNodeDescription(SysmlPackage.eINSTANCE.getPartDefinition()); + + var edgeTools = this.createEdgeToolSwitch(nodeDescription).doSwitch(SysmlPackage.eINSTANCE.getPartDefinition()); + + assertThat(edgeTools) + .extracting(EdgeTool::getName) + .contains(this.descriptionNameGenerator.getCreationToolName(SysmlPackage.eINSTANCE.getSubclassification())); + } + + /** + * Creates the edge tool switch to test with the given node description. + * + * @param nodeDescription + * the node description represented by the switch + * @return the configured edge tool switch + */ + private ViewEdgeToolSwitch createEdgeToolSwitch(NodeDescription nodeDescription) { + return new ViewEdgeToolSwitch(nodeDescription, List.of(nodeDescription), this.descriptionNameGenerator); + } + + /** + * Creates a minimal node description for an EClass. + * + * @param eClass + * the EClass represented by the node description + * @return the node description for the given EClass + */ + private NodeDescription createNodeDescription(EClass eClass) { + return new DiagramBuilders().newNodeDescription() + .name(eClass.getName()) + .domainType(SysMLMetamodelHelper.buildQualifiedName(eClass)) + .build(); + } +} diff --git a/doc/content/modules/user-manual/pages/release-notes/2026.9.0.adoc b/doc/content/modules/user-manual/pages/release-notes/2026.9.0.adoc index ebd075e67a..fb2adfcaa6 100644 --- a/doc/content/modules/user-manual/pages/release-notes/2026.9.0.adoc +++ b/doc/content/modules/user-manual/pages/release-notes/2026.9.0.adoc @@ -86,6 +86,7 @@ It is now _Become nested Concern_ instead of _Become nested Requirement_. ** Fix the ends of the connections whose ends are declared with the `end` keyword inside the body of the connection, which were not resolved. Those connections were missing their source and their target, and were therefore never displayed as edges. ** Replace the name of the _New Perform action_ tool to _New Perform Action_ to be consistent with other tools. +** Remove the _New Subclassification_ edge tool from `EnumerationDefinition` graphical nodes, which cannot subclassify another `EnumerationDefinition`. * In all views: