diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index a553de212..24705ec14 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -103,6 +103,7 @@ Now the _end_ keyword is not displayed anymore in the label of these graphical n - https://github.com/eclipse-syson/syson/issues/2059[#2059] [diagrams] Fix an issue where the _Add existing elements_ tool was not working correctly on the _action flow_ compartment of `ActionUsage` graphical nodes. - https://github.com/eclipse-syson/syson/issues/2043[#2043] [explorer] Prevent user libraries from being moved to the root of the project when a child is created in it. - https://github.com/eclipse-syson/syson/issues/2056[#2056] [diagams] Fix the user feedback when dropping an `Element` which is already exposed on a diagram. +- https://github.com/eclipse-syson/syson/issues/2048[#2048] [diagrams] Fix an issue where the non-empty compartments of graphical nodes were being displayed when executing the _Add existing elements_ tool. === Improvements diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVAddExistingElementsTests.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVAddExistingElementsTests.java index 2789a75dd..145d40fb0 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVAddExistingElementsTests.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVAddExistingElementsTests.java @@ -104,7 +104,6 @@ private Flux givenSubscriptionToDiagram() { return this.givenDiagramSubscription.subscribe(diagramEventInput); } - @BeforeEach public void setUp() { this.givenInitialServerState.initialize(); @@ -123,10 +122,9 @@ public void addExistingElementsOnDiagram() { Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); - String creationToolId = diagramDescriptionIdProvider.getDiagramCreationToolId("Add existing elements"); - assertThat(creationToolId).as("The tool 'Add existing elements' should exist on the diagram").isNotNull(); + String addExistingElementsToolId = diagramDescriptionIdProvider.getDiagramCreationToolId("Add existing elements"); - Runnable nodeCreationRunner = () -> this.nodeCreationTester.invokeTool(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID, diagram, creationToolId); + Runnable nodeCreationRunner = () -> this.nodeCreationTester.invokeTool(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID, diagram, addExistingElementsToolId); Consumer updatedDiagramConsumer = assertRefreshedDiagramThat(newDiagram -> { assertThat(newDiagram.getNodes()).as("3 nodes should be visible on the diagram").hasSize(4); @@ -147,7 +145,6 @@ public void addExistingElementsOnDiagram() { .consumeNextWith(updatedDiagramConsumer) .thenCancel() .verify(Duration.ofSeconds(10)); - } @GivenSysONServer({ GeneralViewAddExistingElementsTestProjectData.SCRIPT_PATH }) @@ -164,15 +161,13 @@ public void addExistingElementsRecursiveOnDiagram() { Consumer initialDiagramContentConsumer = assertRefreshedDiagramThat(diagram::set); String addExistingElementToolId = diagramDescriptionIdProvider.getDiagramCreationToolId("Add existing elements (recursive)"); - assertThat(addExistingElementToolId).as("The tool 'Add existing elements (recursive)' should exist on the diagram").isNotNull(); Runnable addExistingElementTool = () -> this.nodeCreationTester.invokeTool(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID, diagram, addExistingElementToolId); Consumer updatedDiagramConsumer = assertRefreshedDiagramThat(newDiagram -> { - assertThat(newDiagram.getNodes()).as("6 nodes should be visible on the diagram").hasSize(7); + assertThat(newDiagram.getNodes()).as("7 root nodes should be visible on the diagram").hasSize(7); assertThat(newDiagram.getEdges().stream().filter(e -> ViewModifier.Normal.equals(e.getState())).toList()) - .as("3 edges should be visible on the diagram") - .hasSize(3) + .as("3 edges should be visible on the diagram").hasSize(3) .as("The diagram should contain a composite edge between part2 and part1") .anyMatch(edge -> edge.getTargetObjectLabel().equals(PART1)) .as("The diagram should contain a composite edge between action1 and action2") @@ -340,16 +335,8 @@ private void checkRequirementUsage(Diagram newDiagram) { assertThat(optRequirementNode).isPresent(); assertThat(optRequirementNode.get().getChildNodes()) - .as("Node RequirementUsage should contain 6 children") - .hasSize(8); - - var requirementDocCompartment = this.getCompartment(optRequirementNode.get(), "doc"); - assertThat(requirementDocCompartment).isPresent(); - assertThat(requirementDocCompartment.get()) - .as("The doc compartment should be visible") - .matches(node -> !node.getModifiers().contains(ViewModifier.Hidden)) - .as("The doc compartment should contain a document item") - .matches(node -> node.getChildNodes().size() == 1); + .as("Node RequirementUsage should contain 8 hidden compartment children").hasSize(8) + .allMatch(node -> node.getModifiers().contains(ViewModifier.Hidden)); } private Optional getCompartment(Node node, String compartmentName) { diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVDropFromExplorerVisibilityTests.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVDropFromExplorerVisibilityTests.java index a66a243c5..60d36c351 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVDropFromExplorerVisibilityTests.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVDropFromExplorerVisibilityTests.java @@ -98,7 +98,7 @@ public void dropPartFromTheExplorer() { diagramTargetId.set(diagram.getTargetObjectId()); diagramId.set(diagram.getId()); var partNode = new DiagramNavigator(diagram).nodeWithLabel(LabelConstants.OPEN_QUOTE + "part" + LabelConstants.CLOSE_QUOTE + LabelConstants.CR + "p1").getNode(); - assertThat(partNode.getChildNodes().stream().filter(node -> node.getModifiers().contains(ViewModifier.Hidden))).hasSize(9); + assertThat(partNode.getChildNodes().stream().filter(node -> node.getModifiers().contains(ViewModifier.Hidden))).hasSize(10); partNodeSemanticId.set(partNode.getTargetObjectId()); partNodeId.set(partNode.getId()); }); diff --git a/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/DiagramQueryElementService.java b/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/DiagramQueryElementService.java index 44d37d5f7..673af00d7 100644 --- a/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/DiagramQueryElementService.java +++ b/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/DiagramQueryElementService.java @@ -330,17 +330,17 @@ public Object infoMessage(Object self, String message) { } /** - * Checks if the given node represents the given feature. This especially handle can of feature chain that target inherited member. In such case, the two last segments of the chain should be used - * to find the suitable node. + * Checks if the given node represents the given feature. This especially handle can of feature chain that target + * inherited member. In such case, the two last segments of the chain should be used to find the suitable node. * * @param endFeature - * the end feature of a {@link org.eclipse.syson.sysml.ConnectorAsUsage} + * the end feature of a {@link org.eclipse.syson.sysml.ConnectorAsUsage} * @param nodeToTest - * the node to test + * the node to test * @param cacheRendering - * the current cache rendering + * the current cache rendering * @param editingContext - * the editing context + * the editing context * @return true if the given node is valid source/target for the given node */ private boolean isValidConnectionEnd(Feature endFeature, org.eclipse.sirius.components.representations.Element nodeToTest, DiagramRenderingCache cacheRendering, diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/AbstractCompartmentNodeDescriptionProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/AbstractCompartmentNodeDescriptionProvider.java index e76ec3916..ea6fc12de 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/AbstractCompartmentNodeDescriptionProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/AbstractCompartmentNodeDescriptionProvider.java @@ -39,6 +39,7 @@ import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy; import org.eclipse.sirius.components.view.diagram.UserResizableDirection; import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter; +import org.eclipse.syson.diagram.common.view.services.ViewNodeService; import org.eclipse.syson.diagram.common.view.services.description.ToolDescriptionService; import org.eclipse.syson.diagram.common.view.tools.CompartmentNodeToolProvider; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; @@ -100,6 +101,10 @@ public void link(DiagramDescription diagramDescription, IViewDiagramElementFinde }); } + protected IDescriptionNameGenerator getDescriptionNameGenerator() { + return this.descriptionNameGenerator; + } + /** * Implementers should provide the list of {@link NodeDescription} that can be dropped inside this compartment * {@link NodeDescription}. @@ -140,7 +145,9 @@ protected List getItemCreationToolProviders() { * false otherwise. */ protected String isHiddenByDefaultExpression() { - return AQLUtils.getSelfServiceCallExpression("isHiddenByDefault", "'" + this.eReference.getName() + "'"); + return ServiceMethod.of4(ViewNodeService::isHiddenByDefault).aqlSelf(AQLUtils.aqlString(this.getCompartmentName()), + org.eclipse.sirius.components.diagrams.description.NodeDescription.ANCESTORS, + IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); } /** @@ -239,10 +246,6 @@ protected DropNodeTool createCompartmentDropFromDiagramTool(IViewDiagramElementF .build(); } - protected IDescriptionNameGenerator getDescriptionNameGenerator() { - return this.descriptionNameGenerator; - } - protected String getCompartmentLabel() { String customLabel = this.getCustomCompartmentLabel(); if (customLabel != null) { diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/ActionFlowCompartmentNodeDescriptionProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/ActionFlowCompartmentNodeDescriptionProvider.java index 50c253651..ca57aef1d 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/ActionFlowCompartmentNodeDescriptionProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/ActionFlowCompartmentNodeDescriptionProvider.java @@ -72,7 +72,7 @@ public NodeDescription create() { .defaultWidthExpression(ViewConstants.DEFAULT_NODE_WIDTH) .domainType(SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getElement())) .insideLabel(this.createInsideLabelDescription()) - .isHiddenByDefaultExpression("aql:true") + .isHiddenByDefaultExpression(this.isHiddenByDefaultExpression()) .name(this.name) .semanticCandidatesExpression(AQLConstants.AQL_SELF) .style(this.createCompartmentNodeStyle()) @@ -162,7 +162,7 @@ protected InsideLabelStyle createInsideLabelStyle() { .fontSize(12) .italic(true) .labelColor(this.colorProvider.getColor(ViewConstants.DEFAULT_LABEL_COLOR)) - .showIconExpression("aql:false") + .showIconExpression(AQLConstants.AQL_FALSE) .withHeader(true) .build(); } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/InterconnectionCompartmentNodeDescriptionProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/InterconnectionCompartmentNodeDescriptionProvider.java index 088aece9f..7071be9af 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/InterconnectionCompartmentNodeDescriptionProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/InterconnectionCompartmentNodeDescriptionProvider.java @@ -33,12 +33,14 @@ import org.eclipse.sirius.components.view.diagram.NodeToolSection; import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy; import org.eclipse.sirius.components.view.diagram.UserResizableDirection; +import org.eclipse.syson.diagram.common.view.services.ViewNodeService; import org.eclipse.syson.diagram.common.view.services.description.ToolConstants; import org.eclipse.syson.diagram.common.view.tools.ActionFlowCompartmentNodeToolProvider; import org.eclipse.syson.sysml.SysmlPackage; import org.eclipse.syson.util.AQLConstants; import org.eclipse.syson.util.AQLUtils; import org.eclipse.syson.util.IDescriptionNameGenerator; +import org.eclipse.syson.util.ServiceMethod; import org.eclipse.syson.util.StandardDiagramsConstants; import org.eclipse.syson.util.SysMLMetamodelHelper; import org.eclipse.syson.util.ViewConstants; @@ -66,6 +68,7 @@ public NodeDescription create() { .defaultWidthExpression(ViewConstants.DEFAULT_NODE_WIDTH) .domainType(SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getElement())) .insideLabel(this.createInsideLabelDescription()) + .isHiddenByDefaultExpression(this.isHiddenByDefaultExpression()) .name(this.compartmentName) .preconditionExpression( AQLUtils.getSelfServiceCallExpression("isView", @@ -162,4 +165,10 @@ protected NodeStyleDescription createCompartmentNodeStyle() { .childrenLayoutStrategy(this.diagramBuilderHelper.newFreeFormLayoutStrategyDescription().build()) .build(); } + + @Override + protected String isHiddenByDefaultExpression() { + return ServiceMethod.of4(ViewNodeService::isHiddenByDefault).aqlSelf(AQLUtils.aqlString(this.compartmentName), org.eclipse.sirius.components.diagrams.description.NodeDescription.ANCESTORS, + IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); + } } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/StateTransitionCompartmentNodeDescriptionProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/StateTransitionCompartmentNodeDescriptionProvider.java index bc479e481..48d647a19 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/StateTransitionCompartmentNodeDescriptionProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/StateTransitionCompartmentNodeDescriptionProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024, 2025 Obeo. + * Copyright (c) 2024, 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 @@ -106,7 +106,7 @@ protected InsideLabelStyle createInsideLabelStyle() { .fontSize(12) .italic(true) .labelColor(this.colorProvider.getColor(ViewConstants.DEFAULT_LABEL_COLOR)) - .showIconExpression("aql:false") + .showIconExpression(AQLConstants.AQL_FALSE) .withHeader(true) .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 26bdb000e..55275229e 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 @@ -24,7 +24,6 @@ import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.sirius.components.collaborative.diagrams.DiagramContext; import org.eclipse.sirius.components.collaborative.diagrams.DiagramService; import org.eclipse.sirius.components.collaborative.diagrams.DiagramServices; @@ -315,41 +314,38 @@ public Node revealCompartment(Node node, Element targetElement, DiagramContext d } /** - * Check if the compartment associated to the given {@link Element} and reference should be hidden by default. + * Check if the compartment associated to the given {@link Element} should be hidden by default. * * @param self * the {@link Element} associated to the compartment node. - * @param referenceName - * the name of the reference associated to the compartment node. + * @param compartmentName + * the name of the compartment to display/hide by default + * @param ancestors + * the list of ancestors of the element (semantic elements corresponding to graphical ancestors). It + * corresponds to a variable accessible from the variable manager. + * @param editingContext + * the {@link IEditingContext} of the element. It corresponds to a variable accessible from the variable + * manager. + * @param diagramContext + * the {@link DiagramContext} of the element. It corresponds to a variable accessible from the variable + * manager. * @return true if the compartment should be hidden by default, false otherwise */ - public boolean isHiddenByDefault(Element self, String referenceName) { + public boolean isHiddenByDefault(Element self, String compartmentName, List ancestors, IEditingContext editingContext, DiagramContext diagramContext) { boolean isHiddenByDefault = true; - EStructuralFeature eStructuralFeature = self.eClass().getEStructuralFeature(referenceName); - if (eStructuralFeature != null && eStructuralFeature != SysmlPackage.eINSTANCE.getDefinition_OwnedPort()) { - Object referenceValue = self.eGet(eStructuralFeature); - if (referenceValue instanceof List referenceListValue) { - isHiddenByDefault = referenceListValue.isEmpty(); - } else { - isHiddenByDefault = referenceValue == null; + // @technical-debt we should find a way to compute this compartment name here and in + // InterconnectionCompartmentNodeDescriptionProvider only once. + if ("GV Compartment interconnection FreeForm".equals(compartmentName)) { + var exposedParts = this.getExposedElements(self, SysmlPackage.eINSTANCE.getPartUsage(), ancestors, editingContext, diagramContext); + var exposedActions = this.getExposedElements(self, SysmlPackage.eINSTANCE.getActionUsage(), ancestors, editingContext, diagramContext); + var exposedSatisfyRequirements = this.getExposedElements(self, SysmlPackage.eINSTANCE.getSatisfyRequirementUsage(), ancestors, editingContext, diagramContext); + if (!exposedParts.isEmpty() || !exposedActions.isEmpty() || !exposedSatisfyRequirements.isEmpty()) { + isHiddenByDefault = false; } } return isHiddenByDefault; } - /** - * Check if the compartment associated to the given {@link Element} and references should be hidden by default. - * - * @param self - * the {@link Element} associated to the compartment node. - * @param referenceNames - * the name of the references associated to the compartment node. - * @return true if the compartment should be hidden by default, false otherwise - */ - public boolean isHiddenByDefault(Element self, List referenceNames) { - return referenceNames.stream().allMatch(referenceName -> this.isHiddenByDefault(self, referenceName)); - } - /** * Returns {@code true} if {@code parentNodeElement} is an ancestor of {@code childNodeElement}. *

diff --git a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/nodes/AllocationDefinitionEndsCompartmentNodeDescriptionProvider.java b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/nodes/AllocationDefinitionEndsCompartmentNodeDescriptionProvider.java index c0ab62cb7..3f8c34557 100644 --- a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/nodes/AllocationDefinitionEndsCompartmentNodeDescriptionProvider.java +++ b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/nodes/AllocationDefinitionEndsCompartmentNodeDescriptionProvider.java @@ -22,6 +22,7 @@ import org.eclipse.syson.diagram.common.view.nodes.AbstractCompartmentNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.tools.ConnectionDefinitionEndCompartmentNodeToolProvider; import org.eclipse.syson.sysml.SysmlPackage; +import org.eclipse.syson.util.AQLConstants; import org.eclipse.syson.util.IDescriptionNameGenerator; /** @@ -51,4 +52,9 @@ protected List getItemCreationToolProviders() { creationToolProviders.add(new ConnectionDefinitionEndCompartmentNodeToolProvider()); return creationToolProviders; } + + @Override + protected String isHiddenByDefaultExpression() { + return AQLConstants.AQL_FALSE; + } } diff --git a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/nodes/ConnectionDefinitionEndsCompartmentNodeDescriptionProvider.java b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/nodes/ConnectionDefinitionEndsCompartmentNodeDescriptionProvider.java index 0a14e270b..a7b2f76f7 100644 --- a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/nodes/ConnectionDefinitionEndsCompartmentNodeDescriptionProvider.java +++ b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/nodes/ConnectionDefinitionEndsCompartmentNodeDescriptionProvider.java @@ -22,6 +22,7 @@ import org.eclipse.syson.diagram.common.view.nodes.AbstractCompartmentNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.tools.ConnectionDefinitionEndCompartmentNodeToolProvider; import org.eclipse.syson.sysml.SysmlPackage; +import org.eclipse.syson.util.AQLConstants; import org.eclipse.syson.util.IDescriptionNameGenerator; /** @@ -51,4 +52,9 @@ protected List getItemCreationToolProviders() { creationToolProviders.add(new ConnectionDefinitionEndCompartmentNodeToolProvider()); return creationToolProviders; } + + @Override + protected String isHiddenByDefaultExpression() { + return AQLConstants.AQL_FALSE; + } } diff --git a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/nodes/InterfaceDefinitionEndsCompartmentNodeDescriptionProvider.java b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/nodes/InterfaceDefinitionEndsCompartmentNodeDescriptionProvider.java index 0107225d5..3fd24369b 100644 --- a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/nodes/InterfaceDefinitionEndsCompartmentNodeDescriptionProvider.java +++ b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/nodes/InterfaceDefinitionEndsCompartmentNodeDescriptionProvider.java @@ -22,7 +22,6 @@ import org.eclipse.syson.diagram.common.view.nodes.AbstractCompartmentNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.tools.InterfaceDefinitionEndCompartmentNodeToolProvider; import org.eclipse.syson.sysml.SysmlPackage; -import org.eclipse.syson.util.AQLConstants; import org.eclipse.syson.util.IDescriptionNameGenerator; /** @@ -52,9 +51,4 @@ protected List getItemCreationToolProviders() { creationToolProviders.add(new InterfaceDefinitionEndCompartmentNodeToolProvider()); return creationToolProviders; } - - @Override - protected String isHiddenByDefaultExpression() { - return AQLConstants.AQL_TRUE; - } } diff --git a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/services/DiagramMutationDropDefaultVisibility.java b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/services/DiagramMutationDropDefaultVisibility.java deleted file mode 100644 index 8149e0334..000000000 --- a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/services/DiagramMutationDropDefaultVisibility.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * 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.standard.diagrams.view.services; - -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -import org.eclipse.sirius.components.collaborative.api.ChangeDescription; -import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventConsumer; -import org.eclipse.sirius.components.collaborative.diagrams.dto.DropOnDiagramInput; -import org.eclipse.sirius.components.core.api.IEditingContext; -import org.eclipse.sirius.components.core.api.IObjectSearchService; -import org.eclipse.sirius.components.diagrams.Diagram; -import org.eclipse.sirius.components.diagrams.ViewCreationRequest; -import org.eclipse.sirius.components.diagrams.ViewDeletionRequest; -import org.eclipse.sirius.components.diagrams.components.NodeContainmentKind; -import org.eclipse.sirius.components.diagrams.components.NodeIdProvider; -import org.eclipse.sirius.components.diagrams.description.NodeDescription; -import org.eclipse.sirius.components.diagrams.events.HideDiagramElementEvent; -import org.eclipse.sirius.components.diagrams.events.IDiagramEvent; -import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramConversionData; -import org.eclipse.sirius.web.application.editingcontext.EditingContext; -import org.eclipse.syson.diagram.services.DiagramQueryElementService; -import org.eclipse.syson.standard.diagrams.view.SDVDescriptionNameGenerator; -import org.eclipse.syson.sysml.Element; -import org.eclipse.syson.util.IDescriptionNameGenerator; -import org.eclipse.syson.util.SysONRepresentationDescriptionIdentifiers; -import org.springframework.stereotype.Service; - -/** - * Service that will be executed after a DropOnDiagramInput in order to hide compartments. - * If it's an interconnection compartment then we keep the default behavior of {@link org.eclipse.syson.diagram.common.view.services.ViewNodeService#isHiddenByDefault(Element, String)} - * - * @author mcharfadi - */ -@Service -public class DiagramMutationDropDefaultVisibility implements IDiagramEventConsumer { - - private final DiagramQueryElementService diagramQueryElementService; - - private final IObjectSearchService objectSearchService; - - public DiagramMutationDropDefaultVisibility(DiagramQueryElementService diagramQueryElementService, IObjectSearchService objectSearchService) { - this.diagramQueryElementService = diagramQueryElementService; - this.objectSearchService = objectSearchService; - } - - @Override - public void accept(IEditingContext editingContext, Diagram previousDiagram, List diagramEvents, List viewDeletionRequests, List viewCreationRequests, ChangeDescription changeDescription) { - if (changeDescription.getInput() instanceof DropOnDiagramInput input && this.isStandardDiagram(previousDiagram) && editingContext instanceof EditingContext siriusEditingContext - && siriusEditingContext.getViewConversionData().get(previousDiagram.getDescriptionId()) instanceof ViewDiagramConversionData viewDiagramConversionData) { - - IDescriptionNameGenerator descriptionNameGenerator = new SDVDescriptionNameGenerator(); - var interconnectionCompartmentName = descriptionNameGenerator.getFreeFormCompartmentName("interconnection"); - var interConnectionCompartment = viewDiagramConversionData.convertedNodes().entrySet().stream() - .filter(nodeDescriptionNodeDescriptionEntry -> nodeDescriptionNodeDescriptionEntry.getKey().getName().equals(interconnectionCompartmentName)) - .map(Map.Entry::getValue) - .map(NodeDescription::getId) - .findFirst(); - - Set compartmentsToHide = new HashSet<>(); - input.objectIds().forEach(objectId -> { - var semanticParent = this.objectSearchService.getObject(editingContext, objectId); - if (semanticParent.isPresent() && semanticParent.get() instanceof Element element) { - var optionalParentNodeDescriptionId = this.diagramQueryElementService.getNodeDescriptionId(element, previousDiagram, editingContext); - if (optionalParentNodeDescriptionId.isPresent()) { - var parentNodeId = new NodeIdProvider().getNodeId(previousDiagram.getId(), - optionalParentNodeDescriptionId.get(), - NodeContainmentKind.CHILD_NODE, - objectId); - - var parentNodeDescription = viewDiagramConversionData.convertedNodes().values().stream() - .filter(nodeDescription -> nodeDescription.getId().equals(optionalParentNodeDescriptionId.get())) - .findFirst(); - - parentNodeDescription.ifPresent(nodeDescription -> nodeDescription.getReusedChildNodeDescriptionIds().stream() - .filter(reusedChildNodeDescriptionId -> interConnectionCompartment.isEmpty() || !interConnectionCompartment.get().equals(reusedChildNodeDescriptionId)) - .forEach(reusedChildNodeDescriptionId -> { - var containerNodeToHideId = new NodeIdProvider().getNodeId(parentNodeId, - reusedChildNodeDescriptionId, - NodeContainmentKind.CHILD_NODE, - objectId); - compartmentsToHide.add(containerNodeToHideId); - })); - - diagramEvents.add(new HideDiagramElementEvent(compartmentsToHide, true)); - } - } - }); - } - - } - - private boolean isStandardDiagram(Diagram diagram) { - return diagram != null && Objects.equals(SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID, diagram.getDescriptionId()); - } -} diff --git a/doc/content/modules/user-manual/pages/release-notes/2026.3.0.adoc b/doc/content/modules/user-manual/pages/release-notes/2026.3.0.adoc index 0dca18d89..6be5a3ff8 100644 --- a/doc/content/modules/user-manual/pages/release-notes/2026.3.0.adoc +++ b/doc/content/modules/user-manual/pages/release-notes/2026.3.0.adoc @@ -40,6 +40,7 @@ Now the _end_ keyword is not displayed anymore in the label of these graphical n + Consequently, their entire footprint is filled with black, ensuring that all incoming and outgoing edges maintain a valid connection point. ** Fix an issue where the _Add existing elements_ tool was not working correctly on the _action flow_ compartment of `ActionUsage` graphical nodes. ** Fix the user feedback when dropping an `Element` from the _Explorer_ view which is already exposed on a diagram. +** Fix an issue where the non-empty compartments of graphical nodes were being displayed when executing the _Add existing elements_ tool. * In textual import/export: diff --git a/integration-tests-playwright/playwright/resources/SysMLv2WithInterconnectionView.sysml b/integration-tests-playwright/playwright/resources/SysMLv2WithInterconnectionView.sysml index 0db1395a6..74d20b855 100644 --- a/integration-tests-playwright/playwright/resources/SysMLv2WithInterconnectionView.sysml +++ b/integration-tests-playwright/playwright/resources/SysMLv2WithInterconnectionView.sysml @@ -1,6 +1,9 @@ package Package1 { view view1 : StandardViewDefinitions::InterconnectionView { expose part1; + expose part1::part2; + } + part part1 { + part part2; } - part part1; } \ No newline at end of file