From f048137624a7f6b7c088fde076bf38f02b548852 Mon Sep 17 00:00:00 2001 From: Florian Barbin Date: Tue, 25 Jun 2024 15:13:16 +0200 Subject: [PATCH] [2759] Provides the dialog type value in the NodeTool The front needs to know which kind of dialog it has to retrieve in the extension-point Bug: https://github.com/eclipse-sirius/sirius-web/issues/2759 Signed-off-by: Florian Barbin --- CHANGELOG.adoc | 29 +++++++++++++++ .../CompatibilityPaletteProvider.java | 8 ++--- .../services/diagrams/ToolProvider.java | 20 +++++------ .../dto/SingleClickOnDiagramElementTool.java | 11 +++--- ...ClickOnDiagramElementToolEventHandler.java | 14 +++----- .../main/resources/schema/diagram.graphqls | 7 +++- ...OnDiagramElementToolEventHandlerTests.java | 35 +++++++------------ .../tests/graphql/PaletteQueryRunner.java | 4 ++- .../components/diagrams/tools/Dialog.java | 28 +++++++++++++++ .../SingleClickOnDiagramElementTool.java | 14 ++++---- .../src/dialog/DialogContext.tsx | 14 ++++---- .../src/dialog/DialogContext.types.ts | 4 +-- .../diagramDialogExtensionPoint.types.ts | 2 +- .../src/dialog/useDialog.types.ts | 2 +- .../src/renderer/palette/Palette.tsx | 11 +++--- .../src/renderer/palette/Palette.types.ts | 5 +++ .../description/SelectionDescription.java | 2 ++ .../src/SelectionDialog.tsx | 2 +- .../extension/DefaultExtensionRegistry.tsx | 6 ++-- .../diagram/DialogDescriptionTypeSwitch.java | 31 ++++++++++++++++ .../view/emf/diagram/ToolConverter.java | 24 ++++++++++++- .../view/emf/diagram/ViewPaletteProvider.java | 28 +++++++++++---- 22 files changed, 215 insertions(+), 86 deletions(-) create mode 100644 packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/Dialog.java create mode 100644 packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/DialogDescriptionTypeSwitch.java diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index db5b4b5c115..f84bcf392f9 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -33,6 +33,35 @@ More existing APIs will be migrated to this new common pattern. - https://github.com/eclipse-sirius/sirius-web/issues/3634[#3634] [sirius-web] Remove `GraphQLNodeStyleFragment` from `NodeTypeRegistry`, you can specify additional fields to be retreived by the subscription using the `DocumentTransform` GraphQL API and the `apolloClientOptionsConfigurersExtensionPoint` extension point - https://github.com/eclipse-sirius/sirius-web/issues/3641[#3641] [core] `IRepresentationMetadataProvider` now defined a single method `Optional getMetadata(String representationId)` instead of separate `canHandle` and `handle` methods. + - https://github.com/eclipse-sirius/sirius-web/issues/2759[#2759] [diagram] Update the diagram GraphQL API. + + * The `InvokeSingleClickOnDiagramElementToolInput#selectedObjectId` has been replaced by a `variables: [ToolVariable!]!` to make it possible to provide any kind of variable to the backend context. + +``` + input InvokeSingleClickOnDiagramElementToolInput { + id: ID! + editingContextId: ID! + representationId: ID! + variables: [ToolVariable!]! + diagramElementId: ID! + startingPositionX: Float! + startingPositionY: Float! + toolId: ID! +} +``` + + * The `SingleClickOnDiagramElementTool#dialogDescriptionId` has been replaced by a `dialog: Dialog` field to provide the information about the dialog that the frontend needs to retrieve in the extension point. +``` +type SingleClickOnDiagramElementTool implements Tool { + id: ID! + label: String! + iconURL: [String!]! + appliesToDiagramRoot: Boolean! + dialog: Dialog + targetDescriptions: [DiagramElementDescription!]! +} +``` + === Dependency update - https://github.com/eclipse-sirius/sirius-web/issues/3510[#3510] [releng] Switch to Spring Boot 3.2.5 diff --git a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityPaletteProvider.java b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityPaletteProvider.java index 19fcb5a100f..0e92703dd96 100644 --- a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityPaletteProvider.java +++ b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityPaletteProvider.java @@ -133,7 +133,7 @@ private ITool convertTool(org.eclipse.sirius.components.diagrams.tools.ITool too if (tool instanceof org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool singleClickOnDiagramElementTool) { convertedTool = new SingleClickOnDiagramElementTool(singleClickOnDiagramElementTool.getId(), singleClickOnDiagramElementTool.getLabel(), singleClickOnDiagramElementTool.getIconURL(), singleClickOnDiagramElementTool.getTargetDescriptions(), - singleClickOnDiagramElementTool.getDialogDescriptionId(), singleClickOnDiagramElementTool.isAppliesToDiagramRoot()); + singleClickOnDiagramElementTool.getDialog(), singleClickOnDiagramElementTool.isAppliesToDiagramRoot()); } if (tool instanceof org.eclipse.sirius.components.diagrams.tools.SingleClickOnTwoDiagramElementsTool singleClickOnTwoDiagramElementsTool) { List candidates = new ArrayList<>(); @@ -314,20 +314,20 @@ private List createExtraToolSections(Object diagramElementDescripti // Graphical Delete Tool for unsynchronized mapping only (the handler is never called) if (diagramElementDescription instanceof NodeDescription || diagramElementDescription instanceof EdgeDescription) { // Edit Tool (the handler is never called) - SingleClickOnDiagramElementTool editTool = new SingleClickOnDiagramElementTool("edit", "Edit", List.of(DiagramImageConstants.EDIT_SVG), targetDescriptions, "", false); + SingleClickOnDiagramElementTool editTool = new SingleClickOnDiagramElementTool("edit", "Edit", List.of(DiagramImageConstants.EDIT_SVG), targetDescriptions, null, false); var editToolSection = new ToolSection("edit-section", "", List.of(), List.of(editTool)); extraToolSections.add(editToolSection); if (unsynchronizedMapping) { SingleClickOnDiagramElementTool graphicalDeleteTool = new SingleClickOnDiagramElementTool("graphical-delete", "Delete from diagram", - List.of(DiagramImageConstants.GRAPHICAL_DELETE_SVG), targetDescriptions, "", false); + List.of(DiagramImageConstants.GRAPHICAL_DELETE_SVG), targetDescriptions, null, false); var graphicalDeleteToolSection = new ToolSection("graphical-delete-section", "", List.of(), List.of(graphicalDeleteTool)); extraToolSections.add(graphicalDeleteToolSection); } // Semantic Delete Tool (the handler is never called) SingleClickOnDiagramElementTool semanticDeleteTool = new SingleClickOnDiagramElementTool("semantic-delete", "Delete from model", - List.of(DiagramImageConstants.SEMANTIC_DELETE_SVG), targetDescriptions, "", false); + List.of(DiagramImageConstants.SEMANTIC_DELETE_SVG), targetDescriptions, null, false); var graphicalDeleteToolSection = new ToolSection("semantic-delete-section", "", List.of(), List.of(semanticDeleteTool)); extraToolSections.add(graphicalDeleteToolSection); } diff --git a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ToolProvider.java b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ToolProvider.java index b6c7a80046b..c151c73d9e8 100644 --- a/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ToolProvider.java +++ b/packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/ToolProvider.java @@ -34,6 +34,7 @@ import org.eclipse.sirius.components.diagrams.description.EdgeDescription; import org.eclipse.sirius.components.diagrams.description.IDiagramElementDescription; import org.eclipse.sirius.components.diagrams.description.NodeDescription; +import org.eclipse.sirius.components.diagrams.tools.Dialog; import org.eclipse.sirius.components.diagrams.tools.ITool; import org.eclipse.sirius.components.diagrams.tools.Palette; import org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool; @@ -45,6 +46,7 @@ import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.Success; import org.eclipse.sirius.components.representations.VariableManager; +import org.eclipse.sirius.components.selection.description.SelectionDescription; import org.eclipse.sirius.diagram.description.AbstractNodeMapping; import org.eclipse.sirius.diagram.description.AdditionalLayer; import org.eclipse.sirius.diagram.description.ContainerMapping; @@ -234,10 +236,9 @@ private SingleClickOnDiagramElementTool convertNodeCreationDescription(Map imagePath = this.toolImageProvider.getIcon(nodeCreationTool); List targetDescriptions = this.getParentNodeDescriptions(nodeCreationTool.getNodeMappings(), id2NodeDescriptions); var selectModelElementVariableOpt = new SelectModelElementVariableProvider().getSelectModelElementVariable(nodeCreationTool.getVariable()); - String dialogDescriptionId = null; - if (selectModelElementVariableOpt.isPresent()) { - dialogDescriptionId = this.identifierProvider.getIdentifier(selectModelElementVariableOpt.get()); - } + Dialog dialog = selectModelElementVariableOpt + .map(selectModelElementVariable -> new Dialog(this.identifierProvider.getIdentifier(selectModelElementVariable), SelectionDescription.TYPE)) + .orElse(null); // @formatter:off return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(id) .label(label) @@ -245,7 +246,7 @@ private SingleClickOnDiagramElementTool convertNodeCreationDescription(Map imagePath = this.toolImageProvider.getIcon(containerCreationDescription); List targetDescriptions = this.getParentNodeDescriptions(containerCreationDescription.getContainerMappings(), id2NodeDescriptions); var selectModelElementVariableOpt = new SelectModelElementVariableProvider().getSelectModelElementVariable(containerCreationDescription.getVariable()); - String dialogDescriptionId = null; - if (selectModelElementVariableOpt.isPresent()) { - dialogDescriptionId = this.identifierProvider.getIdentifier(selectModelElementVariableOpt.get()); - } + Dialog dialog = selectModelElementVariableOpt + .map(selectModelElementVariable -> new Dialog(this.identifierProvider.getIdentifier(selectModelElementVariable), SelectionDescription.TYPE)) + .orElse(null); // @formatter:off return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(id) .label(label) @@ -268,7 +268,7 @@ private SingleClickOnDiagramElementTool convertContainerCreationDescription(Map< .handler(this.createContainerCreationHandler(interpreter, containerCreationDescription)) .targetDescriptions(targetDescriptions) .appliesToDiagramRoot(this.atLeastOneRootMapping(containerCreationDescription.getContainerMappings())) - .dialogDescriptionId(dialogDescriptionId) + .dialog(dialog) .build(); // @formatter:on } diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/SingleClickOnDiagramElementTool.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/SingleClickOnDiagramElementTool.java index 790ebcb032e..bd89fec6c65 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/SingleClickOnDiagramElementTool.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/SingleClickOnDiagramElementTool.java @@ -16,13 +16,14 @@ import java.util.Objects; import org.eclipse.sirius.components.diagrams.description.IDiagramElementDescription; +import org.eclipse.sirius.components.diagrams.tools.Dialog; /** * A tool triggered by a single click in the palette on a diagram element. * * @author mcharfadi */ -public record SingleClickOnDiagramElementTool(String id, String label, List iconURL, List targetDescriptions, String dialogDescriptionId, +public record SingleClickOnDiagramElementTool(String id, String label, List iconURL, List targetDescriptions, Dialog dialog, boolean appliesToDiagramRoot) implements ITool { public SingleClickOnDiagramElementTool { @@ -53,7 +54,7 @@ public static final class Builder { private List targetDescriptions; - private String dialogDescriptionId; + private Dialog dialog; private boolean appliesToDiagramRoot; @@ -81,13 +82,13 @@ public Builder appliesToDiagramRoot(boolean appliesToDiagramRoot) { return this; } - public Builder dialogDescriptionId(String dialogDescriptionId) { - this.dialogDescriptionId = dialogDescriptionId; + public Builder dialog(Dialog dialog) { + this.dialog = dialog; return this; } public SingleClickOnDiagramElementTool build() { - return new SingleClickOnDiagramElementTool(this.id, this.label, this.iconURL, this.targetDescriptions, this.dialogDescriptionId, this.appliesToDiagramRoot); + return new SingleClickOnDiagramElementTool(this.id, this.label, this.iconURL, this.targetDescriptions, this.dialog, this.appliesToDiagramRoot); } } diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandler.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandler.java index 15c951b5c25..7892bd9b524 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandler.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandler.java @@ -35,7 +35,6 @@ import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IObjectService; import org.eclipse.sirius.components.core.api.IPayload; -import org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService; import org.eclipse.sirius.components.diagrams.Diagram; import org.eclipse.sirius.components.diagrams.Edge; import org.eclipse.sirius.components.diagrams.Node; @@ -78,11 +77,8 @@ public class InvokeSingleClickOnDiagramElementToolEventHandler implements IDiagr private final Counter counter; - private final IRepresentationDescriptionSearchService representationDescriptionSearchService; - - public InvokeSingleClickOnDiagramElementToolEventHandler(IObjectService objectService, IDiagramQueryService diagramQueryService, IToolService toolService, - ICollaborativeDiagramMessageService messageService, MeterRegistry meterRegistry, IRepresentationDescriptionSearchService representationDescriptionSearchService) { + ICollaborativeDiagramMessageService messageService, MeterRegistry meterRegistry) { this.objectService = Objects.requireNonNull(objectService); this.diagramQueryService = Objects.requireNonNull(diagramQueryService); this.toolService = Objects.requireNonNull(toolService); @@ -93,8 +89,6 @@ public InvokeSingleClickOnDiagramElementToolEventHandler(IObjectService objectSe .tag(Monitoring.NAME, this.getClass().getSimpleName()) .register(meterRegistry); // @formatter:on - - this.representationDescriptionSearchService = Objects.requireNonNull(representationDescriptionSearchService); } @Override @@ -154,13 +148,13 @@ private IStatus executeTool(IEditingContext editingContext, IDiagramContext diag if (self.isPresent()) { VariableManager variableManager = this.populateVariableManager(editingContext, diagramContext, node, edge, self); - String dialogDescriptionId = tool.getDialogDescriptionId(); - if (dialogDescriptionId != null && !variables.isEmpty()) { + var dialog = tool.getDialog(); + if (dialog != null && !variables.isEmpty()) { this.handleDialogVariables(editingContext, variableManager, variables); } //We do not apply the tool if a dialog is defined but no variables have been provided - if (dialogDescriptionId == null || !variables.isEmpty()) { + if (dialog == null || !variables.isEmpty()) { result = tool.getHandler().apply(variableManager); Position newPosition = Position.at(startingPositionX, startingPositionY); diagramContext.getDiagramEvents().add(new SinglePositionEvent(diagramElementId, newPosition)); diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls index 30bfafd0c6e..0f269d2fe6c 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls @@ -284,10 +284,15 @@ type SingleClickOnDiagramElementTool implements Tool { label: String! iconURL: [String!]! appliesToDiagramRoot: Boolean! - dialogDescriptionId: String + dialog: Dialog targetDescriptions: [DiagramElementDescription!]! } +type Dialog { + dialogDescriptionId: String! + dialogDescriptionType: String! +} + type SingleClickOnTwoDiagramElementsTool implements Tool { id: ID! label: String! diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandlerTests.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandlerTests.java index 0cb22b9f016..6867f88addf 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandlerTests.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/test/java/org/eclipse/sirius/components/collaborative/diagrams/handlers/InvokeSingleClickOnDiagramElementToolEventHandlerTests.java @@ -37,7 +37,6 @@ import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IObjectService; import org.eclipse.sirius.components.core.api.IPayload; -import org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService; import org.eclipse.sirius.components.diagrams.ArrowStyle; import org.eclipse.sirius.components.diagrams.CollapsingState; import org.eclipse.sirius.components.diagrams.Diagram; @@ -62,6 +61,7 @@ import org.eclipse.sirius.components.diagrams.description.InsideLabelDescription; import org.eclipse.sirius.components.diagrams.description.LabelStyleDescription; import org.eclipse.sirius.components.diagrams.description.NodeDescription; +import org.eclipse.sirius.components.diagrams.tools.Dialog; import org.eclipse.sirius.components.diagrams.tools.ITool; import org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool; import org.eclipse.sirius.components.representations.IStatus; @@ -81,6 +81,8 @@ */ public class InvokeSingleClickOnDiagramElementToolEventHandlerTests { + private static final String SELECTION_DIALOG_TYPE = "SELECTION_DIALOG_TYPE"; + private static final String NAME_VARIABLE_VALUE = "nameVariableValue"; private static final String NAME_VARIABLE = "name"; @@ -133,10 +135,8 @@ public Optional findToolById(IEditingContext editingContext, Diagram diag return Optional.of(tool); } }; - var representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp(); - var handler = new InvokeSingleClickOnDiagramElementToolEventHandler(objectService, diagramQueryService, toolService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry(), - representationDescriptionSearchService); + var handler = new InvokeSingleClickOnDiagramElementToolEventHandler(objectService, diagramQueryService, toolService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry()); var input = new InvokeSingleClickOnDiagramElementToolInput(UUID.randomUUID(), EDITING_CONTEXT_ID, REPRESENTATION_ID, DIAGRAM_ID, TOOL_ID, 5.0, 8.0, VARIABLES); @@ -186,10 +186,8 @@ public Optional findToolById(IEditingContext editingContext, Diagram diag return Optional.of(tool); } }; - var representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp(); - var handler = new InvokeSingleClickOnDiagramElementToolEventHandler(objectService, diagramQueryService, toolService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry(), - representationDescriptionSearchService); + var handler = new InvokeSingleClickOnDiagramElementToolEventHandler(objectService, diagramQueryService, toolService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry()); var input = new InvokeSingleClickOnDiagramElementToolInput(UUID.randomUUID(), EDITING_CONTEXT_ID, REPRESENTATION_ID, NODE_1_ID, TOOL_ID, 5.0, 8.0, VARIABLES); @@ -246,7 +244,7 @@ public Optional findNodeById(Diagram diagram, String nodeId) { return new Success(ChangeKind.SEMANTIC_CHANGE, Map.of()); }; - var tool = this.createTool(TOOL_ID, false, List.of(nodeDescription), DIALOG_DESCRIPTION_ID, toolHandler); + var tool = this.createTool(TOOL_ID, false, List.of(nodeDescription), new Dialog(DIALOG_DESCRIPTION_ID, SELECTION_DIALOG_TYPE), toolHandler); var toolService = new IToolService.NoOp() { @Override @@ -254,10 +252,8 @@ public Optional findToolById(IEditingContext editingContext, Diagram diag return Optional.of(tool); } }; - var representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp(); - var handler = new InvokeSingleClickOnDiagramElementToolEventHandler(objectService, diagramQueryService, toolService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry(), - representationDescriptionSearchService); + var handler = new InvokeSingleClickOnDiagramElementToolEventHandler(objectService, diagramQueryService, toolService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry()); var variables = List.of(new ToolVariable(SELECTED_OBJECT, OBJECT_2_ID, ToolVariableType.OBJECT_ID), new ToolVariable(NAME_VARIABLE, NAME_VARIABLE_VALUE, ToolVariableType.STRING), new ToolVariable(SELECTED_OBJECTS, OBJECT_1_ID + "," + OBJECT_2_ID + "," + OBJECT_3_ID, ToolVariableType.OBJECT_ID_ARRAY)); @@ -314,10 +310,8 @@ public Optional findToolById(IEditingContext editingContext, Diagram diag return Optional.of(tool); } }; - var representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp(); - var handler = new InvokeSingleClickOnDiagramElementToolEventHandler(objectService, diagramQueryService, toolService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry(), - representationDescriptionSearchService); + var handler = new InvokeSingleClickOnDiagramElementToolEventHandler(objectService, diagramQueryService, toolService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry()); var input = new InvokeSingleClickOnDiagramElementToolInput(UUID.randomUUID(), EDITING_CONTEXT_ID, REPRESENTATION_ID, "anotherNodeId", TOOL_ID, 5.0, 8.0, VARIABLES); @@ -370,10 +364,8 @@ public Optional findToolById(IEditingContext editingContext, Diagram diag return Optional.of(tool); } }; - var representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp(); - var handler = new InvokeSingleClickOnDiagramElementToolEventHandler(objectService, diagramQueryService, toolService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry(), - representationDescriptionSearchService); + var handler = new InvokeSingleClickOnDiagramElementToolEventHandler(objectService, diagramQueryService, toolService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry()); var input = new InvokeSingleClickOnDiagramElementToolInput(UUID.randomUUID(), EDITING_CONTEXT_ID, REPRESENTATION_ID, EDGE_1_ID, TOOL_ID, 5.0, 8.0, VARIABLES); @@ -426,10 +418,8 @@ public Optional findToolById(IEditingContext editingContext, Diagram diag return Optional.of(tool); } }; - var representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp(); - var handler = new InvokeSingleClickOnDiagramElementToolEventHandler(objectService, diagramQueryService, toolService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry(), - representationDescriptionSearchService); + var handler = new InvokeSingleClickOnDiagramElementToolEventHandler(objectService, diagramQueryService, toolService, new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry()); var input = new InvokeSingleClickOnDiagramElementToolInput(UUID.randomUUID(), EDITING_CONTEXT_ID, REPRESENTATION_ID, "anotherEdgeId", TOOL_ID, 5.0, 8.0, VARIABLES); @@ -454,12 +444,13 @@ private SingleClickOnDiagramElementTool createTool(String toolId, boolean applie return this.createTool(toolId, appliesToDiagramRoot, diagramElementsDescriptions, null, variableManager -> new Success(ChangeKind.SEMANTIC_CHANGE, Map.of())); } - private SingleClickOnDiagramElementTool createTool(String toolId, boolean appliesToDiagramRoot, List diagramElementsDescriptions, String dialogDescriptionId, Function handler) { + private SingleClickOnDiagramElementTool createTool(String toolId, boolean appliesToDiagramRoot, List diagramElementsDescriptions, Dialog dialog, + Function handler) { return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(toolId) .label(TOOL_LABEL) .iconURL(List.of(TOOL_IMAGE_URL)) .targetDescriptions(diagramElementsDescriptions) - .dialogDescriptionId(dialogDescriptionId) + .dialog(dialog) .handler(handler) .appliesToDiagramRoot(appliesToDiagramRoot) .build(); diff --git a/packages/diagrams/backend/sirius-components-diagrams-tests/src/main/java/org/eclipse/sirius/components/diagrams/tests/graphql/PaletteQueryRunner.java b/packages/diagrams/backend/sirius-components-diagrams-tests/src/main/java/org/eclipse/sirius/components/diagrams/tests/graphql/PaletteQueryRunner.java index 798a8b58693..93f9a086ad9 100644 --- a/packages/diagrams/backend/sirius-components-diagrams-tests/src/main/java/org/eclipse/sirius/components/diagrams/tests/graphql/PaletteQueryRunner.java +++ b/packages/diagrams/backend/sirius-components-diagrams-tests/src/main/java/org/eclipse/sirius/components/diagrams/tests/graphql/PaletteQueryRunner.java @@ -65,7 +65,9 @@ query getPalette($editingContextId: ID!, $representationId: ID!, $diagramElement id } appliesToDiagramRoot - dialogDescriptionId + dialog { + dialogDescriptionId + } } } """; diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/Dialog.java b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/Dialog.java new file mode 100644 index 00000000000..61ff5bdfea7 --- /dev/null +++ b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/Dialog.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.components.diagrams.tools; + +import java.util.Objects; + +/** + * Represents the Dialog type of the SingleClickOnDiagramElementTool#dialog attribute. + * + * @author fbarbin + */ +public record Dialog(String dialogDescriptionId, String dialogDescriptionType) { + + public Dialog { + Objects.requireNonNull(dialogDescriptionId); + Objects.requireNonNull(dialogDescriptionType); + } +} diff --git a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/SingleClickOnDiagramElementTool.java b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/SingleClickOnDiagramElementTool.java index 570b757d87d..799ef18145d 100644 --- a/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/SingleClickOnDiagramElementTool.java +++ b/packages/diagrams/backend/sirius-components-diagrams/src/main/java/org/eclipse/sirius/components/diagrams/tools/SingleClickOnDiagramElementTool.java @@ -45,7 +45,7 @@ public final class SingleClickOnDiagramElementTool implements ITool { private boolean appliesToDiagramRoot; - private String dialogDescriptionId; + private Dialog dialog; private SingleClickOnDiagramElementTool() { // Prevent instantiation @@ -78,8 +78,8 @@ public String getLabel() { return this.label; } - public String getDialogDescriptionId() { - return this.dialogDescriptionId; + public Dialog getDialog() { + return this.dialog; } @Override @@ -113,7 +113,7 @@ public static final class Builder { private boolean appliesToDiagramRoot; - private String dialogDescriptionId; + private Dialog dialog; private Builder(String id) { this.id = Objects.requireNonNull(id); @@ -144,8 +144,8 @@ public Builder handler(Function handler) { return this; } - public Builder dialogDescriptionId(String dialogDescriptionId) { - this.dialogDescriptionId = dialogDescriptionId; + public Builder dialog(Dialog dialog) { + this.dialog = dialog; return this; } @@ -157,7 +157,7 @@ public SingleClickOnDiagramElementTool build() { tool.handler = Objects.requireNonNull(this.handler); tool.targetDescriptions = Objects.requireNonNull(this.targetDescriptions); tool.appliesToDiagramRoot = this.appliesToDiagramRoot; - tool.dialogDescriptionId = this.dialogDescriptionId; + tool.dialog = this.dialog; return tool; } } diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.tsx index 99f321335d5..b3e4be6ea43 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.tsx @@ -27,7 +27,7 @@ export const DialogContext = React.createContext(defaultValu export const DialogContextProvider = ({ children }) => { const [state, setState] = useState({ dialogDescriptionId: undefined, - dialogKindId: undefined, + dialogTypeId: undefined, editingContextId: undefined, targetObjectId: undefined, onConfirm: () => {}, @@ -36,22 +36,22 @@ export const DialogContextProvider = ({ children }) => { const { data: dialogContributions } = useData(diagramDialogContributionExtensionPoint); const showDialog = ( - dialogKindId: string, + dialogTypeId: string, editingContextId: string, dialogDescriptionId, targetObjectId, onConfirm: (variables: GQLToolVariable[]) => void ) => { - setState({ open: true, dialogKindId, editingContextId, dialogDescriptionId, targetObjectId, onConfirm }); + setState({ open: true, dialogTypeId, editingContextId, dialogDescriptionId, targetObjectId, onConfirm }); }; const onFinish = (toolVariables: GQLToolVariable[]) => { state.onConfirm(toolVariables); - setState((prevState) => ({ ...prevState, open: false, dialogKindId: undefined })); + setState((prevState) => ({ ...prevState, open: false, dialogTypeId: undefined })); }; const onClose = () => { - setState((prevState) => ({ ...prevState, open: false, dialogKindId: undefined })); + setState((prevState) => ({ ...prevState, open: false, dialogTypeId: undefined })); }; let DialogComponent: React.ComponentType | undefined; @@ -62,9 +62,9 @@ export const DialogContextProvider = ({ children }) => { onFinish, onClose, }; - if (state.open && state.dialogKindId) { + if (state.open && state.dialogTypeId) { const dialogContribution: DiagramDialogContribution | undefined = dialogContributions.find((dialogContribution) => - dialogContribution.canHandle(state.dialogKindId as string) + dialogContribution.canHandle(state.dialogTypeId as string) ); if (dialogContribution) { DialogComponent = dialogContribution.component; diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.types.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.types.ts index 39dd0130f5b..ffb32fc46de 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/DialogContext.types.ts @@ -15,7 +15,7 @@ import { GQLToolVariable } from '../renderer/palette/Palette.types'; export interface DialogContextValue { showDialog: ( - dialogKindId: string, + dialogTypeId: string, editingContextId: string, dialogDescriptionId: string, targetObjectId: string, @@ -25,7 +25,7 @@ export interface DialogContextValue { export interface DialogContextProviderState { open: boolean; - dialogKindId: string | undefined; + dialogTypeId: string | undefined; editingContextId: string | undefined; dialogDescriptionId: string | undefined; targetObjectId: string | undefined; diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/diagramDialogExtensionPoint.types.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/diagramDialogExtensionPoint.types.ts index 64083f7f1e1..ba01bc7f420 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/diagramDialogExtensionPoint.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/diagramDialogExtensionPoint.types.ts @@ -13,7 +13,7 @@ import { GQLToolVariable } from '../renderer/palette/Palette.types'; export interface DiagramDialogContribution { - canHandle: (dialogKindId: string) => boolean; + canHandle: (dialogTypeId: string) => boolean; component: React.ComponentType; } diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/useDialog.types.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/useDialog.types.ts index 789f91a1539..59f94ade6a4 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/useDialog.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/dialog/useDialog.types.ts @@ -13,7 +13,7 @@ import { GQLToolVariable } from '../renderer/palette/Palette.types'; export interface UseDialogValue { showDialog: ( - dialogKindId: string, + dialogTypeId: string, editingContextID: string, dialogDescriptionId: string, targetObjectId: string, diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/palette/Palette.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/palette/Palette.tsx index 71aca4ab38b..4db2b6ba32a 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/palette/Palette.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/palette/Palette.tsx @@ -97,7 +97,10 @@ const ToolFields = gql` id } appliesToDiagramRoot - dialogDescriptionId + dialog { + dialogDescriptionId + dialogDescriptionType + } } } `; @@ -421,9 +424,9 @@ export const Palette = ({ invokeSingleClickTool(tool, variables); }; showDialog( - 'SELECTION_DIALOG_ID', + tool.dialog.dialogDescriptionType, editingContextId, - tool.dialogDescriptionId, + tool.dialog.dialogDescriptionId, diagramElementTargetObjectId, onConfirm ); @@ -450,7 +453,7 @@ export const Palette = ({ break; default: if (isSingleClickOnDiagramElementTool(tool)) { - if (tool.dialogDescriptionId && diagramElementTargetObjectId) { + if (tool.dialog && diagramElementTargetObjectId) { handleDialogDescription(tool, diagramElementTargetObjectId); } else { invokeSingleClickTool(tool, []); diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/palette/Palette.types.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/palette/Palette.types.ts index 2bb665ebc1b..8eab2d206a5 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/palette/Palette.types.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/palette/Palette.types.ts @@ -97,7 +97,12 @@ export interface GQLTool { export interface GQLSingleClickOnDiagramElementTool extends GQLTool { appliesToDiagramRoot: boolean; + dialog: GQLDialog; +} + +export interface GQLDialog { dialogDescriptionId: string; + dialogDescriptionType: string; } export interface GQLGetToolSectionsVariables { diff --git a/packages/selection/backend/sirius-components-selection/src/main/java/org/eclipse/sirius/components/selection/description/SelectionDescription.java b/packages/selection/backend/sirius-components-selection/src/main/java/org/eclipse/sirius/components/selection/description/SelectionDescription.java index 46152955270..c67835f5a9c 100644 --- a/packages/selection/backend/sirius-components-selection/src/main/java/org/eclipse/sirius/components/selection/description/SelectionDescription.java +++ b/packages/selection/backend/sirius-components-selection/src/main/java/org/eclipse/sirius/components/selection/description/SelectionDescription.java @@ -30,6 +30,8 @@ @Immutable public final class SelectionDescription implements IRepresentationDescription { + public static final String TYPE = "SELECTION_DIALOG_TYPE"; + private String id; private String label; diff --git a/packages/selection/frontend/sirius-components-selection/src/SelectionDialog.tsx b/packages/selection/frontend/sirius-components-selection/src/SelectionDialog.tsx index 9965a4da815..ea757ecde6b 100644 --- a/packages/selection/frontend/sirius-components-selection/src/SelectionDialog.tsx +++ b/packages/selection/frontend/sirius-components-selection/src/SelectionDialog.tsx @@ -71,7 +71,7 @@ const useSelectionObjectModalStyles = makeStyles((_theme) => }) ); -export const SELECTION_DIALOG_ID: string = 'SELECTION_DIALOG_ID'; +export const SELECTION_DIALOG_TYPE: string = 'SELECTION_DIALOG_TYPE'; export const SelectionDialog = ({ editingContextId, diff --git a/packages/sirius-web/frontend/sirius-web-application/src/extension/DefaultExtensionRegistry.tsx b/packages/sirius-web/frontend/sirius-web-application/src/extension/DefaultExtensionRegistry.tsx index a52dda2a3c2..c9d766867fb 100644 --- a/packages/sirius-web/frontend/sirius-web-application/src/extension/DefaultExtensionRegistry.tsx +++ b/packages/sirius-web/frontend/sirius-web-application/src/extension/DefaultExtensionRegistry.tsx @@ -49,7 +49,7 @@ import { NewProjectCard } from '../views/project-browser/create-projects-area/Ne import { ShowAllProjectTemplatesCard } from '../views/project-browser/create-projects-area/ShowAllProjectTemplatesCard'; import { UploadProjectCard } from '../views/project-browser/create-projects-area/UploadProjectCard'; -import { SELECTION_DIALOG_ID, SelectionDialog } from '@eclipse-sirius/sirius-components-selection'; +import { SELECTION_DIALOG_TYPE, SelectionDialog } from '@eclipse-sirius/sirius-components-selection'; const getType = (representation: RepresentationMetadata): string | null => { const query = representation.kind.substring(representation.kind.indexOf('?') + 1, representation.kind.length); const params = new URLSearchParams(query); @@ -181,8 +181,8 @@ defaultExtensionRegistry.addComponent(diagramPanelActionExtensionPoint, { *******************************************************************************/ const diagramDialogContributions: DiagramDialogContribution[] = [ { - canHandle: (dialogKindId: string) => { - return SELECTION_DIALOG_ID === dialogKindId; + canHandle: (dialogTypeId: string) => { + return SELECTION_DIALOG_TYPE === dialogTypeId; }, component: SelectionDialog, }, diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/DialogDescriptionTypeSwitch.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/DialogDescriptionTypeSwitch.java new file mode 100644 index 00000000000..7f05e0b6a67 --- /dev/null +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/DialogDescriptionTypeSwitch.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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.components.view.emf.diagram; + +import org.eclipse.sirius.components.selection.description.SelectionDescription; +import org.eclipse.sirius.components.view.diagram.SelectionDialogDescription; +import org.eclipse.sirius.components.view.diagram.util.DiagramSwitch; + +/** + * A switch dedicated to retrieve dialog kind value. + * + * @author fbarbin + */ +public class DialogDescriptionTypeSwitch extends DiagramSwitch { + + @Override + public String caseSelectionDialogDescription(SelectionDialogDescription selectionDialogDescription) { + return SelectionDescription.TYPE; + } + +} diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/ToolConverter.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/ToolConverter.java index acd0afd5e13..d46d0599d06 100644 --- a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/ToolConverter.java +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/ToolConverter.java @@ -17,6 +17,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.UUID; import java.util.function.Function; @@ -26,6 +27,7 @@ import org.eclipse.sirius.components.core.api.IEditService; import org.eclipse.sirius.components.core.api.IFeedbackMessageService; import org.eclipse.sirius.components.core.api.IObjectService; +import org.eclipse.sirius.components.diagrams.tools.Dialog; import org.eclipse.sirius.components.diagrams.tools.ITool; import org.eclipse.sirius.components.diagrams.tools.Palette; import org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool; @@ -36,6 +38,7 @@ import org.eclipse.sirius.components.representations.IStatus; import org.eclipse.sirius.components.representations.VariableManager; import org.eclipse.sirius.components.view.diagram.DiagramToolSection; +import org.eclipse.sirius.components.view.diagram.DialogDescription; import org.eclipse.sirius.components.view.diagram.EdgeTool; import org.eclipse.sirius.components.view.diagram.EdgeToolSection; import org.eclipse.sirius.components.view.diagram.NodeDescription; @@ -172,6 +175,7 @@ private ToolSection createToolSection(EdgeToolSection toolSection, ViewDiagramDe private ITool createNodeTool(NodeTool nodeTool, ViewDiagramDescriptionConverterContext converterContext, boolean appliesToDiagramRoot) { var convertedNodes = Collections.unmodifiableMap(converterContext.getConvertedNodes()); String toolId = this.idProvider.apply(nodeTool).toString(); + Dialog dialog = this.createDialog(nodeTool); return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(toolId) .label(nodeTool.getName()) .iconURL(this.toolIconURLProvider(nodeTool.getIconURLsExpression(), ViewToolImageProvider.NODE_CREATION_TOOL_ICON, converterContext.getInterpreter())) @@ -181,11 +185,29 @@ private ITool createNodeTool(NodeTool nodeTool, ViewDiagramDescriptionConverterC return this.execute(converterContext, convertedNodes, nodeTool, child); }) .targetDescriptions(List.of()) - .dialogDescriptionId(this.objectService.getId(nodeTool.getDialogDescription())) + .dialog(dialog) .appliesToDiagramRoot(appliesToDiagramRoot) .build(); } + private Dialog createDialog(NodeTool nodeTool) { + return Optional.ofNullable(nodeTool.getDialogDescription()) + .map(this::convertToDialog) + .orElse(null); + } + + private String getDialogType(DialogDescription dialogDescription) { + return new DialogDescriptionTypeSwitch().doSwitch(dialogDescription); + } + + private Dialog convertToDialog(DialogDescription dialogDescription) { + String dialogType = this.getDialogType(dialogDescription); + if (dialogType != null) { + return new Dialog(this.objectService.getId(dialogDescription), dialogType); + } + return null; + } + private ITool createEdgeTool(EdgeTool edgeTool, NodeDescription nodeDescription, ViewDiagramDescriptionConverterContext converterContext) { var convertedNodes = Collections.unmodifiableMap(converterContext.getConvertedNodes()); String toolId = this.idProvider.apply(edgeTool).toString(); diff --git a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/ViewPaletteProvider.java b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/ViewPaletteProvider.java index 2580276234e..982beb9cf3f 100644 --- a/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/ViewPaletteProvider.java +++ b/packages/view/backend/sirius-components-view-emf/src/main/java/org/eclipse/sirius/components/view/emf/diagram/ViewPaletteProvider.java @@ -42,12 +42,14 @@ import org.eclipse.sirius.components.diagrams.description.IDiagramElementDescription; import org.eclipse.sirius.components.diagrams.description.NodeDescription; import org.eclipse.sirius.components.diagrams.description.SynchronizationPolicy; +import org.eclipse.sirius.components.diagrams.tools.Dialog; import org.eclipse.sirius.components.interpreter.AQLInterpreter; import org.eclipse.sirius.components.interpreter.Result; import org.eclipse.sirius.components.interpreter.Status; import org.eclipse.sirius.components.representations.VariableManager; import org.eclipse.sirius.components.view.View; import org.eclipse.sirius.components.view.diagram.DiagramToolSection; +import org.eclipse.sirius.components.view.diagram.DialogDescription; import org.eclipse.sirius.components.view.diagram.EdgeTool; import org.eclipse.sirius.components.view.diagram.EdgeToolSection; import org.eclipse.sirius.components.view.diagram.NodeTool; @@ -175,20 +177,34 @@ private ITool createNodeTool(NodeTool viewNodeTool, VariableManager variableMana private ITool createNodeTool(NodeTool viewNodeTool, boolean appliesToDiagramRoot, VariableManager variableManager, AQLInterpreter interpreter) { String toolId = this.idProvider.apply(viewNodeTool).toString(); List iconURLProvider = this.nodeToolIconURLProvider(viewNodeTool, interpreter, variableManager); - String dialogDescriptionId = ""; - if (viewNodeTool.getDialogDescription() != null) { - dialogDescriptionId = this.objectService.getId(viewNodeTool.getDialogDescription()); - } - + Dialog dialog = this.createDialog(viewNodeTool); return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(toolId) .label(viewNodeTool.getName()) .iconURL(iconURLProvider) - .dialogDescriptionId(dialogDescriptionId) + .dialog(dialog) .targetDescriptions(List.of()) .appliesToDiagramRoot(appliesToDiagramRoot) .build(); } + private Dialog createDialog(NodeTool nodeTool) { + return Optional.ofNullable(nodeTool.getDialogDescription()) + .map(this::convertToDialog) + .orElse(null); + } + + private Dialog convertToDialog(DialogDescription dialogDescription) { + String dialogType = this.getDialogType(dialogDescription); + if (dialogType != null) { + return new Dialog(this.objectService.getId(dialogDescription), dialogType); + } + return null; + } + + private String getDialogType(DialogDescription dialogDescription) { + return new DialogDescriptionTypeSwitch().doSwitch(dialogDescription); + } + private Palette getNodePalette(IEditingContext editingContext, DiagramDescription diagramDescription, NodeDescription nodeDescription, List extraToolSections, VariableManager variableManager, AQLInterpreter interpreter) { Optional sourceElementId = this.getSourceElementId(nodeDescription.getId());