Skip to content

Commit 9929579

Browse files
committed
[1398] Fix exposed Element update while d'n'd Element on General View
Bug: #1398 Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
1 parent dcfa659 commit 9929579

6 files changed

Lines changed: 33 additions & 18 deletions

File tree

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
=== Bug fixes
2424

2525
- https://github.com/eclipse-syson/syson/issues/893[#893] [explorer] Fix _Expand All_ tool in SysON _Explorer_ view
26+
- 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.
2627

2728
=== Improvements
2829

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controllers/diagrams/general/view/GVDropFromExplorerTests.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.eclipse.syson.sysml.Element;
5252
import org.eclipse.syson.sysml.Package;
5353
import org.eclipse.syson.sysml.SysmlPackage;
54+
import org.eclipse.syson.sysml.ViewUsage;
5455
import org.eclipse.syson.util.IDescriptionNameGenerator;
5556
import org.eclipse.syson.util.SysONRepresentationDescriptionIdentifiers;
5657
import org.junit.jupiter.api.AfterEach;
@@ -136,7 +137,8 @@ public void tearDown() {
136137
}
137138
}
138139

139-
@Sql(scripts = { GeneralViewAddExistingElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
140+
@Sql(scripts = { GeneralViewAddExistingElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD,
141+
config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
140142
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
141143
@Test
142144
public void dropFromExplorerOnEmptyDiagram() {
@@ -156,9 +158,7 @@ public void dropFromExplorerOnEmptyDiagram() {
156158
String emptyDiagramNodeDescriptionId = this.diagramDescriptionIdProvider.getNodeDescriptionId(GeneralViewEmptyDiagramNodeDescriptionProvider.NAME);
157159
// Ensure the existing node is the "empty diagram" one.
158160
assertThat(emptyDiagramNode).hasDescriptionId(emptyDiagramNodeDescriptionId);
159-
this.dropFromExplorerTester.dropFromExplorerOnDiagram(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID,
160-
this.diagram,
161-
semanticElementId.get());
161+
this.dropFromExplorerTester.dropFromExplorerOnDiagram(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID, this.diagram, semanticElementId.get());
162162
});
163163

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

179179
this.verifier.consumeNextWith(updatedDiagramConsumer);
180+
181+
Runnable exposedElementsChecker = this.semanticRunnableFactory.createRunnable(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID,
182+
(editingContext, executeEditingContextFunctionInput) -> {
183+
ViewUsage generalViewViewUsage = this.objectSearchService.getObject(editingContext, GeneralViewAddExistingElementsTestProjectData.SemanticIds.GENERAL_VIEW_VIEW_USAGE_ID)
184+
.filter(ViewUsage.class::isInstance)
185+
.map(ViewUsage.class::cast)
186+
.orElse(null);
187+
assertThat(generalViewViewUsage).isNotNull();
188+
assertThat(generalViewViewUsage.getExposedElement()).hasSize(1);
189+
return new ExecuteEditingContextFunctionSuccessPayload(executeEditingContextFunctionInput.id(), true);
190+
});
191+
192+
this.verifier.then(exposedElementsChecker);
193+
180194
}
181195

182-
@Sql(scripts = { GeneralViewAddExistingElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
196+
@Sql(scripts = { GeneralViewAddExistingElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD,
197+
config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
183198
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
184199
@Test
185200
public void dropFromExplorerOnEmptyDiagramNode() {
@@ -199,10 +214,7 @@ public void dropFromExplorerOnEmptyDiagramNode() {
199214
String emptyDiagramNodeDescriptionId = this.diagramDescriptionIdProvider.getNodeDescriptionId(GeneralViewEmptyDiagramNodeDescriptionProvider.NAME);
200215
// Ensure the existing node is the "empty diagram" one.
201216
assertThat(emptyDiagramNode).hasDescriptionId(emptyDiagramNodeDescriptionId);
202-
this.dropFromExplorerTester.dropFromExplorer(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID,
203-
this.diagram,
204-
emptyDiagramNode.getId(),
205-
semanticElementId.get());
217+
this.dropFromExplorerTester.dropFromExplorer(GeneralViewAddExistingElementsTestProjectData.EDITING_CONTEXT_ID, this.diagram, emptyDiagramNode.getId(), semanticElementId.get());
206218
});
207219

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

226238
private String getSemanticElementWithTargetObjectLabel(IEditingContext editingContext, String targetObjectLabel) {
227-
Object semanticRootObject = this.objectSearchService.getObject(editingContext,
228-
GeneralViewAddExistingElementsTestProjectData.SemanticIds.PACKAGE_1_ID).orElse(null);
239+
Object semanticRootObject = this.objectSearchService.getObject(editingContext, GeneralViewAddExistingElementsTestProjectData.SemanticIds.PACKAGE_1_ID).orElse(null);
229240
assertThat(semanticRootObject).isInstanceOf(Package.class);
230241
Package rootPackage = (Package) semanticRootObject;
231242
Optional<Element> optPartUsage = rootPackage.getOwnedMember().stream().filter(m -> Objects.equals(m.getName(), targetObjectLabel)).findFirst();

backend/application/syson-application/src/test/java/org/eclipse/syson/application/data/GeneralViewAddExistingElementsTestProjectData.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public static final class SemanticIds {
3939

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

42+
public static final String GENERAL_VIEW_VIEW_USAGE_ID = "b67872fa-5900-48d3-88f0-e6ced193c8ec";
43+
4244
public static final String SUCCESSION_START_ACTION_2_IDS = "18d6f2fc-2182-4217-8da2-bf68c36ffa41";
4345
}
4446

backend/application/syson-application/src/test/java/org/eclipse/syson/tree/explorer/view/handlers/DropTreeItemHandlerTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ public void beforeEach() {
8080
this.givenInitialServerState.initialize();
8181
}
8282

83-
@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.")
84-
@Sql(scripts = { SimpleProjectElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
83+
@DisplayName("GIVEN a SySML project, WHEN drag an dropping a PartDefinition on a Package, THEN the PartDefinition should be moved under the Package.")
84+
@Sql(scripts = { SimpleProjectElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD,
85+
config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
8586
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
8687
@Test
8788
public void checkDnDPartDefinitionOnPackage() {
@@ -153,8 +154,9 @@ public void checkDnDPartDefinitionOnPackage() {
153154

154155
}
155156

156-
@DisplayName("Given a SySML project, when drag an dropping an element into one of its descendant, then the selected element should not be moved")
157-
@Sql(scripts = { SimpleProjectElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
157+
@DisplayName("GIVEN a SySML project, WHEN drag an dropping an Element into one of its descendant, THEN the selected Element should not be moved")
158+
@Sql(scripts = { SimpleProjectElementsTestProjectData.SCRIPT_PATH }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD,
159+
config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
158160
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
159161
@Test
160162
public void checkForbiddenDropOnDescendant() {
@@ -211,5 +213,4 @@ public void checkForbiddenDropOnDescendant() {
211213
.verify(Duration.ofSeconds(10));
212214

213215
}
214-
215216
}

backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ public Element dropElementFromExplorer(Element element, IEditingContext editingC
392392
}
393393
if (optElementToDrop.isPresent()) {
394394
this.dropElementFromExplorerInTarget(optElementToDrop.get(), targetElement, editingContext, diagramContext, selectedNode, convertedNodes);
395-
this.updateExposedElements(targetElement, optElementToDrop.get(), editingContext, diagramContext);
396395
}
397396
}
398397
}

doc/content/modules/user-manual/pages/release-notes/2025.8.0.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
== Bug fixes
1616

17-
- Fix an issue that made the _Expand All_ tool not work consistently in SysON _Explorer_ view
17+
- Fix an issue that made the _Expand All_ tool not work consistently in SysON _Explorer_ view.
18+
- 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.
1819

1920
== Improvements
2021

0 commit comments

Comments
 (0)