Skip to content

Commit

Permalink
[2759] Completes CHANGELOG Breaking changes
Browse files Browse the repository at this point in the history
* Remove some formatter annotations
* Fix unsafe check in DialogContext.tsx

Bug: #2759
Signed-off-by: Florian Barbin <[email protected]>
  • Loading branch information
florianbarbin committed Jul 3, 2024
1 parent 5d87461 commit eb6761d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 35 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ 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<RepresentationMetadata> 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.
- https://github.com/eclipse-sirius/sirius-web/issues/2759[#2759] [diagram] Update some API relative to the diagram:

* The `NodeTool#selectionDescription` attribute of type `SelectionDescription` has been renamed into `dialogDescription` and is now of type `DialogDescription`.
* The `SelectionDescription` type has been renamed into `SelectionDialogDescription` and inherit from `DialogDescription`.
* The `InvokeSingleClickOnDiagramElementToolInput#selectedObjectId` has been replaced by a `variables: [ToolVariable!]!` to make it possible to provide any kind of variable to the backend context.

```
Expand All @@ -61,6 +63,11 @@ type SingleClickOnDiagramElementTool implements Tool {
targetDescriptions: [DiagramElementDescription!]!
}
```
* The `String` attribute `org.eclipse.sirius.components.collaborative.diagrams.dto.InvokeSingleClickOnDiagramElementToolInput#selectedObjectId` has been replaced by the attribute `variables` of type `List<ToolVariable>`
* The `String` attribute `org.eclipse.sirius.components.collaborative.diagrams.dto.SingleClickOnDiagramElementTool#selectionDescriptionId` has been replaced by the attribute `dialog` of type `Dialog`
* The `String` attribute `org.eclipse.sirius.components.diagrams.tools.SingleClickOnDiagramElementTool` has been replaced by the attribute `dialog` of type `Dialog`
* The `Palette` component in `sirius-components-diagrams` has a new property `diagramElementTargetObjectId` that represents the id of the diagram element target object.
* The `DiagramPalette` component in `sirius-components-diagrams` has a new property `diagramTargetObjectId: string` that represents the diagram target object.

=== Dependency update

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public CompatibilityPaletteProvider(IIdentifierProvider identifierProvider, IODe
this.odesignRegistry = Objects.requireNonNull(odesignRegistry);
this.interpreterFactory = Objects.requireNonNull(interpreterFactory);
}

@Override
public boolean canHandle(DiagramDescription diagramDescription) {
return this.identifierProvider.findVsmElementId(diagramDescription.getId()).isPresent();
Expand Down Expand Up @@ -149,7 +148,6 @@ private ITool convertTool(org.eclipse.sirius.components.diagrams.tools.ITool too

private ToolSection filteredTools(Object targetElement, Object diagramElement, ToolSection toolSection, org.eclipse.sirius.diagram.description.DiagramDescription siriusDiagramDescription,
Object diagramElementDescription) {
// @formatter:off
List<ITool> tools = toolSection.tools().stream()
.filter(tool -> {
boolean keepTool = false;
Expand Down Expand Up @@ -177,7 +175,6 @@ private ToolSection filteredTools(Object targetElement, Object diagramElement, T
return keepTool;
})
.toList();
// @formatter:on
return new ToolSection(toolSection.id(), toolSection.label(), toolSection.iconURL(), tools);
}

Expand All @@ -201,12 +198,10 @@ private Optional<EObject> getDiagramElementMapping(Object diagramElementDescript
String descriptionId = this.getDescriptionId(diagramElementDescription);
var optionalVsmElementId = this.identifierProvider.findVsmElementId(descriptionId);
if (optionalVsmElementId.isPresent()) {
// @formatter:off
return this.odesignRegistry.getODesigns().stream()
.map(EObject::eResource).map(r -> r.getResourceSet().getEObject(URI.createURI(optionalVsmElementId.get()), false))
.filter(Objects::nonNull)
.findFirst();
// @formatter:on
}
return Optional.empty();
}
Expand All @@ -233,21 +228,17 @@ private List<DiagramElementMapping> getSiriusToolMappings(AbstractToolDescriptio
}

private List<DiagramElementMapping> getParentMappings(List<DiagramElementMapping> mappings) {
//@formatter:off
return mappings.stream()
.map(DiagramElementMapping::eContainer)
.filter(DiagramElementMapping.class::isInstance)
.map(DiagramElementMapping.class::cast)
.toList();
//@formatter:on
}

private boolean atLeastOneRootMapping(List<DiagramElementMapping> mappings) {
//@formatter:off
return mappings.stream()
.map(DiagramElementMapping::eContainer)
.anyMatch(Layer.class::isInstance);
//@formatter:on
}

private String getDescriptionId(Object diagramElementDescription) {
Expand Down Expand Up @@ -293,7 +284,6 @@ private List<ToolSection> createExtraToolSections(Object diagramElementDescripti

List<IDiagramElementDescription> targetDescriptions = new ArrayList<>();
boolean unsynchronizedMapping = false;
//@formatter:off
if (diagramElementDescription instanceof NodeDescription nodeDescription) {
targetDescriptions.add(nodeDescription);
unsynchronizedMapping = SynchronizationPolicy.UNSYNCHRONIZED.equals(nodeDescription.getSynchronizationPolicy());
Expand Down Expand Up @@ -332,6 +322,5 @@ private List<ToolSection> createExtraToolSections(Object diagramElementDescripti
extraToolSections.add(graphicalDeleteToolSection);
}
return extraToolSections;
//@formatter:on
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,11 @@ private boolean isSupported(AbstractToolDescription toolDescription) {

private ToolSection convertToolSection(org.eclipse.sirius.diagram.description.tool.ToolSection siriusToolSection, List<ITool> tools) {
String toolSectionLabel = Optional.ofNullable(siriusToolSection.getLabel()).orElse(siriusToolSection.getName());
// @formatter:off
return ToolSection.newToolSection(toolSectionLabel)
.tools(tools)
.label(toolSectionLabel)
.iconURL(this.getImagePathFromIconPath(siriusToolSection))
.build();
// @formatter:on
}

private List<AbstractToolDescription> getToolDescriptions(org.eclipse.sirius.diagram.description.tool.ToolSection toolSection) {
Expand All @@ -187,7 +185,6 @@ private List<AbstractToolDescription> getToolDescriptions(org.eclipse.sirius.dia
}

private List<IDiagramElementDescription> getParentNodeDescriptions(List<? extends AbstractNodeMapping> nodeMappings, Map<String, NodeDescription> id2NodeDescriptions) {
//@formatter:off
return nodeMappings.stream()
.map(AbstractNodeMapping::eContainer)
.filter(AbstractNodeMapping.class::isInstance)
Expand All @@ -199,15 +196,12 @@ private List<IDiagramElementDescription> getParentNodeDescriptions(List<? extend
.filter(IDiagramElementDescription.class::isInstance)
.map(IDiagramElementDescription.class::cast)
.toList();
//@formatter:on
}

private boolean atLeastOneRootMapping(List<? extends AbstractNodeMapping> nodeMappings) {
//@formatter:off
return nodeMappings.stream()
.map(AbstractNodeMapping::eContainer)
.anyMatch(Layer.class::isInstance);
//@formatter:on
}

private Optional<ITool> convertTool(Map<String, NodeDescription> id2NodeDescriptions, List<EdgeDescription> edgeDescriptions,
Expand Down Expand Up @@ -239,7 +233,6 @@ private SingleClickOnDiagramElementTool convertNodeCreationDescription(Map<Strin
Dialog dialog = selectModelElementVariableOpt
.map(selectModelElementVariable -> new Dialog(this.identifierProvider.getIdentifier(selectModelElementVariable), SelectionDescription.TYPE))
.orElse(null);
// @formatter:off
return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(id)
.label(label)
.iconURL(imagePath)
Expand All @@ -248,7 +241,6 @@ private SingleClickOnDiagramElementTool convertNodeCreationDescription(Map<Strin
.appliesToDiagramRoot(this.atLeastOneRootMapping(nodeCreationTool.getNodeMappings()))
.dialog(dialog)
.build();
// @formatter:on
}

private SingleClickOnDiagramElementTool convertContainerCreationDescription(Map<String, NodeDescription> id2NodeDescriptions, AQLInterpreter interpreter,
Expand All @@ -261,7 +253,6 @@ private SingleClickOnDiagramElementTool convertContainerCreationDescription(Map<
Dialog dialog = selectModelElementVariableOpt
.map(selectModelElementVariable -> new Dialog(this.identifierProvider.getIdentifier(selectModelElementVariable), SelectionDescription.TYPE))
.orElse(null);
// @formatter:off
return SingleClickOnDiagramElementTool.newSingleClickOnDiagramElementTool(id)
.label(label)
.iconURL(imagePath)
Expand All @@ -270,7 +261,6 @@ private SingleClickOnDiagramElementTool convertContainerCreationDescription(Map<
.appliesToDiagramRoot(this.atLeastOneRootMapping(containerCreationDescription.getContainerMappings()))
.dialog(dialog)
.build();
// @formatter:on
}

private SingleClickOnDiagramElementTool convertToolDescription(Map<String, NodeDescription> id2NodeDescriptions, List<EdgeDescription> edgeDescriptions, AQLInterpreter interpreter,
Expand All @@ -281,7 +271,6 @@ private SingleClickOnDiagramElementTool convertToolDescription(Map<String, NodeD

List<DiagramElementMapping> mappings = this.getAllDiagramElementMappings(siriusDiagramDescription);

// @formatter:off
List<String> targetDescriptionIds = mappings.stream()
.map(this.identifierProvider::getIdentifier)
.toList();
Expand Down Expand Up @@ -313,7 +302,6 @@ private SingleClickOnDiagramElementTool convertToolDescription(Map<String, NodeD
.targetDescriptions(targetDescriptions)
.appliesToDiagramRoot(true)
.build();
// @formatter:on
}

private SingleClickOnDiagramElementTool convertOperationAction(Map<String, NodeDescription> id2NodeDescriptions, List<EdgeDescription> edgeDescriptions, AQLInterpreter interpreter,
Expand All @@ -324,7 +312,6 @@ private SingleClickOnDiagramElementTool convertOperationAction(Map<String, NodeD

List<DiagramElementMapping> mappings = this.getAllDiagramElementMappings(siriusDiagramDescription);

// @formatter:off
List<String> targetDescriptionIds = mappings.stream()
.map(this.identifierProvider::getIdentifier)
.toList();
Expand Down Expand Up @@ -354,7 +341,6 @@ private SingleClickOnDiagramElementTool convertOperationAction(Map<String, NodeD
.targetDescriptions(targetDescriptions)
.appliesToDiagramRoot(true)
.build();
// @formatter:on
}

private List<DiagramElementMapping> getAllDiagramElementMappings(DiagramDescription siriusDiagramDescription) {
Expand Down Expand Up @@ -592,13 +578,11 @@ private Object getParentNode(Node node, Diagram diagram) {
if (nodes.contains(node)) {
parentNode = diagram;
} else {
// @formatter:off
parentNode = nodes.stream()
.map(subNode -> this.getParentNode(node, subNode))
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
// @formatter:on
}
}
return parentNode;
Expand All @@ -609,13 +593,11 @@ private Node getParentNode(Node node, Node nodeContainer) {
if (nodes.contains(node)) {
return nodeContainer;
}
// @formatter:off
return nodes.stream()
.map(subNode -> this.getParentNode(node, subNode))
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
// @formatter:on
}

private List<String> getImagePathFromIconPath(org.eclipse.sirius.diagram.description.tool.ToolSection toolSection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ public InvokeSingleClickOnDiagramElementToolEventHandler(IObjectService objectSe
this.toolService = Objects.requireNonNull(toolService);
this.messageService = Objects.requireNonNull(messageService);

// @formatter:off
this.counter = Counter.builder(Monitoring.EVENT_HANDLER)
.tag(Monitoring.NAME, this.getClass().getSimpleName())
.register(meterRegistry);
// @formatter:on
}

@Override
Expand All @@ -106,11 +104,9 @@ public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDesc

if (diagramInput instanceof InvokeSingleClickOnDiagramElementToolInput input) {
Diagram diagram = diagramContext.getDiagram();
// @formatter:off
var optionalTool = this.toolService.findToolById(editingContext, diagram, input.toolId())
.filter(SingleClickOnDiagramElementTool.class::isInstance)
.map(SingleClickOnDiagramElementTool.class::cast);
// @formatter:on
if (optionalTool.isPresent()) {
IStatus status = this.executeTool(editingContext, diagramContext, input.diagramElementId(), optionalTool.get(), input.startingPositionX(), input.startingPositionY(),
input.variables());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ export const DialogContextProvider = ({ children }) => {
onClose,
};
if (state.open && state.dialogTypeId) {
const dialogTypeId: string = state.dialogTypeId;
const dialogContribution: DiagramDialogContribution | undefined = dialogContributions.find((dialogContribution) =>
dialogContribution.canHandle(state.dialogTypeId as string)
dialogContribution.canHandle(dialogTypeId)
);
if (dialogContribution) {
DialogComponent = dialogContribution.component;
Expand Down

0 comments on commit eb6761d

Please sign in to comment.