-
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 dd123a8
Showing
29 changed files
with
2,080 additions
and
622 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
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
76 changes: 76 additions & 0 deletions
76
...lipse/sirius/components/view/builder/generated/SelectionDialogTreeDescriptionBuilder.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,76 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023, 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.components.view.builder.generated; | ||
|
||
/** | ||
* Builder for SelectionDialogTreeDescriptionBuilder. | ||
* | ||
* @author BuilderGenerator | ||
* @generated | ||
*/ | ||
public class SelectionDialogTreeDescriptionBuilder { | ||
|
||
/** | ||
* Create instance org.eclipse.sirius.components.view.diagram.SelectionDialogTreeDescription. | ||
* @generated | ||
*/ | ||
private org.eclipse.sirius.components.view.diagram.SelectionDialogTreeDescription selectionDialogTreeDescription = org.eclipse.sirius.components.view.diagram.DiagramFactory.eINSTANCE.createSelectionDialogTreeDescription(); | ||
|
||
/** | ||
* Return instance org.eclipse.sirius.components.view.diagram.SelectionDialogTreeDescription. | ||
* @generated | ||
*/ | ||
protected org.eclipse.sirius.components.view.diagram.SelectionDialogTreeDescription getSelectionDialogTreeDescription() { | ||
return this.selectionDialogTreeDescription; | ||
} | ||
|
||
/** | ||
* Return instance org.eclipse.sirius.components.view.diagram.SelectionDialogTreeDescription. | ||
* @generated | ||
*/ | ||
public org.eclipse.sirius.components.view.diagram.SelectionDialogTreeDescription build() { | ||
return this.getSelectionDialogTreeDescription(); | ||
} | ||
|
||
/** | ||
* Setter for ElementsExpression. | ||
* | ||
* @generated | ||
*/ | ||
public SelectionDialogTreeDescriptionBuilder elementsExpression(java.lang.String value) { | ||
this.getSelectionDialogTreeDescription().setElementsExpression(value); | ||
return this; | ||
} | ||
|
||
/** | ||
* Setter for ChildrenExpression. | ||
* | ||
* @generated | ||
*/ | ||
public SelectionDialogTreeDescriptionBuilder childrenExpression(java.lang.String value) { | ||
this.getSelectionDialogTreeDescription().setChildrenExpression(value); | ||
return this; | ||
} | ||
|
||
/** | ||
* Setter for IsSelectableExpression. | ||
* | ||
* @generated | ||
*/ | ||
public SelectionDialogTreeDescriptionBuilder isSelectableExpression(java.lang.String value) { | ||
this.getSelectionDialogTreeDescription().setIsSelectableExpression(value); | ||
return this; | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.