diff --git a/backend/metamodel/syson-siriusweb-customnodes-metamodel/src/test/java/org/eclipse/syson/customnodes/metamodel/SysMLImportedPackageNodeStyleDescriptionTests.java b/backend/metamodel/syson-siriusweb-customnodes-metamodel/src/test/java/org/eclipse/syson/customnodes/metamodel/SysMLImportedPackageNodeStyleDescriptionTests.java index ce13e6539..57d9f3d42 100644 --- a/backend/metamodel/syson-siriusweb-customnodes-metamodel/src/test/java/org/eclipse/syson/customnodes/metamodel/SysMLImportedPackageNodeStyleDescriptionTests.java +++ b/backend/metamodel/syson-siriusweb-customnodes-metamodel/src/test/java/org/eclipse/syson/customnodes/metamodel/SysMLImportedPackageNodeStyleDescriptionTests.java @@ -23,6 +23,8 @@ /** * Unit test for the imported package custom node style. + * + * @author jgout */ public class SysMLImportedPackageNodeStyleDescriptionTests { diff --git a/backend/services/syson-services/src/main/java/org/eclipse/syson/services/ToolService.java b/backend/services/syson-services/src/main/java/org/eclipse/syson/services/ToolService.java index 6272836ae..a168ff8ae 100644 --- a/backend/services/syson-services/src/main/java/org/eclipse/syson/services/ToolService.java +++ b/backend/services/syson-services/src/main/java/org/eclipse/syson/services/ToolService.java @@ -36,6 +36,7 @@ import org.eclipse.sirius.components.diagrams.events.HideDiagramElementEvent; import org.eclipse.sirius.components.view.diagram.DiagramDescription; import org.eclipse.syson.sysml.Element; +import org.eclipse.syson.sysml.Import; import org.eclipse.syson.sysml.helper.EMFUtils; /** @@ -232,12 +233,32 @@ protected Optional getChildNodeDescriptionIdForRendering(Element element protected void moveElement(Element droppedElement, Node droppedNode, Element targetElement, Node targetNode, IEditingContext editingContext, IDiagramContext diagramContext, Map convertedNodes) { - this.utilService.moveMembership(droppedElement, targetElement); + this.moveSemanticElement(droppedElement, targetElement); ViewCreationRequest droppedElementViewCreationRequest = this.createView(droppedElement, editingContext, diagramContext, targetNode, convertedNodes); this.moveSubNodes(droppedElementViewCreationRequest, droppedNode, diagramContext); diagramContext.getViewDeletionRequests().add(ViewDeletionRequest.newViewDeletionRequest().elementId(droppedNode.getId()).build()); } + protected void moveSemanticElement(Element element, Element newParent) { + if (element instanceof Import imprt) { + newParent.getOwnedRelationship().add(0, imprt); + } else { + this.utilService.moveMembership(element, newParent); + } + } + + protected Optional getViewNodeDescription(String descriptionId, DiagramDescription diagramDescription, + Map convertedNodes) { + return EMFUtils.eAllContentStreamWithSelf(diagramDescription) + .filter(org.eclipse.sirius.components.view.diagram.NodeDescription.class::isInstance) + .map(org.eclipse.sirius.components.view.diagram.NodeDescription.class::cast) + .filter(nodeDesc -> { + NodeDescription convertedNodeDesc = convertedNodes.get(nodeDesc); + return convertedNodeDesc != null && descriptionId.equals(convertedNodeDesc.getId()); + }) + .findFirst(); + } + /** * Moves the sub-nodes of the provided {@code parentNode} inside the graphical element created by * {@code parentViewCreationRequest}. @@ -258,7 +279,7 @@ protected void moveElement(Element droppedElement, Node droppedNode, Element tar * @param diagramContext * the diagram context */ - private void moveSubNodes(ViewCreationRequest parentViewCreationRequest, Node parentNode, IDiagramContext diagramContext) { + protected void moveSubNodes(ViewCreationRequest parentViewCreationRequest, Node parentNode, IDiagramContext diagramContext) { for (Node childNode : parentNode.getChildNodes()) { ViewCreationRequest childViewCreationRequest = ViewCreationRequest.newViewCreationRequest() .containmentKind(NodeContainmentKind.CHILD_NODE) @@ -289,16 +310,4 @@ private void moveSubNodes(ViewCreationRequest parentViewCreationRequest, Node pa } } } - - protected Optional getViewNodeDescription(String descriptionId, DiagramDescription diagramDescription, - Map convertedNodes) { - return EMFUtils.eAllContentStreamWithSelf(diagramDescription) - .filter(org.eclipse.sirius.components.view.diagram.NodeDescription.class::isInstance) - .map(org.eclipse.sirius.components.view.diagram.NodeDescription.class::cast) - .filter(nodeDesc -> { - NodeDescription convertedNodeDesc = convertedNodes.get(nodeDesc); - return convertedNodeDesc != null && descriptionId.equals(convertedNodeDesc.getId()); - }) - .findFirst(); - } } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/AbstractPackageNodeDescriptionProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/AbstractPackageNodeDescriptionProvider.java index f3af4a769..675ee9f9b 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/AbstractPackageNodeDescriptionProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/nodes/AbstractPackageNodeDescriptionProvider.java @@ -18,6 +18,7 @@ import org.eclipse.emf.ecore.EClass; import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext; +import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.view.builder.IViewDiagramElementFinder; import org.eclipse.sirius.components.view.builder.generated.diagram.FreeFormLayoutStrategyDescriptionBuilder; import org.eclipse.sirius.components.view.builder.generated.diagram.NodeToolSectionBuilder; @@ -191,7 +192,7 @@ private NodePalette createNodePalette(NodeDescription nodeDescription, IViewDiag .initialDirectEditLabelExpression(AQLConstants.AQL_SELF + ".getDefaultInitialDirectEditLabel()") .body(callEditService.build()); - var edgeTools = new ArrayList(this.getEdgeTools(nodeDescription, cache)); + var edgeTools = new ArrayList<>(this.getEdgeTools(nodeDescription, cache)); return this.diagramBuilderHelper.newNodePalette() .deleteTool(deleteTool.build()) @@ -209,7 +210,8 @@ private List getEdgeTools(NodeDescription nodeDescription, IViewDiagra private DropNodeTool createDropFromDiagramTool(IViewDiagramElementFinder cache) { var dropElementFromDiagram = this.viewBuilderHelper.newChangeContext() - .expression("aql:droppedElement.dropElementFromDiagram(droppedNode, targetElement, targetNode, editingContext, diagramContext, convertedNodes)"); + .expression(AQLUtils.getServiceCallExpression("droppedElement", "dropElementFromDiagram", + List.of("droppedNode", "targetElement", "targetNode", IEditingContext.EDITING_CONTEXT, IDiagramContext.DIAGRAM_CONTEXT, "convertedNodes"))); return this.diagramBuilderHelper.newDropNodeTool() .name("Drop from Diagram") diff --git a/backend/views/syson-diagram-general-view/src/main/java/org/eclipse/syson/diagram/general/view/GeneralViewDiagramDescriptionProvider.java b/backend/views/syson-diagram-general-view/src/main/java/org/eclipse/syson/diagram/general/view/GeneralViewDiagramDescriptionProvider.java index 6950c7251..38d9d58b0 100644 --- a/backend/views/syson-diagram-general-view/src/main/java/org/eclipse/syson/diagram/general/view/GeneralViewDiagramDescriptionProvider.java +++ b/backend/views/syson-diagram-general-view/src/main/java/org/eclipse/syson/diagram/general/view/GeneralViewDiagramDescriptionProvider.java @@ -374,7 +374,7 @@ protected IDescriptionNameGenerator getDescriptionNameGenerator() { } private void addCustomNodeDescriptionProviders(IColorProvider colorProvider, - ArrayList> diagramElementDescriptionProviders) { + List> diagramElementDescriptionProviders) { diagramElementDescriptionProviders.add(new RequirementUsageSubjectCompartmentNodeDescriptionProvider(colorProvider, this.getDescriptionNameGenerator())); diagramElementDescriptionProviders.add(new RequirementDefinitionSubjectCompartmentNodeDescriptionProvider(colorProvider, this.getDescriptionNameGenerator())); diagramElementDescriptionProviders.add(new CompartmentItemNodeDescriptionProvider(SysmlPackage.eINSTANCE.getRequirementUsage(), SysmlPackage.eINSTANCE.getRequirementUsage_SubjectParameter(), @@ -433,7 +433,7 @@ private void addCustomNodeDescriptionProviders(IColorProvider colorProvider, diagramElementDescriptionProviders.add(new DecisionActionNodeDescriptionProvider(colorProvider, this.getDescriptionNameGenerator())); diagramElementDescriptionProviders.add(new ReferencingPerformActionUsageNodeDescriptionProvider(colorProvider)); diagramElementDescriptionProviders.add(new ActorNodeDescriptionProvider(colorProvider)); - diagramElementDescriptionProviders.add(new ImportedPackageNodeDescriptionProvider(colorProvider, this.descriptionNameGenerator)); + diagramElementDescriptionProviders.add(new ImportedPackageNodeDescriptionProvider(colorProvider, this.getDescriptionNameGenerator())); } private void addEdgeDescriptionProviders(IColorProvider colorProvider, ArrayList> diagramElementDescriptionProviders) { @@ -633,8 +633,8 @@ private DropNodeTool createDropFromDiagramTool(IViewDiagramElementFinder cache) }); }); - var optPackageNodeDescription = cache.getNodeDescription(this.getDescriptionNameGenerator().getNodeName(SysmlPackage.eINSTANCE.getPackage())); - acceptedNodeTypes.add(optPackageNodeDescription.get()); + cache.getNodeDescription(this.getDescriptionNameGenerator().getNodeName(SysmlPackage.eINSTANCE.getNamespaceImport())) + .ifPresent(acceptedNodeTypes::add); var dropElementFromDiagram = this.viewBuilderHelper.newChangeContext() .expression(AQLUtils.getServiceCallExpression("droppedElement", "dropElementFromDiagram", diff --git a/doc/content/modules/user-manual/pages/release-notes/2025.1.0.adoc b/doc/content/modules/user-manual/pages/release-notes/2025.1.0.adoc index e66851720..1539342da 100644 --- a/doc/content/modules/user-manual/pages/release-notes/2025.1.0.adoc +++ b/doc/content/modules/user-manual/pages/release-notes/2025.1.0.adoc @@ -10,7 +10,7 @@ == Improvements -- `OccurrenceUsag#portionKind` is now unsettable and its default value is `null` in the SysMLv2 metamodel to conform to the specification. +- `OccurrenceUsage#portionKind` is now unsettable and its default value is `null` in the SysMLv2 metamodel to conform to the specification. == New features diff --git a/frontend/syson-components/src/nodes/imported_package/SysMLImportedPackageNode.tsx b/frontend/syson-components/src/nodes/imported_package/SysMLImportedPackageNode.tsx index ea9bb5b9f..5c78fe907 100644 --- a/frontend/syson-components/src/nodes/imported_package/SysMLImportedPackageNode.tsx +++ b/frontend/syson-components/src/nodes/imported_package/SysMLImportedPackageNode.tsx @@ -23,6 +23,7 @@ import { DiagramElementPalette, Label, useConnectorNodeStyle, + useDrop, useDropNodeStyle, useRefreshConnectionHandles, } from '@eclipse-sirius/sirius-components-diagrams'; @@ -133,9 +134,14 @@ export const SysMLImportedPackageNode: NodeComponentsMap['sysMLImportedPackageNo ({ data, id, selected, dragging }: NodeProps>) => { const { readOnly } = useContext(DiagramContext); const theme: Theme = useTheme(); + const { onDrop, onDragOver } = useDrop(); const { style: connectionFeedbackStyle } = useConnectorNodeStyle(id, data.nodeDescription.id); const { style: dropFeedbackStyle } = useDropNodeStyle(data.isDropNodeTarget, data.isDropNodeCandidate, dragging); + const handleOnDrop = (event: React.DragEvent) => { + onDrop(event, id); + }; + const label: any = { ...data.insideLabel, style: { @@ -201,6 +207,8 @@ export const SysMLImportedPackageNode: NodeComponentsMap['sysMLImportedPackageNo style={{ ...sysMLImportedPackageNodeStyle(theme, data.style, !!selected, data.isHovered, data.faded), }} + onDragOver={onDragOver} + onDrop={handleOnDrop} data-testid={`SysMLImportedPackage - ${data?.insideLabel?.text}`}> {!!selected ? (