-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3763] Split the SelectionDialogDescription to prepare the Tree support #3857
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-202408261126"; | ||
|
||
@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 { | ||
sbegaudeau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use a flatMap somewhere?