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 @@ -41,6 +41,7 @@ A separate customizer annotated with Spring `@Primary` does not replace this fil
- https://github.com/eclipse-syson/syson/issues/2510[#2510] [import] Report syntax errors that may leave an uploaded SysML file partially imported.
The parsed elements are still imported, and the loading report includes the parser diagnostics and a warning about possibly missing elements.
- https://github.com/eclipse-syson/syson/issues/2527[#2527] [export] Export connector ends whose feature chain is only owned by the `ReferenceSubsetting`, and export `InterfaceUsage` with the `interface` keyword instead of `connection`.
- https://github.com/eclipse-syson/syson/issues/2518[#2518] [diagrams] Fix the numbering of node labels when creating elements in a diagram on a root `Namespace`.

=== 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.assertj.core.api.InstanceOfAssertFactories.type;
import static org.eclipse.sirius.components.diagrams.tests.DiagramEventPayloadConsumer.assertRefreshedDiagramThat;

import java.time.Duration;
Expand All @@ -26,13 +27,15 @@

import org.assertj.core.api.Assertions;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramEventInput;
import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload;
import org.eclipse.sirius.components.collaborative.diagrams.dto.ToolVariable;
import org.eclipse.sirius.components.collaborative.diagrams.dto.ToolVariableType;
import org.eclipse.sirius.components.collaborative.dto.CreateRepresentationInput;
import org.eclipse.sirius.components.collaborative.selection.dto.SelectionDialogTreeEventInput;
import org.eclipse.sirius.components.collaborative.trees.dto.TreeRefreshedEventPayload;
import org.eclipse.sirius.components.core.api.IEditingContext;
Expand All @@ -53,6 +56,7 @@
import org.eclipse.sirius.components.view.diagram.SelectionDialogDescription;
import org.eclipse.sirius.components.view.emf.diagram.IDiagramIdProvider;
import org.eclipse.sirius.components.view.emf.diagram.api.IViewDiagramDescriptionSearchService;
import org.eclipse.sirius.web.tests.services.api.IGivenCreatedDiagramSubscription;
import org.eclipse.sirius.web.tests.services.api.IGivenInitialServerState;
import org.eclipse.sirius.web.tests.services.representation.RepresentationIdBuilder;
import org.eclipse.sirius.web.tests.services.selection.SelectionDialogTreeEventSubscriptionRunner;
Expand All @@ -63,6 +67,7 @@
import org.eclipse.syson.application.controllers.diagrams.testers.ToolTester;
import org.eclipse.syson.application.controllers.utils.TestNameGenerator;
import org.eclipse.syson.application.data.GeneralViewEmptyTestProjectData;
import org.eclipse.syson.application.data.GeneralViewWithTopNodesTestProjectData;
import org.eclipse.syson.services.SemanticRunnableFactory;
import org.eclipse.syson.services.diagrams.DiagramComparator;
import org.eclipse.syson.services.diagrams.DiagramDescriptionIdProvider;
Expand Down Expand Up @@ -115,6 +120,9 @@ public class GVTopNodeCreationTests extends AbstractIntegrationTests {
@Autowired
private IGivenDiagramSubscription givenDiagramSubscription;

@Autowired
private IGivenCreatedDiagramSubscription givenCreatedDiagramSubscription;

@Autowired
private IDiagramIdProvider diagramIdProvider;

Expand Down Expand Up @@ -194,6 +202,17 @@ private Flux<DiagramRefreshedEventPayload> givenSubscriptionToDiagram() {
return this.givenDiagramSubscription.subscribe(diagramEventInput);
}

private Flux<Object> createAndSubscribeToDiagram() {
var input = new CreateRepresentationInput(
UUID.randomUUID(),
GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID,
SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID,
GeneralViewWithTopNodesTestProjectData.SemanticIds.ROOT_NAMESPACE_ID,
"root Namespace diagram"
);
return this.givenCreatedDiagramSubscription.createAndSubscribe(input).flux();
}

@BeforeEach
public void setUp() {
this.givenInitialServerState.initialize();
Expand Down Expand Up @@ -267,6 +286,72 @@ public void createTopNode(EClass eClass, int totalCompartmentCount, int visibleC
.verify(Duration.ofSeconds(10));
}

@Test
@GivenSysONServer({ GeneralViewWithTopNodesTestProjectData.SCRIPT_PATH })
@DisplayName("GIVEN a general view diagram on a root namespace, WHEN creating two successive PartUsage, THEN the index in their label increments correctly")
public void checkLabelSuffixForElementCreatedOnRootNamespace() {
var flux = this.createAndSubscribeToDiagram();

AtomicReference<Diagram> diagram = new AtomicReference<>();
Consumer<Object> initialDiagramConsumer = assertRefreshedDiagramThat(diagram::set);

var diagramDescription = this.givenDiagramDescription.getDiagramDescription(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID,
SysONRepresentationDescriptionIdentifiers.GENERAL_VIEW_DIAGRAM_DESCRIPTION_ID);
var diagramDescriptionIdProvider = new DiagramDescriptionIdProvider(diagramDescription, this.diagramIdProvider);

String creationToolId = diagramDescriptionIdProvider.getDiagramCreationToolId(this.descriptionNameGenerator.getCreationToolName(SysmlPackage.eINSTANCE.getPartUsage()));

Runnable createNodeRunnable = () -> {
this.nodeCreationTester.invokeTool(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, diagram, null, creationToolId);
};

AtomicReference<String> lastCreatedSemanticElementId = new AtomicReference<>();
Consumer<Object> firstPartCreatedDiagramChecker = assertRefreshedDiagramThat(newDiagram -> {
var initialDiagram = diagram.get();
var newNodes = this.diagramComparator.newNodes(initialDiagram, newDiagram);
assertThat(newNodes).anySatisfy(node -> {
assertThat(node.getInsideLabel().getText()).contains("part1");
lastCreatedSemanticElementId.set(node.getTargetObjectId());
});
diagram.set(newDiagram);
});

Runnable semanticChecker = this.semanticRunnableFactory.createQueryRunnable(GeneralViewWithTopNodesTestProjectData.EDITING_CONTEXT_ID, (editingContext, executeEditingContextFunctionInput) -> {
var object = this.objectSearchService.getObject(editingContext, lastCreatedSemanticElementId.get());
assertThat(object).isPresent()
.get()
.isInstanceOf(EObject.class)
.asInstanceOf(type(EObject.class))
.satisfies(eObject -> {
var container = eObject.eContainer();
assertThat(container.eClass()).isEqualTo(SysmlPackage.eINSTANCE.getOwningMembership());
});
return new ExecuteEditingContextFunctionSuccessPayload(executeEditingContextFunctionInput.id(), true);
});

Consumer<Object> secondPartCreatedDiagramChecker = assertRefreshedDiagramThat(newDiagram -> {
var initialDiagram = diagram.get();
var newNodes = this.diagramComparator.newNodes(initialDiagram, newDiagram);
assertThat(newNodes).anySatisfy(node -> {
assertThat(node.getInsideLabel().getText()).contains("part2");
lastCreatedSemanticElementId.set(node.getTargetObjectId());
});
diagram.set(newDiagram);
});

StepVerifier.create(flux)
.consumeNextWith(initialDiagramConsumer)
.then(createNodeRunnable)
.consumeNextWith(firstPartCreatedDiagramChecker)
.then(semanticChecker)
.then(createNodeRunnable)
.consumeNextWith(secondPartCreatedDiagramChecker)
.then(semanticChecker)
.thenCancel()
.verify(Duration.ofSeconds(10));

}

@DisplayName("GIVEN an empty SysML Project, WHEN New Namespace Import tool on diagram is requested, THEN a new NamespaceImport is created")
@GivenSysONServer({ GeneralViewEmptyTestProjectData.SCRIPT_PATH })
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.syson.sysml.metamodel.services;

import java.util.List;
import java.util.Objects;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
Expand Down Expand Up @@ -75,7 +76,7 @@ public MetamodelMutationElementService() {
*/
public Membership createMembership(Element element) {
Membership membership = null;
if (element instanceof Package) {
if (element instanceof Package || Objects.equals(element.eClass(), SysmlPackage.eINSTANCE.getNamespace())) {
membership = SysmlFactory.eINSTANCE.createOwningMembership();
} else {
membership = SysmlFactory.eINSTANCE.createFeatureMembership();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Use the existing content tools to display these elements. Existing representatio
** In standard view diagrams, the connector palette now shows only edge creation tools compatible with the selected target node.
For example, _New Feature Typing_ is no longer offered between two `Usage` graphical nodes, but remains available from a `Usage` to its corresponding `Definition`.
_New Satisfy Requirement_ remains available when the target is a `RequirementUsage` or `SatisfyRequirementUsage`.
** Elements created in a diagram on a root `Namespace` are now named sequentially.

* In textual import/export:

Expand Down
Loading