Skip to content

Commit

Permalink
[3763] Split the SelectionDialogDescription to prepare the Tree support
Browse files Browse the repository at this point in the history
The SelectionDialogDescription will now just hold the message
information
The SelectionDialogDescription will now have a
selectionDialogTreeDescription to make it possible for the specifier to
display the selectable elements as a tree.
The selectionDialogTreeDescription will be relatively simple at first
time.

Bug: #3763
Signed-off-by: Florian Barbin <[email protected]>
  • Loading branch information
florianbarbin committed Aug 14, 2024
1 parent 87f712c commit ce47cea
Show file tree
Hide file tree
Showing 29 changed files with 2,320 additions and 840 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ A migration participant has been added to automatically keep compatible all diag
- https://github.com/eclipse-sirius/sirius-web/issues/3782[#3782] [sirius-web] Add an extension point to contribute custom widgets
- https://github.com/eclipse-sirius/sirius-web/issues/3801[#3801] Add an equivalent of IViewDiagramDescriptionSearchService for Form descriptions
- https://github.com/eclipse-sirius/sirius-web/issues/3557[#3550] [sirius-web] Add an extension point to contribute setting pages
- https://github.com/eclipse-sirius/sirius-web/issues/3763[#3763] [diagram] Split the SelectionDialogDescription to prepare the Tree support


== v2024.7.0
Expand Down
97 changes: 97 additions & 0 deletions acceleoGeneratorSample.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
diff --git a/packages/sirius-web/backend/sirius-web-sample-application/pom.xml b/packages/sirius-web/backend/sirius-web-sample-application/pom.xml
index a3958639e..17be72d2f 100644
--- a/packages/sirius-web/backend/sirius-web-sample-application/pom.xml
+++ b/packages/sirius-web/backend/sirius-web-sample-application/pom.xml
@@ -12,8 +12,8 @@
Obeo - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
@@ -58,6 +58,14 @@
<enabled>true</enabled>
</snapshots>
</repository>
+ <repository>
+ <id>Eclipse - Acceleo Snapshots</id>
+ <url>https://repo.eclipse.org/content/repositories/acceleo-snapshots</url>
+ </repository>
+ <repository>
+ <id>Eclipse - Acceleo Release</id>
+ <url>https://repo.eclipse.org/content/repositories/acceleo-releases</url>
+ </repository>
</repositories>

<dependencies>
@@ -211,7 +219,8 @@
</dependency>
<dependency>
<groupId>org.eclipse.sirius</groupId>
- <artifactId>sirius-components-collaborative-formdescriptioneditors-widget-reference</artifactId>
+ <artifactId>
+ sirius-components-collaborative-formdescriptioneditors-widget-reference</artifactId>
<version>2024.3.0</version>
</dependency>
<dependency>
@@ -257,6 +266,46 @@
<version>2024.3.0</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>SampleGenerator</groupId>
+ <artifactId>org.eclipse.acceleo.module.sample</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.acceleo</groupId>
+ <artifactId>org.eclipse.acceleo.engine</artifactId>
+ <version>3.6.4-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.acceleo</groupId>
+ <artifactId>org.eclipse.acceleo.common</artifactId>
+ <version>3.6.4-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.acceleo</groupId>
+ <artifactId>org.eclipse.acceleo.model</artifactId>
+ <version>3.6.4-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.ocl</groupId>
+ <artifactId>org.eclipse.ocl.ecore</artifactId>
+ <version>3.3.0.v20130520-1222</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.ocl</groupId>
+ <artifactId>org.eclipse.ocl</artifactId>
+ <version>3.3.0.v20130909-1552</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.ocl</groupId>
+ <artifactId>org.eclipse.ocl.common</artifactId>
+ <version>1.1.0.v20130531-0544</version>
+ </dependency>
+ <dependency>
+ <groupId>lpg.runtime.java</groupId>
+ <artifactId>lpg.runtime.java</artifactId>
+ <version>2.0.17.v201004271640</version>
+ </dependency>
</dependencies>

<build>
@@ -277,7 +326,8 @@
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.2.0</version>
<configuration>
- <configLocation>../../../releng/backend/sirius-components-resources/checkstyle/CheckstyleConfiguration.xml</configLocation>
+ <configLocation>
+ ../../../releng/backend/sirius-components-resources/checkstyle/CheckstyleConfiguration.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<failsOnError>true</failsOnError>
<consoleOutput>true</consoleOutput>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright (c) 2024 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.sirius.web.application.editingcontext.migration.participants;

import com.google.gson.JsonObject;

import java.util.Optional;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.sirius.components.emf.migration.api.IMigrationParticipant;
import org.eclipse.sirius.components.view.builder.generated.SelectionDialogTreeDescriptionBuilder;
import org.eclipse.sirius.components.view.diagram.SelectionDialogDescription;
import org.eclipse.sirius.components.view.diagram.SelectionDialogTreeDescription;
import org.springframework.stereotype.Service;

/**
* MigrationParticipant that create a new SelectionDialogTreeDescription in the SelectionDialogDescription to replace the former SelectionDialogDescription#selectionCandidatesExpression.
* SelectionDialogDescription#selectionCandidatesExpression value is moved toward SelectionDialogDescription#selectionDialogTreeDescription#elementsExpression
*
* @author fbarbin
*/
@Service
public class SelectionDialogDescriptionSelectionCandidatesExpressionMigrationParticipant implements IMigrationParticipant {

private static final String PARTICIPANT_VERSION = "2024.9.0-202408121400";

@Override
public String getVersion() {
return PARTICIPANT_VERSION;
}

@Override
public void postObjectLoading(EObject eObject, JsonObject jsonObject) {
if (eObject instanceof SelectionDialogDescription selectionDialogDescription) {
var optionalSelectionDialogDescriptionData = Optional.ofNullable(jsonObject.getAsJsonObject("data"));
optionalSelectionDialogDescriptionData.ifPresent(selectionDialogDescriptionData -> {
var optionalSelectionCandidatesExpression = Optional.ofNullable(selectionDialogDescriptionData.get("selectionCandidatesExpression"));
optionalSelectionCandidatesExpression.ifPresent(selectionCandidatesExpression -> {
SelectionDialogTreeDescription selectionDialogTreeDescription = new SelectionDialogTreeDescriptionBuilder()
.elementsExpression(selectionCandidatesExpression.getAsString())
.build();
selectionDialogDescription.setSelectionDialogTreeDescription(selectionDialogTreeDescription);
});
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public final class MigrationIdentifiers {

public static final String MIGRATION_NODE_LABEL_STYLE_SHOW_ICON_STUDIO_DIAGRAM = "NodeLabelStyle#showIcon migration";

public static final UUID MIGRATION_SELECTION_DIALOG_DESCRIPTION_SELECTION_CANDIDATES_EXPRESSION_STUDIO = UUID.fromString("19d73d38-3de2-4d03-a8f1-ce36c2ed36db");

public static final String MIGRATION_SELECTION_DIALOG_DESCRIPTION_SELECTION_CANDIDATES_EXPRESSION_STUDIO_DIAGRAM = "SelectionDialogDescription#selectionCandidatesExpression migration";



private MigrationIdentifiers() {
// Prevent instantiation
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
import org.eclipse.sirius.components.view.builder.generated.NodeToolBuilder;
import org.eclipse.sirius.components.view.builder.generated.RectangularNodeStyleDescriptionBuilder;
import org.eclipse.sirius.components.view.builder.generated.SelectionDialogDescriptionBuilder;
import org.eclipse.sirius.components.view.builder.generated.SelectionDialogTreeDescriptionBuilder;
import org.eclipse.sirius.components.view.builder.generated.ViewBuilder;
import org.eclipse.sirius.components.view.builder.generated.ViewBuilders;
import org.eclipse.sirius.components.view.diagram.DiagramDescription;
import org.eclipse.sirius.components.view.diagram.DiagramFactory;
import org.eclipse.sirius.components.view.diagram.InsideLabelPosition;
import org.eclipse.sirius.components.view.diagram.NodeTool;
import org.eclipse.sirius.components.view.diagram.SelectionDialogTreeDescription;
import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy;
import org.eclipse.sirius.components.view.emf.diagram.IDiagramIdProvider;
import org.eclipse.sirius.emfjson.resource.JsonResource;
Expand Down Expand Up @@ -193,9 +195,13 @@ private void createCreateNodeTool() {
}

private void createRenameElementNodeTool() {

SelectionDialogTreeDescription selectionDialogTreeDescription = new SelectionDialogTreeDescriptionBuilder()
.elementsExpression("aql:self.eResource().eAllContents()")
.build();
var selectionDialog = new SelectionDialogDescriptionBuilder()
.selectionCandidatesExpression("aql:self.eResource().eAllContents()")
.selectionMessage("Select a new element")
.selectionDialogTreeDescription(selectionDialogTreeDescription)
.build();

var setSelectedComponentName = new ViewBuilders().newSetValue()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2024 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.sirius.web.services.migration;

import static org.assertj.core.api.Assertions.assertThat;

import org.eclipse.sirius.components.core.api.IEditingContext;
import org.eclipse.sirius.components.core.api.IEditingContextSearchService;
import org.eclipse.sirius.components.view.diagram.DiagramDescription;
import org.eclipse.sirius.components.view.diagram.SelectionDialogDescription;
import org.eclipse.sirius.web.AbstractIntegrationTests;
import org.eclipse.sirius.web.application.editingcontext.EditingContext;
import org.eclipse.sirius.web.data.MigrationIdentifiers;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlConfig;
import org.springframework.transaction.annotation.Transactional;

/**
* Integration tests of SelectionDialogDescriptionSelectionCandidatesExpressionMigrationParticipant.
*
* @author fbarbin
*/
@Transactional
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class SelectionDialogDescriptionSelectionCandidatesExpressionMigrationParticipantTests extends AbstractIntegrationTests {

@Autowired
private IEditingContextSearchService editingContextSearchService;

@Test
@DisplayName("Given a project with an old model, SelectionDialogDescriptionSelectionCandidatesExpressionMigrationParticipant migrates the model correctly")
@Sql(scripts = { "/scripts/migration.sql" }, executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = { "/scripts/cleanup.sql" }, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, config = @SqlConfig(transactionMode = SqlConfig.TransactionMode.ISOLATED))
public void givenAnOldModelMigrationParticipantCanBeContributedToUpdateTheModel() {
var optionalEditingContext = this.editingContextSearchService.findById(MigrationIdentifiers.MIGRATION_SELECTION_DIALOG_DESCRIPTION_SELECTION_CANDIDATES_EXPRESSION_STUDIO.toString());
assertThat(optionalEditingContext).isPresent();
this.testIsMigrationSuccessful(optionalEditingContext.get());
}

private void testIsMigrationSuccessful(IEditingContext editingContext) {
if (editingContext instanceof EditingContext siriusWebEditingContext) {
var optionalDiagramDescription = siriusWebEditingContext.getViews().stream().flatMap(view -> view.getDescriptions().stream()).filter(
representationDescription -> representationDescription.getName().equals(MigrationIdentifiers.MIGRATION_SELECTION_DIALOG_DESCRIPTION_SELECTION_CANDIDATES_EXPRESSION_STUDIO_DIAGRAM))
.findFirst();
assertThat(optionalDiagramDescription).isPresent();
assertThat(optionalDiagramDescription.get()).isInstanceOf(DiagramDescription.class);
optionalDiagramDescription.ifPresent(representationDescription -> {
if (representationDescription instanceof DiagramDescription diagramDescription) {
assertThat(diagramDescription.getPalette()).isNotNull();
var palette = diagramDescription.getPalette();
assertThat(palette.getNodeTools()).hasSize(1);
var nodeTool = palette.getNodeTools().get(0);
var dialogDescription = nodeTool.getDialogDescription();
assertThat(dialogDescription).isNotNull();
assertThat(dialogDescription).isInstanceOf(SelectionDialogDescription.class);
if (dialogDescription instanceof SelectionDialogDescription selectionDialogDescription) {
var selectionDialogTreeDescription = selectionDialogDescription.getSelectionDialogTreeDescription();
assertThat(selectionDialogTreeDescription).isNotNull();
assertThat(selectionDialogTreeDescription.getElementsExpression()).isEqualTo("aql:self.eContents()");
}
}
});
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -913,3 +913,108 @@ INSERT INTO document (
'2024-07-18 15:00:0.000',
'2024-07-18 15:00:0.000'
);


INSERT INTO project (
id,
name,
created_on,
last_modified_on
) VALUES (
'19d73d38-3de2-4d03-a8f1-ce36c2ed36db',
'Migration SelectionDialogDescription#selectionCandidatesExpression Studio',
'2024-07-18 15:00:0.000',
'2024-07-18 15:00:0.000'
);
INSERT INTO nature (
project_id,
name
) VALUES (
'19d73d38-3de2-4d03-a8f1-ce36c2ed36db',
'siriusComponents://nature?kind=studio'
);
INSERT INTO semantic_data (
id,
project_id,
created_on,
last_modified_on
) VALUES (
'06d828d9-c2c6-46d0-a9c4-7fabd588755b',
'19d73d38-3de2-4d03-a8f1-ce36c2ed36db',
'2024-07-01 15:00:0.000',
'2024-07-01 15:00:0.000'
);
INSERT INTO semantic_data_domain (
semantic_data_id,
uri
) VALUES (
'06d828d9-c2c6-46d0-a9c4-7fabd588755b',
'http://www.eclipse.org/sirius-web/view'
);
INSERT INTO semantic_data_domain (
semantic_data_id,
uri
) VALUES (
'06d828d9-c2c6-46d0-a9c4-7fabd588755b',
'http://www.eclipse.org/sirius-web/diagram'
);
INSERT INTO document (
id,
semantic_data_id,
name,
content,
created_on,
last_modified_on
) VALUES (
'8652ae06-6754-4c46-aa4c-2c8db2c3b602',
'06d828d9-c2c6-46d0-a9c4-7fabd588755b',
'SelectionDialogDescription#selectionCandidatesExpression migration',
'{
"json": { "version": "1.0", "encoding": "utf-8" },
"ns": { "diagram": "http://www.eclipse.org/sirius-web/diagram", "view": "http://www.eclipse.org/sirius-web/view" },
"content": [
{
"id": "00deb638-5c32-4d94-983d-1d00517ac82f",
"eClass": "view:View",
"data": {
"descriptions": [
{
"id": "683b678c-6263-4d21-b25a-502661859198",
"eClass": "diagram:DiagramDescription",
"data": {
"name": "SelectionDialogDescription#selectionCandidatesExpression migration",
"domainType": "wilson::Root",
"titleExpression": "wilson diagram",
"palette": {
"id": "3e54cf6c-a1d0-4eaa-bfca-48fbb9a25695",
"eClass": "diagram:DiagramPalette",
"data": {
"nodeTools": [
{
"id": "b5b0dfc1-566c-48ae-9907-00f50a553dae",
"eClass": "diagram:NodeTool",
"data": {
"name": "Selection Tool",
"dialogDescription": {
"id": "6a4e7200-2040-46fb-89c3-9060f321ecf4",
"eClass": "diagram:SelectionDialogDescription",
"data": {
"selectionCandidatesExpression": "aql:self.eContents()",
"selectionMessage": "Select an element"
}
}
}
}
]
}
}
}
}
]
}
}
]
}',
'2024-07-18 15:00:0.000',
'2024-07-18 15:00:0.000'
);
Loading

0 comments on commit ce47cea

Please sign in to comment.