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 @@ -23,6 +23,7 @@
=== Bug fixes

- https://github.com/eclipse-syson/syson/issues/893[#893] [explorer] Fix _Expand All_ tool in SysON _Explorer_ view
- https://github.com/eclipse-syson/syson/issues/1398[#1398] [explorer] Fix an issue where a d'n'd of an `Element` in a diagram exposed the `Element` twice in the `ViewUsage` associated to the diagram.

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.eclipse.syson.sysml.Element;
import org.eclipse.syson.sysml.Package;
import org.eclipse.syson.sysml.SysmlPackage;
import org.eclipse.syson.sysml.ViewUsage;
import org.eclipse.syson.util.IDescriptionNameGenerator;
import org.eclipse.syson.util.SysONRepresentationDescriptionIdentifiers;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -136,7 +137,8 @@ public void tearDown() {
}
}

@Sql(scripts = { GeneralViewAddExistingElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = { GeneralViewAddExistingElementsTestProjectData.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 dropFromExplorerOnEmptyDiagram() {
Expand All @@ -156,9 +158,7 @@ public void dropFromExplorerOnEmptyDiagram() {
String emptyDiagramNodeDescriptionId = this.diagramDescriptionIdProvider.getNodeDescriptionId(GeneralViewEmptyDiagramNodeDescriptionProvider.NAME);
// Ensure the existing node is the "empty diagram" one.
assertThat(emptyDiagramNode).hasDescriptionId(emptyDiagramNodeDescriptionId);
this.dropFromExplorerTester.dropFromExplorerOnDiagram(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID,
this.diagram,
semanticElementId.get());
this.dropFromExplorerTester.dropFromExplorerOnDiagram(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID, this.diagram, semanticElementId.get());
});

Consumer<DiagramRefreshedEventPayload> updatedDiagramConsumer = payload -> Optional.of(payload)
Expand All @@ -177,9 +177,24 @@ public void dropFromExplorerOnEmptyDiagram() {
}, () -> fail("Missing diagram"));

this.verifier.consumeNextWith(updatedDiagramConsumer);

Runnable exposedElementsChecker = this.semanticRunnableFactory.createRunnable(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID,
(editingContext, executeEditingContextFunctionInput) -> {
ViewUsage generalViewViewUsage = this.objectSearchService.getObject(editingContext, GeneralViewAddExistingElementsTestProjectData.SemanticIds.GENERAL_VIEW_VIEW_USAGE_ID)
.filter(ViewUsage.class::isInstance)
.map(ViewUsage.class::cast)
.orElse(null);
assertThat(generalViewViewUsage).isNotNull();
assertThat(generalViewViewUsage.getExposedElement()).hasSize(1);
return new ExecuteEditingContextFunctionSuccessPayload(executeEditingContextFunctionInput.id(), true);
});

this.verifier.then(exposedElementsChecker);

}

@Sql(scripts = { GeneralViewAddExistingElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = { GeneralViewAddExistingElementsTestProjectData.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 dropFromExplorerOnEmptyDiagramNode() {
Expand All @@ -199,10 +214,7 @@ public void dropFromExplorerOnEmptyDiagramNode() {
String emptyDiagramNodeDescriptionId = this.diagramDescriptionIdProvider.getNodeDescriptionId(GeneralViewEmptyDiagramNodeDescriptionProvider.NAME);
// Ensure the existing node is the "empty diagram" one.
assertThat(emptyDiagramNode).hasDescriptionId(emptyDiagramNodeDescriptionId);
this.dropFromExplorerTester.dropFromExplorer(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID,
this.diagram,
emptyDiagramNode.getId(),
semanticElementId.get());
this.dropFromExplorerTester.dropFromExplorer(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID, this.diagram, emptyDiagramNode.getId(), semanticElementId.get());
});

Consumer<DiagramRefreshedEventPayload> updatedDiagramConsumer = payload -> Optional.of(payload)
Expand All @@ -224,8 +236,7 @@ public void dropFromExplorerOnEmptyDiagramNode() {
}

private String getSemanticElementWithTargetObjectLabel(IEditingContext editingContext, String targetObjectLabel) {
Object semanticRootObject = this.objectSearchService.getObject(editingContext,
GeneralViewAddExistingElementsTestProjectData.SemanticIds.PACKAGE_1_ID).orElse(null);
Object semanticRootObject = this.objectSearchService.getObject(editingContext, GeneralViewAddExistingElementsTestProjectData.SemanticIds.PACKAGE_1_ID).orElse(null);
assertThat(semanticRootObject).isInstanceOf(Package.class);
Package rootPackage = (Package) semanticRootObject;
Optional<Element> optPartUsage = rootPackage.getOwnedMember().stream().filter(m -> Objects.equals(m.getName(), targetObjectLabel)).findFirst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public static final class SemanticIds {

public static final String PACKAGE_1_ID = "8d4123ac-3ac5-412d-90f2-49282b923003";

public static final String GENERAL_VIEW_VIEW_USAGE_ID = "b67872fa-5900-48d3-88f0-e6ced193c8ec";

public static final String SUCCESSION_START_ACTION_2_IDS = "18d6f2fc-2182-4217-8da2-bf68c36ffa41";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ public void beforeEach() {
this.givenInitialServerState.initialize();
}

@DisplayName("Given the simple project, when drag an dropping a part definition on a package, then the part definition should be moved under the Package.")
@Sql(scripts = { SimpleProjectElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@DisplayName("GIVEN a SySML project, WHEN drag an dropping a PartDefinition on a Package, THEN the PartDefinition should be moved under the Package.")
@Sql(scripts = { SimpleProjectElementsTestProjectData.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 checkDnDPartDefinitionOnPackage() {
Expand Down Expand Up @@ -153,8 +154,9 @@ public void checkDnDPartDefinitionOnPackage() {

}

@DisplayName("Given a SySML project, when drag an dropping an element into one of its descendant, then the selected element should not be moved")
@Sql(scripts = { SimpleProjectElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@DisplayName("GIVEN a SySML project, WHEN drag an dropping an Element into one of its descendant, THEN the selected Element should not be moved")
@Sql(scripts = { SimpleProjectElementsTestProjectData.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 checkForbiddenDropOnDescendant() {
Expand Down Expand Up @@ -211,5 +213,4 @@ public void checkForbiddenDropOnDescendant() {
.verify(Duration.ofSeconds(10));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ public Element dropElementFromExplorer(Element element, IEditingContext editingC
}
if (optElementToDrop.isPresent()) {
this.dropElementFromExplorerInTarget(optElementToDrop.get(), targetElement, editingContext, diagramContext, selectedNode, convertedNodes);
this.updateExposedElements(targetElement, optElementToDrop.get(), editingContext, diagramContext);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

== Bug fixes

- Fix an issue that made the _Expand All_ tool not work consistently in SysON _Explorer_ view
- Fix an issue that made the _Expand All_ tool not work consistently in SysON _Explorer_ view.
- Fix an issue where a d'n'd of an `Element` from the _Explorer_ view to a diagram exposed the `Element` twice in the `ViewUsage` associated to the diagram.

== Improvements

Expand Down
Loading