-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3763] Split the SelectionDialogDescription to prepare the Tree support
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
1 parent
dd9b41e
commit c59f3a4
Showing
30 changed files
with
2,396 additions
and
840 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
57 changes: 57 additions & 0 deletions
57
...icipants/SelectionDialogDescriptionSelectionCandidatesExpressionMigrationParticipant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...ion/SelectionDialogDescriptionSelectionCandidatesExpressionMigrationParticipantTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()"); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.