diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index c97331788ab..89aa4f90f3e 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -16,6 +16,11 @@ - https://github.com/eclipse-sirius/sirius-web/issues/3562[#3562] [sirius-web] Update displayed default model creation action. + Projects that have a nature and need the action to create an empty model will need to register the empty model action like it is done in `StudioEditingContextActionProvider`. +- https://github.com/eclipse-sirius/sirius-web/issues/3597[#3597] [core] `IRepresentationEventProcessorFactory`, `IRepresentationEventProcessor` and `IEditingContextEventProcessor` change to the signature of the methods in order to create RepresentationEventProcessor without the need of `Class representationEventProcessorClass` to : + * `boolean canHandle(IRepresentationConfiguration configuration)`; + * `Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext)`; + * `public Optional acquireRepresentationEventProcessor(IRepresentationConfiguration configuration, IInput input)`; + * `Flux getSubscription(String editingContextId, IRepresentationConfiguration representationConfiguration, IInput input);` === Dependency update @@ -70,6 +75,7 @@ - https://github.com/eclipse-sirius/sirius-web/issues/3558[#3558] [core] Avoid all representation migration overhead when not needed - https://github.com/eclipse-sirius/sirius-web/issues/3595[#3595] [core] Avoid re-rendering the workbench when the selection does not really change - https://github.com/eclipse-sirius/sirius-web/issues/3601[#3601] [sirius-web] Extract test helper classes to sirius-web-tests +- https://github.com/eclipse-sirius/sirius-web/issues/3597[#3597] [core] Improve the creation of `RepresentationEventProcessor` == v2024.5.0 diff --git a/packages/charts/backend/sirius-components-collaborative-charts/src/main/java/org/eclipse/sirius/components/collaborative/charts/HierarchyEventProcessorFactory.java b/packages/charts/backend/sirius-components-collaborative-charts/src/main/java/org/eclipse/sirius/components/collaborative/charts/HierarchyEventProcessorFactory.java index 1401ba502da..a3fd283adfd 100644 --- a/packages/charts/backend/sirius-components-collaborative-charts/src/main/java/org/eclipse/sirius/components/collaborative/charts/HierarchyEventProcessorFactory.java +++ b/packages/charts/backend/sirius-components-collaborative-charts/src/main/java/org/eclipse/sirius/components/collaborative/charts/HierarchyEventProcessorFactory.java @@ -46,28 +46,22 @@ public HierarchyEventProcessorFactory(IRepresentationSearchService representatio } @Override - public boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration) { - return IHierarchyEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof HierarchyConfiguration; + public boolean canHandle(IRepresentationConfiguration configuration) { + return configuration instanceof HierarchyConfiguration; } @Override - public Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IEditingContext editingContext) { - if (IHierarchyEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof HierarchyConfiguration) { - HierarchyConfiguration hierarchyConfiguration = (HierarchyConfiguration) configuration; + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { + if (configuration instanceof HierarchyConfiguration hierarchyConfiguration) { var optionalHierarchy = this.representationSearchService.findById(editingContext, hierarchyConfiguration.getId(), Hierarchy.class); if (optionalHierarchy.isPresent()) { Hierarchy hierarchy = optionalHierarchy.get(); - // @formatter:off HierarchyContext hierarchyContext = new HierarchyContext(hierarchy); IRepresentationEventProcessor hierarchyEventProcessor = new HierarchyEventProcessor(editingContext, hierarchyContext, this.subscriptionManagerFactory.create(), this.hierarchyCreationService, this.representationSearchService); - return Optional.of(hierarchyEventProcessor) - .filter(representationEventProcessorClass::isInstance) - .map(representationEventProcessorClass::cast); - // @formatter:on + return Optional.of(hierarchyEventProcessor); } } return Optional.empty(); diff --git a/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/api/IEditingContextEventProcessor.java b/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/api/IEditingContextEventProcessor.java index c0ed8575f56..2d0b8236843 100644 --- a/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/api/IEditingContextEventProcessor.java +++ b/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/api/IEditingContextEventProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2021 Obeo. + * Copyright (c) 2019, 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 @@ -29,7 +29,7 @@ public interface IEditingContextEventProcessor extends IDisposablePublisher { String getEditingContextId(); - Optional acquireRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, IInput input); + Optional acquireRepresentationEventProcessor(IRepresentationConfiguration configuration, IInput input); List getRepresentationEventProcessors(); @@ -59,8 +59,7 @@ public String getEditingContextId() { } @Override - public Optional acquireRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IInput input) { + public Optional acquireRepresentationEventProcessor(IRepresentationConfiguration configuration, IInput input) { return Optional.empty(); } diff --git a/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/api/IRepresentationEventProcessorComposedFactory.java b/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/api/IRepresentationEventProcessorComposedFactory.java index 10cee3e08a6..9ce497da8f6 100644 --- a/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/api/IRepresentationEventProcessorComposedFactory.java +++ b/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/api/IRepresentationEventProcessorComposedFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2020 Obeo. + * Copyright (c) 2019, 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 @@ -22,6 +22,5 @@ * @author sbegaudeau */ public interface IRepresentationEventProcessorComposedFactory { - Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IEditingContext editingContext); + Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext); } diff --git a/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/api/IRepresentationEventProcessorFactory.java b/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/api/IRepresentationEventProcessorFactory.java index 3646a7e3155..f4c3c256c7f 100644 --- a/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/api/IRepresentationEventProcessorFactory.java +++ b/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/api/IRepresentationEventProcessorFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2020 Obeo. + * Copyright (c) 2019, 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 @@ -22,8 +22,7 @@ * @author sbegaudeau */ public interface IRepresentationEventProcessorFactory { - boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration); + boolean canHandle(IRepresentationConfiguration configuration); - Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IEditingContext editingContext); + Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext); } diff --git a/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/editingcontext/EditingContextEventProcessor.java b/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/editingcontext/EditingContextEventProcessor.java index 8b0408d4a16..750876bdbc2 100644 --- a/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/editingcontext/EditingContextEventProcessor.java +++ b/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/editingcontext/EditingContextEventProcessor.java @@ -351,18 +351,14 @@ private void handleRepresentationInput(One payloadSink, IRepresentatio } @Override - public Optional acquireRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IInput input) { + public Optional acquireRepresentationEventProcessor(IRepresentationConfiguration configuration, IInput input) { var getRepresentationEventProcessorSample = Timer.start(this.meterRegistry); var optionalRepresentationEventProcessor = Optional.ofNullable(this.representationEventProcessors.get(configuration.getId())) - .map(RepresentationEventProcessorEntry::getRepresentationEventProcessor) - .filter(representationEventProcessorClass::isInstance) - .map(representationEventProcessorClass::cast); + .map(RepresentationEventProcessorEntry::getRepresentationEventProcessor); if (!optionalRepresentationEventProcessor.isPresent()) { - optionalRepresentationEventProcessor = this.representationEventProcessorComposedFactory.createRepresentationEventProcessor(representationEventProcessorClass, configuration, - this.editingContext); + optionalRepresentationEventProcessor = this.representationEventProcessorComposedFactory.createRepresentationEventProcessor(configuration, this.editingContext); if (optionalRepresentationEventProcessor.isPresent()) { var representationEventProcessor = optionalRepresentationEventProcessor.get(); diff --git a/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/editingcontext/RepresentationEventProcessorComposedFactory.java b/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/editingcontext/RepresentationEventProcessorComposedFactory.java index 8376e9f9389..4badad0ff37 100644 --- a/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/editingcontext/RepresentationEventProcessorComposedFactory.java +++ b/packages/core/backend/sirius-components-collaborative/src/main/java/org/eclipse/sirius/components/collaborative/editingcontext/RepresentationEventProcessorComposedFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2020 Obeo. + * Copyright (c) 2019, 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 @@ -42,14 +42,11 @@ public RepresentationEventProcessorComposedFactory(List Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IEditingContext editingContext) { - // @formatter:off + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { return this.factories.stream() - .filter(factory -> factory.canHandle(representationEventProcessorClass, configuration)) + .filter(factory -> factory.canHandle(configuration)) .findFirst() - .flatMap(factory -> factory.createRepresentationEventProcessor(representationEventProcessorClass, configuration, editingContext)); - // @formatter:on + .flatMap(factory -> factory.createRepresentationEventProcessor(configuration, editingContext)); } } diff --git a/packages/core/backend/sirius-components-graphql-api/src/main/java/org/eclipse/sirius/components/graphql/api/IEventProcessorSubscriptionProvider.java b/packages/core/backend/sirius-components-graphql-api/src/main/java/org/eclipse/sirius/components/graphql/api/IEventProcessorSubscriptionProvider.java index eab312f11d9..f9e1c4b6ac5 100644 --- a/packages/core/backend/sirius-components-graphql-api/src/main/java/org/eclipse/sirius/components/graphql/api/IEventProcessorSubscriptionProvider.java +++ b/packages/core/backend/sirius-components-graphql-api/src/main/java/org/eclipse/sirius/components/graphql/api/IEventProcessorSubscriptionProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022 Obeo. + * Copyright (c) 2022, 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 @@ -13,7 +13,6 @@ package org.eclipse.sirius.components.graphql.api; import org.eclipse.sirius.components.collaborative.api.IRepresentationConfiguration; -import org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor; import org.eclipse.sirius.components.core.api.IInput; import org.eclipse.sirius.components.core.api.IPayload; @@ -25,8 +24,7 @@ * @author sbegaudeau */ public interface IEventProcessorSubscriptionProvider { - Flux getSubscription(String editingContextId, Class representationEventProcessorClass, - IRepresentationConfiguration representationConfiguration, IInput input); + Flux getSubscription(String editingContextId, IRepresentationConfiguration representationConfiguration, IInput input); /** * Implementation which does nothing, used for mocks in unit tests. @@ -36,8 +34,7 @@ Flux getSubscription(String class NoOp implements IEventProcessorSubscriptionProvider { @Override - public Flux getSubscription(String editingContextId, Class representationEventProcessorClass, - IRepresentationConfiguration representationConfiguration, IInput input) { + public Flux getSubscription(String editingContextId, IRepresentationConfiguration representationConfiguration, IInput input) { return Flux.empty(); } diff --git a/packages/deck/backend/sirius-components-collaborative-deck/src/main/java/org/eclipse/sirius/components/collaborative/deck/DeckEventProcessorFactory.java b/packages/deck/backend/sirius-components-collaborative-deck/src/main/java/org/eclipse/sirius/components/collaborative/deck/DeckEventProcessorFactory.java index 1b319539639..4241ee913ba 100644 --- a/packages/deck/backend/sirius-components-collaborative-deck/src/main/java/org/eclipse/sirius/components/collaborative/deck/DeckEventProcessorFactory.java +++ b/packages/deck/backend/sirius-components-collaborative-deck/src/main/java/org/eclipse/sirius/components/collaborative/deck/DeckEventProcessorFactory.java @@ -23,7 +23,6 @@ import org.eclipse.sirius.components.collaborative.api.IRepresentationSearchService; import org.eclipse.sirius.components.collaborative.api.ISubscriptionManagerFactory; import org.eclipse.sirius.components.collaborative.deck.api.IDeckEventHandler; -import org.eclipse.sirius.components.collaborative.deck.api.IDeckEventProcessor; import org.eclipse.sirius.components.collaborative.deck.service.DeckCreationService; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.deck.Deck; @@ -57,14 +56,14 @@ public DeckEventProcessorFactory(IRepresentationSearchService representationSear } @Override - public boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration) { - return IDeckEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof DeckConfiguration; + public boolean canHandle(IRepresentationConfiguration configuration) { + return configuration instanceof DeckConfiguration; } @Override - public Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { - if (IDeckEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof DeckConfiguration deckConfiguration) { + if (configuration instanceof DeckConfiguration deckConfiguration) { var optionalDeck = this.representationSearchService.findById(editingContext, deckConfiguration.getId(), Deck.class); if (optionalDeck.isPresent()) { Deck deck = optionalDeck.get(); @@ -73,7 +72,7 @@ public Optional createRepresentatio IRepresentationEventProcessor deckEventProcessor = new DeckEventProcessor(editingContext, this.subscriptionManagerFactory.create(), this.deckCreationService, this.deckEventHandlers, deckContext, this.representationPersistenceService, this.representationSearchService); - return Optional.of(deckEventProcessor).map(representationEventProcessorClass::cast); + return Optional.of(deckEventProcessor); } } return Optional.empty(); diff --git a/packages/deck/backend/sirius-components-deck-graphql/src/main/java/org/eclipse/sirius/components/deck/graphql/datafetchers/subscription/SubscriptionDeckDiagramEventDataFetcher.java b/packages/deck/backend/sirius-components-deck-graphql/src/main/java/org/eclipse/sirius/components/deck/graphql/datafetchers/subscription/SubscriptionDeckDiagramEventDataFetcher.java index 18b049cbde8..9bc14ed0bb7 100644 --- a/packages/deck/backend/sirius-components-deck-graphql/src/main/java/org/eclipse/sirius/components/deck/graphql/datafetchers/subscription/SubscriptionDeckDiagramEventDataFetcher.java +++ b/packages/deck/backend/sirius-components-deck-graphql/src/main/java/org/eclipse/sirius/components/deck/graphql/datafetchers/subscription/SubscriptionDeckDiagramEventDataFetcher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 Obeo. + * 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 @@ -20,7 +20,6 @@ import org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher; import org.eclipse.sirius.components.collaborative.deck.DeckConfiguration; -import org.eclipse.sirius.components.collaborative.deck.api.IDeckEventProcessor; import org.eclipse.sirius.components.collaborative.deck.dto.input.DeckEventInput; import org.eclipse.sirius.components.core.api.IPayload; import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; @@ -64,7 +63,7 @@ public Publisher> get(DataFetchingEnvironment enviro localContext.put(LocalContextConstants.EDITING_CONTEXT_ID, input.editingContextId()); localContext.put(LocalContextConstants.REPRESENTATION_ID, input.deckId()); - return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), IDeckEventProcessor.class, deckConfiguration, input), input) + return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), deckConfiguration, input), input) .map(payload -> DataFetcherResult.newResult() .data(payload) .localContext(localContext) diff --git a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/DiagramEventProcessorFactory.java b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/DiagramEventProcessorFactory.java index b4342ed5c53..2b008b1b4a2 100644 --- a/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/DiagramEventProcessorFactory.java +++ b/packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/DiagramEventProcessorFactory.java @@ -27,7 +27,6 @@ import org.eclipse.sirius.components.collaborative.diagrams.api.DiagramConfiguration; import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramCreationService; import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventHandler; -import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventProcessor; import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramInputReferencePositionProvider; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService; @@ -71,14 +70,13 @@ public DiagramEventProcessorFactory(RepresentationEventProcessorFactoryConfigura } @Override - public boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration) { - return IDiagramEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof DiagramConfiguration; + public boolean canHandle(IRepresentationConfiguration configuration) { + return configuration instanceof DiagramConfiguration; } @Override - public Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IEditingContext editingContext) { - if (IDiagramEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof DiagramConfiguration diagramConfiguration) { + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { + if (configuration instanceof DiagramConfiguration diagramConfiguration) { var optionalDiagram = this.representationSearchService.findById(editingContext, diagramConfiguration.getId(), Diagram.class); if (optionalDiagram.isPresent()) { Diagram diagram = optionalDiagram.get(); @@ -99,9 +97,7 @@ public Optional createRepresentatio IRepresentationEventProcessor diagramEventProcessor = new DiagramEventProcessor(parameters); - return Optional.of(diagramEventProcessor) - .filter(representationEventProcessorClass::isInstance) - .map(representationEventProcessorClass::cast); + return Optional.of(diagramEventProcessor); } } return Optional.empty(); diff --git a/packages/diagrams/backend/sirius-components-diagrams-graphql/src/main/java/org/eclipse/sirius/components/diagrams/graphql/datafetchers/subscription/SubscriptionDiagramEventDataFetcher.java b/packages/diagrams/backend/sirius-components-diagrams-graphql/src/main/java/org/eclipse/sirius/components/diagrams/graphql/datafetchers/subscription/SubscriptionDiagramEventDataFetcher.java index 72922a0e922..d61faba25f8 100644 --- a/packages/diagrams/backend/sirius-components-diagrams-graphql/src/main/java/org/eclipse/sirius/components/diagrams/graphql/datafetchers/subscription/SubscriptionDiagramEventDataFetcher.java +++ b/packages/diagrams/backend/sirius-components-diagrams-graphql/src/main/java/org/eclipse/sirius/components/diagrams/graphql/datafetchers/subscription/SubscriptionDiagramEventDataFetcher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022, 2023 Obeo. + * Copyright (c) 2022, 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 @@ -19,7 +19,6 @@ import org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher; import org.eclipse.sirius.components.collaborative.diagrams.api.DiagramConfiguration; -import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventProcessor; import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramEventInput; import org.eclipse.sirius.components.core.api.IPayload; import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; @@ -64,7 +63,7 @@ public Publisher> get(DataFetchingEnvironment enviro localContext.put(LocalContextConstants.EDITING_CONTEXT_ID, input.editingContextId()); localContext.put(LocalContextConstants.REPRESENTATION_ID, input.diagramId()); - return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), IDiagramEventProcessor.class, diagramConfiguration, input), input) + return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), diagramConfiguration, input), input) .map(payload -> DataFetcherResult.newResult() .data(payload) .localContext(localContext) diff --git a/packages/formdescriptioneditors/backend/sirius-components-collaborative-formdescriptioneditors/src/main/java/org/eclipse/sirius/components/collaborative/formdescriptioneditors/FormDescriptionEditorEventProcessorFactory.java b/packages/formdescriptioneditors/backend/sirius-components-collaborative-formdescriptioneditors/src/main/java/org/eclipse/sirius/components/collaborative/formdescriptioneditors/FormDescriptionEditorEventProcessorFactory.java index 5ed33a294da..c23d64c3b25 100644 --- a/packages/formdescriptioneditors/backend/sirius-components-collaborative-formdescriptioneditors/src/main/java/org/eclipse/sirius/components/collaborative/formdescriptioneditors/FormDescriptionEditorEventProcessorFactory.java +++ b/packages/formdescriptioneditors/backend/sirius-components-collaborative-formdescriptioneditors/src/main/java/org/eclipse/sirius/components/collaborative/formdescriptioneditors/FormDescriptionEditorEventProcessorFactory.java @@ -26,7 +26,6 @@ import org.eclipse.sirius.components.collaborative.formdescriptioneditors.api.FormDescriptionEditorConfiguration; import org.eclipse.sirius.components.collaborative.formdescriptioneditors.api.IFormDescriptionEditorCreationService; import org.eclipse.sirius.components.collaborative.formdescriptioneditors.api.IFormDescriptionEditorEventHandler; -import org.eclipse.sirius.components.collaborative.formdescriptioneditors.api.IFormDescriptionEditorEventProcessor; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService; import org.eclipse.sirius.components.formdescriptioneditors.FormDescriptionEditor; @@ -63,34 +62,23 @@ public FormDescriptionEditorEventProcessorFactory(RepresentationEventProcessorFa } @Override - public boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration) { - return IFormDescriptionEditorEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof FormDescriptionEditorConfiguration; + public boolean canHandle(IRepresentationConfiguration configuration) { + return configuration instanceof FormDescriptionEditorConfiguration; } @Override - public Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { - if (IFormDescriptionEditorEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof FormDescriptionEditorConfiguration) { - FormDescriptionEditorConfiguration formDescriptionEditorConfiguration = (FormDescriptionEditorConfiguration) configuration; - + if (configuration instanceof FormDescriptionEditorConfiguration formDescriptionEditorConfiguration) { Optional optionalFormDescriptionEditor = this.representationSearchService.findById(editingContext, formDescriptionEditorConfiguration.getId(), FormDescriptionEditor.class); if (optionalFormDescriptionEditor.isPresent()) { FormDescriptionEditor formDescriptionEditor = optionalFormDescriptionEditor.get(); FormDescriptionEditorContext formDescriptionEditorContext = new FormDescriptionEditorContext(formDescriptionEditor); - var parameters = FormDescriptionEditorEventProcessorParameters.newFormDescriptionEditorEventProcessorParameters() - .editingContext(editingContext) - .formDescriptionEditorContext(formDescriptionEditorContext) - .formDescriptionEditorEventHandlers(this.formDescriptionEditorEventHandlers) - .subscriptionManager(this.subscriptionManagerFactory.create()) - .formDescriptionEditorCreationService(this.formDescriptionEditorCreationService) - .representationDescriptionSearchService(this.representationDescriptionSearchService) - .representationSearchService(this.representationSearchService) - .representationRefreshPolicyRegistry(this.representationRefreshPolicyRegistry) - .build(); - IRepresentationEventProcessor formDescriptionEditorEventProcessor = new FormDescriptionEditorEventProcessor(parameters); + IRepresentationEventProcessor formDescriptionEditorEventProcessor = new FormDescriptionEditorEventProcessor(editingContext, formDescriptionEditorContext, this.formDescriptionEditorEventHandlers, + this.subscriptionManagerFactory.create(), this.formDescriptionEditormCreationService, this.representationDescriptionSearchService, this.representationRefreshPolicyRegistry); - return Optional.of(formDescriptionEditorEventProcessor).filter(representationEventProcessorClass::isInstance).map(representationEventProcessorClass::cast); + return Optional.of(formDescriptionEditorEventProcessor); } } return Optional.empty(); diff --git a/packages/formdescriptioneditors/backend/sirius-components-formdescriptioneditors-graphql/src/main/java/org/eclipse/sirius/components/formdescriptioneditors/graphql/datafetchers/subscription/SubscriptionFormDescriptionEditorEventDataFetcher.java b/packages/formdescriptioneditors/backend/sirius-components-formdescriptioneditors-graphql/src/main/java/org/eclipse/sirius/components/formdescriptioneditors/graphql/datafetchers/subscription/SubscriptionFormDescriptionEditorEventDataFetcher.java index 5237f0d1bdf..df68329abbd 100644 --- a/packages/formdescriptioneditors/backend/sirius-components-formdescriptioneditors-graphql/src/main/java/org/eclipse/sirius/components/formdescriptioneditors/graphql/datafetchers/subscription/SubscriptionFormDescriptionEditorEventDataFetcher.java +++ b/packages/formdescriptioneditors/backend/sirius-components-formdescriptioneditors-graphql/src/main/java/org/eclipse/sirius/components/formdescriptioneditors/graphql/datafetchers/subscription/SubscriptionFormDescriptionEditorEventDataFetcher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022, 2023 Obeo. + * Copyright (c) 2022, 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 @@ -19,7 +19,6 @@ import org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher; import org.eclipse.sirius.components.collaborative.formdescriptioneditors.api.FormDescriptionEditorConfiguration; -import org.eclipse.sirius.components.collaborative.formdescriptioneditors.api.IFormDescriptionEditorEventProcessor; import org.eclipse.sirius.components.collaborative.formdescriptioneditors.dto.FormDescriptionEditorEventInput; import org.eclipse.sirius.components.core.api.IPayload; import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; @@ -72,7 +71,7 @@ public Publisher> get(DataFetchingEnvironment enviro localContext.put(LocalContextConstants.EDITING_CONTEXT_ID, input.editingContextId()); localContext.put(LocalContextConstants.REPRESENTATION_ID, input.formDescriptionEditorId()); - return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), IFormDescriptionEditorEventProcessor.class, formDescriptionEditorConfiguration, input), input) + return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), formDescriptionEditorConfiguration, input), input) .map(payload -> DataFetcherResult.newResult() .data(payload) .localContext(localContext) diff --git a/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/FormEventProcessorFactory.java b/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/FormEventProcessorFactory.java index 857bffd3010..6727b482456 100644 --- a/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/FormEventProcessorFactory.java +++ b/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/FormEventProcessorFactory.java @@ -26,7 +26,6 @@ import org.eclipse.sirius.components.collaborative.forms.api.FormConfiguration; import org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters; import org.eclipse.sirius.components.collaborative.forms.api.IFormEventHandler; -import org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor; import org.eclipse.sirius.components.collaborative.forms.api.IFormPostProcessor; import org.eclipse.sirius.components.collaborative.forms.api.IWidgetSubscriptionManagerFactory; import org.eclipse.sirius.components.collaborative.forms.configuration.FormEventProcessorConfiguration; @@ -79,14 +78,13 @@ public FormEventProcessorFactory(RepresentationEventProcessorFactoryConfiguratio } @Override - public boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration) { - return IFormEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof FormConfiguration; + public boolean canHandle(IRepresentationConfiguration configuration) { + return configuration instanceof FormConfiguration; } @Override - public Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IEditingContext editingContext) { - if (IFormEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof FormConfiguration formConfiguration) { + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { + if (configuration instanceof FormConfiguration formConfiguration) { Optional
optionalForm = this.representationSearchService.findById(editingContext, formConfiguration.getId(), Form.class); if (optionalForm.isPresent()) { @@ -115,10 +113,7 @@ public Optional createRepresentatio this.representationRefreshPolicyRegistry, this.formPostProcessor); - return Optional.of(formEventProcessor) - .filter(representationEventProcessorClass::isInstance) - .map(representationEventProcessorClass::cast); - + return Optional.of(formEventProcessor); } } } diff --git a/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/PropertiesEventProcessorFactory.java b/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/PropertiesEventProcessorFactory.java index b540694fa88..985b79a5152 100644 --- a/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/PropertiesEventProcessorFactory.java +++ b/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/PropertiesEventProcessorFactory.java @@ -26,7 +26,6 @@ import org.eclipse.sirius.components.collaborative.api.RepresentationEventProcessorFactoryConfiguration; import org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters; import org.eclipse.sirius.components.collaborative.forms.api.IFormEventHandler; -import org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor; import org.eclipse.sirius.components.collaborative.forms.api.IFormPostProcessor; import org.eclipse.sirius.components.collaborative.forms.api.IPropertiesDefaultDescriptionProvider; import org.eclipse.sirius.components.collaborative.forms.api.IPropertiesDescriptionService; @@ -86,14 +85,13 @@ public PropertiesEventProcessorFactory(IPropertiesDescriptionService propertiesD } @Override - public boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration) { - return IFormEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof PropertiesConfiguration; + public boolean canHandle(IRepresentationConfiguration configuration) { + return configuration instanceof PropertiesConfiguration; } @Override - public Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IEditingContext editingContext) { - if (IFormEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof PropertiesConfiguration propertiesConfiguration) { + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { + if (configuration instanceof PropertiesConfiguration propertiesConfiguration) { List pageDescriptions = this.propertiesDescriptionService.getPropertiesDescriptions(); var objects = propertiesConfiguration.getObjectIds().stream() @@ -122,9 +120,7 @@ public Optional createRepresentatio this.representationRefreshPolicyRegistry, this.formPostProcessor); - return Optional.of(formEventProcessor) - .filter(representationEventProcessorClass::isInstance) - .map(representationEventProcessorClass::cast); + return Optional.of(formEventProcessor); } } return Optional.empty(); diff --git a/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/RelatedElementsEventProcessorFactory.java b/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/RelatedElementsEventProcessorFactory.java index 8db45e1892a..f8724b9b977 100644 --- a/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/RelatedElementsEventProcessorFactory.java +++ b/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/RelatedElementsEventProcessorFactory.java @@ -25,7 +25,6 @@ import org.eclipse.sirius.components.collaborative.api.RepresentationEventProcessorFactoryConfiguration; import org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters; import org.eclipse.sirius.components.collaborative.forms.api.IFormEventHandler; -import org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor; import org.eclipse.sirius.components.collaborative.forms.api.IFormPostProcessor; import org.eclipse.sirius.components.collaborative.forms.api.IRelatedElementsDescriptionProvider; import org.eclipse.sirius.components.collaborative.forms.api.IWidgetSubscriptionManagerFactory; @@ -78,14 +77,14 @@ public RelatedElementsEventProcessorFactory(RepresentationEventProcessorFactoryC } @Override - public boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration) { - return IFormEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof RelatedElementsConfiguration; + public boolean canHandle(IRepresentationConfiguration configuration) { + return configuration instanceof RelatedElementsConfiguration; } @Override - public Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { - if (IFormEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof RelatedElementsConfiguration relatedElementsConfiguration) { + if (configuration instanceof RelatedElementsConfiguration relatedElementsConfiguration) { var objects = relatedElementsConfiguration.getObjectIds().stream() .map(objectId -> this.objectService.getObject(editingContext, objectId)) @@ -108,9 +107,7 @@ public Optional createRepresentatio this.representationRefreshPolicyRegistry, this.formPostProcessor); - return Optional.of(formEventProcessor) - .filter(representationEventProcessorClass::isInstance) - .map(representationEventProcessorClass::cast); + return Optional.of(formEventProcessor); } } return Optional.empty(); diff --git a/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/RepresentationsEventProcessorFactory.java b/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/RepresentationsEventProcessorFactory.java index f5f0f2084ea..987169f3472 100644 --- a/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/RepresentationsEventProcessorFactory.java +++ b/packages/forms/backend/sirius-components-collaborative-forms/src/main/java/org/eclipse/sirius/components/collaborative/forms/RepresentationsEventProcessorFactory.java @@ -25,7 +25,6 @@ import org.eclipse.sirius.components.collaborative.api.RepresentationEventProcessorFactoryConfiguration; import org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters; import org.eclipse.sirius.components.collaborative.forms.api.IFormEventHandler; -import org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor; import org.eclipse.sirius.components.collaborative.forms.api.IFormPostProcessor; import org.eclipse.sirius.components.collaborative.forms.api.IRepresentationsDescriptionProvider; import org.eclipse.sirius.components.collaborative.forms.api.IWidgetSubscriptionManagerFactory; @@ -78,14 +77,13 @@ public RepresentationsEventProcessorFactory(IRepresentationsDescriptionProvider } @Override - public boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration) { - return IFormEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof RepresentationsConfiguration; + public boolean canHandle(IRepresentationConfiguration configuration) { + return configuration instanceof RepresentationsConfiguration; } @Override - public Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IEditingContext editingContext) { - if (IFormEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof RepresentationsConfiguration representationsConfiguration) { + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { + if (configuration instanceof RepresentationsConfiguration representationsConfiguration) { var objects = representationsConfiguration.getObjectIds().stream() .map(objectId -> this.objectService.getObject(editingContext, objectId)) @@ -108,9 +106,7 @@ public Optional createRepresentatio this.representationRefreshPolicyRegistry, this.formPostProcessor); - return Optional.of(formEventProcessor) - .filter(representationEventProcessorClass::isInstance) - .map(representationEventProcessorClass::cast); + return Optional.of(formEventProcessor); } } return Optional.empty(); diff --git a/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionFormEventDataFetcher.java b/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionFormEventDataFetcher.java index 414f5f92983..b729d5af88e 100644 --- a/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionFormEventDataFetcher.java +++ b/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionFormEventDataFetcher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022, 2023 Obeo. + * Copyright (c) 2022, 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 @@ -19,7 +19,6 @@ import org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher; import org.eclipse.sirius.components.collaborative.forms.api.FormConfiguration; -import org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor; import org.eclipse.sirius.components.collaborative.forms.dto.FormEventInput; import org.eclipse.sirius.components.core.api.IPayload; import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; @@ -64,7 +63,7 @@ public Publisher> get(DataFetchingEnvironment enviro localContext.put(LocalContextConstants.EDITING_CONTEXT_ID, input.editingContextId()); localContext.put(LocalContextConstants.REPRESENTATION_ID, input.formId()); - return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), IFormEventProcessor.class, formConfiguration, input), input) + return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), formConfiguration, input), input) .map(payload -> DataFetcherResult.newResult() .data(payload) .localContext(localContext) diff --git a/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionPropertiesEventDataFetcher.java b/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionPropertiesEventDataFetcher.java index 90833a7d4fa..b8387155af3 100644 --- a/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionPropertiesEventDataFetcher.java +++ b/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionPropertiesEventDataFetcher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022, 2023 Obeo. + * Copyright (c) 2022, 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 @@ -18,7 +18,6 @@ import java.util.Objects; import org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher; -import org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor; import org.eclipse.sirius.components.collaborative.forms.api.PropertiesConfiguration; import org.eclipse.sirius.components.collaborative.forms.dto.PropertiesEventInput; import org.eclipse.sirius.components.core.api.IPayload; @@ -63,7 +62,7 @@ public Publisher> get(DataFetchingEnvironment enviro localContext.put(LocalContextConstants.EDITING_CONTEXT_ID, input.editingContextId()); localContext.put(LocalContextConstants.REPRESENTATION_ID, propertiesConfiguration.getId()); - return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), IFormEventProcessor.class, propertiesConfiguration, input), input) + return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), propertiesConfiguration, input), input) .map(payload -> DataFetcherResult.newResult() .data(payload) .localContext(localContext) diff --git a/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionRelatedElementsEventDataFetcher.java b/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionRelatedElementsEventDataFetcher.java index a6edffc3e0b..12951ae6b96 100644 --- a/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionRelatedElementsEventDataFetcher.java +++ b/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionRelatedElementsEventDataFetcher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022, 2023 Obeo. + * Copyright (c) 2022, 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 @@ -18,7 +18,6 @@ import java.util.Objects; import org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher; -import org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor; import org.eclipse.sirius.components.collaborative.forms.api.RelatedElementsConfiguration; import org.eclipse.sirius.components.collaborative.forms.dto.PropertiesEventInput; import org.eclipse.sirius.components.core.api.IPayload; @@ -63,7 +62,7 @@ public Publisher> get(DataFetchingEnvironment enviro localContext.put(LocalContextConstants.EDITING_CONTEXT_ID, input.editingContextId()); localContext.put(LocalContextConstants.REPRESENTATION_ID, propertiesConfiguration.getId()); - return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), IFormEventProcessor.class, propertiesConfiguration, input), input) + return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), propertiesConfiguration, input), input) .map(payload -> DataFetcherResult.newResult() .data(payload) .localContext(localContext) diff --git a/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionRepresentationsEventDataFetcher.java b/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionRepresentationsEventDataFetcher.java index d7946ea7fcc..6c3ac881596 100644 --- a/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionRepresentationsEventDataFetcher.java +++ b/packages/forms/backend/sirius-components-forms-graphql/src/main/java/org/eclipse/sirius/components/forms/graphql/datafetchers/subscription/SubscriptionRepresentationsEventDataFetcher.java @@ -19,7 +19,6 @@ import java.util.Objects; import org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher; -import org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor; import org.eclipse.sirius.components.collaborative.forms.api.RepresentationsConfiguration; import org.eclipse.sirius.components.collaborative.forms.dto.PropertiesEventInput; import org.eclipse.sirius.components.core.api.IPayload; @@ -64,7 +63,7 @@ public Publisher> get(DataFetchingEnvironment enviro localContext.put(LocalContextConstants.EDITING_CONTEXT_ID, input.editingContextId()); localContext.put(LocalContextConstants.REPRESENTATION_ID, representationsConfiguration.getId()); - return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), IFormEventProcessor.class, representationsConfiguration, input), input) + return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), representationsConfiguration, input), input) .map(payload -> DataFetcherResult.newResult() .data(payload) .localContext(localContext) diff --git a/packages/gantt/backend/sirius-components-collaborative-gantt/src/main/java/org/eclipse/sirius/components/collaborative/gantt/GanttEventProcessorFactory.java b/packages/gantt/backend/sirius-components-collaborative-gantt/src/main/java/org/eclipse/sirius/components/collaborative/gantt/GanttEventProcessorFactory.java index 04e830f914d..a9d3fac12a9 100644 --- a/packages/gantt/backend/sirius-components-collaborative-gantt/src/main/java/org/eclipse/sirius/components/collaborative/gantt/GanttEventProcessorFactory.java +++ b/packages/gantt/backend/sirius-components-collaborative-gantt/src/main/java/org/eclipse/sirius/components/collaborative/gantt/GanttEventProcessorFactory.java @@ -23,7 +23,6 @@ import org.eclipse.sirius.components.collaborative.api.IRepresentationSearchService; import org.eclipse.sirius.components.collaborative.api.ISubscriptionManagerFactory; import org.eclipse.sirius.components.collaborative.gantt.api.IGanttEventHandler; -import org.eclipse.sirius.components.collaborative.gantt.api.IGanttEventProcessor; import org.eclipse.sirius.components.collaborative.gantt.service.GanttCreationService; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.gantt.Gantt; @@ -57,14 +56,14 @@ public GanttEventProcessorFactory(IRepresentationSearchService representationSea } @Override - public boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration) { - return IGanttEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof GanttConfiguration; + public boolean canHandle(IRepresentationConfiguration configuration) { + return configuration instanceof GanttConfiguration; } @Override - public Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { - if (IGanttEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof GanttConfiguration ganttConfiguration) { + if (configuration instanceof GanttConfiguration ganttConfiguration) { var optionalGantt = this.representationSearchService.findById(editingContext, ganttConfiguration.getId(), Gantt.class); if (optionalGantt.isPresent()) { GanttContext ganttContext = new GanttContext(optionalGantt.get()); @@ -72,7 +71,7 @@ public Optional createRepresentatio IRepresentationEventProcessor ganttEventProcessor = new GanttEventProcessor(editingContext, this.subscriptionManagerFactory.create(), this.ganttCreationService, this.representationSearchService, this.ganttEventHandlers, ganttContext, this.representationPersistenceService); - return Optional.of(ganttEventProcessor).map(representationEventProcessorClass::cast); + return Optional.of(ganttEventProcessor); } } return Optional.empty(); diff --git a/packages/gantt/backend/sirius-components-gantt-graphql/src/main/java/org/eclipse/sirius/components/gantt/graphql/datafetchers/subscription/SubscriptionGanttDiagramEventDataFetcher.java b/packages/gantt/backend/sirius-components-gantt-graphql/src/main/java/org/eclipse/sirius/components/gantt/graphql/datafetchers/subscription/SubscriptionGanttDiagramEventDataFetcher.java index b9f6c7ced6e..aada4486232 100644 --- a/packages/gantt/backend/sirius-components-gantt-graphql/src/main/java/org/eclipse/sirius/components/gantt/graphql/datafetchers/subscription/SubscriptionGanttDiagramEventDataFetcher.java +++ b/packages/gantt/backend/sirius-components-gantt-graphql/src/main/java/org/eclipse/sirius/components/gantt/graphql/datafetchers/subscription/SubscriptionGanttDiagramEventDataFetcher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 Obeo. + * 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 @@ -20,7 +20,6 @@ import org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher; import org.eclipse.sirius.components.collaborative.gantt.GanttConfiguration; -import org.eclipse.sirius.components.collaborative.gantt.api.IGanttEventProcessor; import org.eclipse.sirius.components.collaborative.gantt.dto.input.GanttEventInput; import org.eclipse.sirius.components.core.api.IPayload; import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; @@ -64,7 +63,7 @@ public Publisher> get(DataFetchingEnvironment enviro localContext.put(LocalContextConstants.EDITING_CONTEXT_ID, input.editingContextId()); localContext.put(LocalContextConstants.REPRESENTATION_ID, input.ganttId()); - return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), IGanttEventProcessor.class, ganttConfiguration, input), input) + return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), ganttConfiguration, input), input) .map(payload -> DataFetcherResult.newResult() .data(payload) .localContext(localContext) diff --git a/packages/portals/backend/sirius-components-collaborative-portals/src/main/java/org/eclipse/sirius/components/collaborative/portals/PortalEventProcessorFactory.java b/packages/portals/backend/sirius-components-collaborative-portals/src/main/java/org/eclipse/sirius/components/collaborative/portals/PortalEventProcessorFactory.java index cf398e1e8f3..773e1ffabcb 100644 --- a/packages/portals/backend/sirius-components-collaborative-portals/src/main/java/org/eclipse/sirius/components/collaborative/portals/PortalEventProcessorFactory.java +++ b/packages/portals/backend/sirius-components-collaborative-portals/src/main/java/org/eclipse/sirius/components/collaborative/portals/PortalEventProcessorFactory.java @@ -52,21 +52,18 @@ public PortalEventProcessorFactory(IRepresentationSearchService representationSe } @Override - public boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration) { - return IPortalEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof PortalConfiguration; + public boolean canHandle(IRepresentationConfiguration configuration) { + return configuration instanceof PortalConfiguration; } @Override - public Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IEditingContext editingContext) { - if (IPortalEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof PortalConfiguration portalConfiguration) { + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { + if (configuration instanceof PortalConfiguration portalConfiguration) { var optionalPortal = this.representationSearchService.findById(editingContext, portalConfiguration.getId(), Portal.class); if (optionalPortal.isPresent()) { Portal portal = optionalPortal.get(); var portalEventProcessor = new PortalEventProcessor(editingContext, this.representationSearchService, this.representationPersistenceService, this.portalEventHandlers, this.subscriptionManagerFactory.create(), portal); - return Optional.of(portalEventProcessor) - .filter(representationEventProcessorClass::isInstance) - .map(representationEventProcessorClass::cast); + return Optional.of(portalEventProcessor); } } return Optional.empty(); diff --git a/packages/portals/backend/sirius-components-portals-graphql/src/main/java/org/eclipse/sirius/components/portals/graphql/datafetchers/subscription/SubscriptionPortalEventDataFetcher.java b/packages/portals/backend/sirius-components-portals-graphql/src/main/java/org/eclipse/sirius/components/portals/graphql/datafetchers/subscription/SubscriptionPortalEventDataFetcher.java index 8b6a11098bd..93302f6ce0b 100644 --- a/packages/portals/backend/sirius-components-portals-graphql/src/main/java/org/eclipse/sirius/components/portals/graphql/datafetchers/subscription/SubscriptionPortalEventDataFetcher.java +++ b/packages/portals/backend/sirius-components-portals-graphql/src/main/java/org/eclipse/sirius/components/portals/graphql/datafetchers/subscription/SubscriptionPortalEventDataFetcher.java @@ -19,7 +19,6 @@ import java.util.Objects; import org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher; -import org.eclipse.sirius.components.collaborative.portals.IPortalEventProcessor; import org.eclipse.sirius.components.collaborative.portals.api.PortalConfiguration; import org.eclipse.sirius.components.collaborative.portals.dto.PortalEventInput; import org.eclipse.sirius.components.core.api.IPayload; @@ -64,7 +63,7 @@ public Publisher> get(DataFetchingEnvironment enviro localContext.put(LocalContextConstants.EDITING_CONTEXT_ID, input.editingContextId()); localContext.put(LocalContextConstants.REPRESENTATION_ID, portalConfiguration.getId()); - return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), IPortalEventProcessor.class, portalConfiguration, input), input) + return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), portalConfiguration, input), input) .map(payload -> DataFetcherResult.newResult() .data(payload) .localContext(localContext) diff --git a/packages/selection/backend/sirius-components-collaborative-selection/src/main/java/org/eclipse/sirius/components/collaborative/selection/SelectionEventProcessorFactory.java b/packages/selection/backend/sirius-components-collaborative-selection/src/main/java/org/eclipse/sirius/components/collaborative/selection/SelectionEventProcessorFactory.java index a2c8e86b389..5cb65314a8c 100644 --- a/packages/selection/backend/sirius-components-collaborative-selection/src/main/java/org/eclipse/sirius/components/collaborative/selection/SelectionEventProcessorFactory.java +++ b/packages/selection/backend/sirius-components-collaborative-selection/src/main/java/org/eclipse/sirius/components/collaborative/selection/SelectionEventProcessorFactory.java @@ -21,7 +21,6 @@ import org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicyRegistry; import org.eclipse.sirius.components.collaborative.api.ISubscriptionManagerFactory; import org.eclipse.sirius.components.collaborative.api.RepresentationEventProcessorFactoryConfiguration; -import org.eclipse.sirius.components.collaborative.selection.api.ISelectionEventProcessor; import org.eclipse.sirius.components.collaborative.selection.api.SelectionConfiguration; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.core.api.IObjectService; @@ -53,14 +52,13 @@ public SelectionEventProcessorFactory(RepresentationEventProcessorFactoryConfigu } @Override - public boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration) { - return ISelectionEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof SelectionConfiguration; + public boolean canHandle(IRepresentationConfiguration configuration) { + return configuration instanceof SelectionConfiguration; } @Override - public Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IEditingContext editingContext) { - if (ISelectionEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof SelectionConfiguration selectionConfiguration) { + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { + if (configuration instanceof SelectionConfiguration selectionConfiguration) { // @formatter:off Optional optionalSelectionDescription = this.representationDescriptionSearchService @@ -77,12 +75,7 @@ public Optional createRepresentatio IRepresentationEventProcessor selectionEventProcessor = new SelectionEventProcessor(editingContext, this.objectService, selectionDescription, selectionConfiguration.getId(), objectId, this.subscriptionManagerFactory.create(), this.representationRefreshPolicyRegistry); - // @formatter:off - return Optional.of(selectionEventProcessor) - .filter(representationEventProcessorClass::isInstance) - .map(representationEventProcessorClass::cast); - // @formatter:on - + return Optional.of(selectionEventProcessor); } } return Optional.empty(); diff --git a/packages/selection/backend/sirius-components-selection-graphql/src/main/java/org/eclipse/sirius/components/selection/graphql/datafetchers/subscription/SubscriptionSelectionEventDataFetcher.java b/packages/selection/backend/sirius-components-selection-graphql/src/main/java/org/eclipse/sirius/components/selection/graphql/datafetchers/subscription/SubscriptionSelectionEventDataFetcher.java index 05a8e7d55f5..a6a6537fe5f 100644 --- a/packages/selection/backend/sirius-components-selection-graphql/src/main/java/org/eclipse/sirius/components/selection/graphql/datafetchers/subscription/SubscriptionSelectionEventDataFetcher.java +++ b/packages/selection/backend/sirius-components-selection-graphql/src/main/java/org/eclipse/sirius/components/selection/graphql/datafetchers/subscription/SubscriptionSelectionEventDataFetcher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022, 2023 Obeo. + * Copyright (c) 2022, 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 @@ -19,7 +19,6 @@ import java.util.UUID; import org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher; -import org.eclipse.sirius.components.collaborative.selection.api.ISelectionEventProcessor; import org.eclipse.sirius.components.collaborative.selection.api.SelectionConfiguration; import org.eclipse.sirius.components.collaborative.selection.dto.SelectionEventInput; import org.eclipse.sirius.components.core.api.IPayload; @@ -64,7 +63,7 @@ public Publisher> get(DataFetchingEnvironment enviro localContext.put(LocalContextConstants.EDITING_CONTEXT_ID, input.editingContextId()); localContext.put(LocalContextConstants.REPRESENTATION_ID, selectionConfiguration.getId()); - return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), ISelectionEventProcessor.class, selectionConfiguration, input), input) + return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), selectionConfiguration, input), input) .map(payload -> DataFetcherResult.newResult() .data(payload) .localContext(localContext) diff --git a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/formdescritpioneditors/FormDescriptionEditorPageIntegrationTests.java b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/formdescritpioneditors/FormDescriptionEditorPageIntegrationTests.java index 5057371e5b5..f3066a0d0a8 100644 --- a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/formdescritpioneditors/FormDescriptionEditorPageIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/formdescritpioneditors/FormDescriptionEditorPageIntegrationTests.java @@ -31,7 +31,6 @@ import org.eclipse.sirius.components.collaborative.dto.CreateRootObjectInput; import org.eclipse.sirius.components.collaborative.editingcontext.EditingContextEventProcessorRegistry; import org.eclipse.sirius.components.collaborative.formdescriptioneditors.api.FormDescriptionEditorConfiguration; -import org.eclipse.sirius.components.collaborative.formdescriptioneditors.api.IFormDescriptionEditorEventProcessor; import org.eclipse.sirius.components.collaborative.formdescriptioneditors.dto.AddPageInput; import org.eclipse.sirius.components.collaborative.formdescriptioneditors.dto.DeletePageInput; import org.eclipse.sirius.components.collaborative.formdescriptioneditors.dto.FormDescriptionEditorEventInput; @@ -345,7 +344,7 @@ mutation createRepresentation($input: CreateRepresentationInput!) { public void testPageMutations() { var configuration = new FormDescriptionEditorConfiguration(this.representationId.toString()); var input = new FormDescriptionEditorEventInput(UUID.randomUUID(), this.projectId.toString(), this.representationId.toString()); - var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), IFormDescriptionEditorEventProcessor.class, configuration, input); + var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), configuration, input); AtomicReference defaultPageId = new AtomicReference<>(); AtomicReference newPageId = new AtomicReference<>(); diff --git a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ReferenceWidgetIntegrationTests.java b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ReferenceWidgetIntegrationTests.java index 4813bff11f9..5229fd92d46 100644 --- a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ReferenceWidgetIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ReferenceWidgetIntegrationTests.java @@ -31,7 +31,6 @@ import org.eclipse.sirius.components.collaborative.dto.CreateRootObjectInput; import org.eclipse.sirius.components.collaborative.editingcontext.EditingContextEventProcessorRegistry; import org.eclipse.sirius.components.collaborative.forms.api.FormConfiguration; -import org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor; import org.eclipse.sirius.components.collaborative.forms.dto.FormEventInput; import org.eclipse.sirius.components.collaborative.forms.dto.FormRefreshedEventPayload; import org.eclipse.sirius.components.core.api.IPayload; @@ -266,7 +265,7 @@ mutation createRepresentation($input: CreateRepresentationInput!) { public void canCreateFormWithSliderWidget() { var configuration = new FormConfiguration(this.representationId.toString()); var input = new FormEventInput(UUID.randomUUID(), this.projectId.toString(), this.representationId.toString()); - var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), IFormEventProcessor.class, configuration, input); + var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), configuration, input); Predicate isFormWithReferenceWdigetsRefreshedEventPayload = payload -> { if (payload instanceof FormRefreshedEventPayload formRefreshedEventPayload) { var form = formRefreshedEventPayload.form(); diff --git a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/SliderWidgetIntegrationTests.java b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/SliderWidgetIntegrationTests.java index d25596b0eee..315796e39ff 100644 --- a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/SliderWidgetIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/SliderWidgetIntegrationTests.java @@ -31,7 +31,6 @@ import org.eclipse.sirius.components.collaborative.dto.CreateRootObjectInput; import org.eclipse.sirius.components.collaborative.editingcontext.EditingContextEventProcessorRegistry; import org.eclipse.sirius.components.collaborative.forms.api.FormConfiguration; -import org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor; import org.eclipse.sirius.components.collaborative.forms.dto.FormEventInput; import org.eclipse.sirius.components.collaborative.forms.dto.FormRefreshedEventPayload; import org.eclipse.sirius.components.core.api.IPayload; @@ -266,7 +265,7 @@ mutation createRepresentation($input: CreateRepresentationInput!) { public void canCreateFormWithSliderWidget() { var configuration = new FormConfiguration(this.representationId.toString()); var input = new FormEventInput(UUID.randomUUID(), this.projectId.toString(), this.representationId.toString()); - var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), IFormEventProcessor.class, configuration, input); + var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), configuration, input); Predicate isFormWithSlidersRefreshedEventPayload = payload -> { if (payload instanceof FormRefreshedEventPayload formRefreshedEventPayload) { var form = formRefreshedEventPayload.form(); diff --git a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewDiagramIntegrationTests.java b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewDiagramIntegrationTests.java index ab4660e002e..952dd9da04a 100644 --- a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewDiagramIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewDiagramIntegrationTests.java @@ -26,7 +26,6 @@ import java.util.function.Predicate; import org.eclipse.sirius.components.collaborative.diagrams.api.DiagramConfiguration; -import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventProcessor; import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramEventInput; import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload; import org.eclipse.sirius.components.collaborative.diagrams.dto.InvokeSingleClickOnDiagramElementToolInput; @@ -326,7 +325,7 @@ mutation createRepresentation($input: CreateRepresentationInput!) { public void givenDomainAndViewWhenDocumentAndRepresentationAreCreatedThenWeCanSubscribeToTheRepresentation() { var configuration = new DiagramConfiguration(this.representationId.toString()); var input = new DiagramEventInput(UUID.randomUUID(), this.projectId.toString(), this.representationId.toString()); - var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), IDiagramEventProcessor.class, configuration, input); + var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), configuration, input); Predicate isEmptyDiagramRefreshedEventPayload = payload -> { if (payload instanceof DiagramRefreshedEventPayload diagramRefreshedEventPayload) { diff --git a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewFormIntegrationTests.java b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewFormIntegrationTests.java index 706c8652e42..8a39c76596d 100644 --- a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewFormIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewFormIntegrationTests.java @@ -31,7 +31,6 @@ import org.eclipse.sirius.components.collaborative.dto.CreateRootObjectInput; import org.eclipse.sirius.components.collaborative.editingcontext.EditingContextEventProcessorRegistry; import org.eclipse.sirius.components.collaborative.forms.api.FormConfiguration; -import org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor; import org.eclipse.sirius.components.collaborative.forms.dto.FormEventInput; import org.eclipse.sirius.components.collaborative.forms.dto.FormRefreshedEventPayload; import org.eclipse.sirius.components.core.api.IPayload; @@ -341,7 +340,7 @@ query helpText($editingContextId: ID!, $formId: ID!, $widgetId: ID!) { public void givenDomainAndViewWhenDocumentAndRepresentationAreCreatedThenWeCanSubscribeToTheRepresentation() { var configuration = new FormConfiguration(this.representationId.toString()); var input = new FormEventInput(UUID.randomUUID(), this.projectId.toString(), this.representationId.toString()); - var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), IFormEventProcessor.class, configuration, input); + var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), configuration, input); Predicate isEmptyFormRefreshedEventPayload = payload -> { if (payload instanceof FormRefreshedEventPayload formRefreshedEventPayload) { @@ -362,7 +361,7 @@ public void givenDomainAndViewWhenDocumentAndRepresentationAreCreatedThenWeCanSu public void givenRenderedRormWeCanRetrieveTheDynamicallyComputedHelpTextOfAWidget() { var configuration = new FormConfiguration(this.representationId.toString()); var input = new FormEventInput(UUID.randomUUID(), this.projectId.toString(), this.representationId.toString()); - var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), IFormEventProcessor.class, configuration, input); + var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), configuration, input); AtomicReference widgetId = new AtomicReference<>(); Predicate isEmptyFormRefreshedEventPayload = payload -> { diff --git a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewInitialDirectEditElementLabelProviderIntegrationTests.java b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewInitialDirectEditElementLabelProviderIntegrationTests.java index 73f752effc9..daae39b646c 100644 --- a/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewInitialDirectEditElementLabelProviderIntegrationTests.java +++ b/packages/sirius-web/backend/sirius-web-sample-application/src/test/java/org/eclipse/sirius/web/sample/tests/integration/view/ViewInitialDirectEditElementLabelProviderIntegrationTests.java @@ -26,7 +26,6 @@ import java.util.function.Predicate; import org.eclipse.sirius.components.collaborative.diagrams.api.DiagramConfiguration; -import org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventProcessor; import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramEventInput; import org.eclipse.sirius.components.collaborative.diagrams.dto.DiagramRefreshedEventPayload; import org.eclipse.sirius.components.collaborative.diagrams.dto.InvokeSingleClickOnDiagramElementToolInput; @@ -124,7 +123,7 @@ public void teardown() { public void initialDirectEditElementLabel() { var configuration = new DiagramConfiguration(this.representationId.toString()); var input = new DiagramEventInput(UUID.randomUUID(), this.projectId.toString(), this.representationId.toString()); - var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), IDiagramEventProcessor.class, configuration, input); + var payloadFlux = this.eventProcessorSubscriptionProvider.getSubscription(this.projectId.toString(), configuration, input); Predicate isEmptyDiagramRefreshedEventPayload = payload -> { if (payload instanceof DiagramRefreshedEventPayload diagramRefreshedEventPayload) { diff --git a/packages/sirius-web/backend/sirius-web-starter/src/main/java/org/eclipse/sirius/web/starter/SiriusWebStarterConfiguration.java b/packages/sirius-web/backend/sirius-web-starter/src/main/java/org/eclipse/sirius/web/starter/SiriusWebStarterConfiguration.java index b00deda024f..e3ef056dbb1 100644 --- a/packages/sirius-web/backend/sirius-web-starter/src/main/java/org/eclipse/sirius/web/starter/SiriusWebStarterConfiguration.java +++ b/packages/sirius-web/backend/sirius-web-starter/src/main/java/org/eclipse/sirius/web/starter/SiriusWebStarterConfiguration.java @@ -16,7 +16,6 @@ import org.eclipse.sirius.components.collaborative.api.IEditingContextEventProcessorRegistry; import org.eclipse.sirius.components.collaborative.api.IRepresentationConfiguration; -import org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor; import org.eclipse.sirius.components.collaborative.api.ISubscriptionManagerFactory; import org.eclipse.sirius.components.collaborative.editingcontext.api.IEditingContextEventProcessorExecutorServiceProvider; import org.eclipse.sirius.components.collaborative.forms.WidgetSubscriptionManager; @@ -129,9 +128,9 @@ public void afterConnectionClosed(WebSocketSession session, CloseStatus status) public IEventProcessorSubscriptionProvider eventProcessorSubscriptionProvider(IEditingContextEventProcessorRegistry editingContextEventProcessorRegistry) { return new IEventProcessorSubscriptionProvider() { @Override - public Flux getSubscription(String editingContextId, Class representationEventProcessorClass, IRepresentationConfiguration representationConfiguration, IInput input) { + public Flux getSubscription(String editingContextId, IRepresentationConfiguration representationConfiguration, IInput input) { return editingContextEventProcessorRegistry.getOrCreateEditingContextEventProcessor(editingContextId) - .flatMap(processor -> processor.acquireRepresentationEventProcessor(representationEventProcessorClass, representationConfiguration, input)) + .flatMap(processor -> processor.acquireRepresentationEventProcessor(representationConfiguration, input)) .map(representationEventProcessor -> representationEventProcessor.getOutputEvents(input)) .orElse(Flux.empty()); } diff --git a/packages/starters/backend/sirius-components-starter/src/main/java/org/eclipse/sirius/components/starter/SiriusWebStarterConfiguration.java b/packages/starters/backend/sirius-components-starter/src/main/java/org/eclipse/sirius/components/starter/SiriusWebStarterConfiguration.java index 1a2c6774b13..f6332f94bdd 100644 --- a/packages/starters/backend/sirius-components-starter/src/main/java/org/eclipse/sirius/components/starter/SiriusWebStarterConfiguration.java +++ b/packages/starters/backend/sirius-components-starter/src/main/java/org/eclipse/sirius/components/starter/SiriusWebStarterConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2023 Obeo. + * Copyright (c) 2019, 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 @@ -16,7 +16,6 @@ import org.eclipse.sirius.components.collaborative.api.IEditingContextEventProcessorRegistry; import org.eclipse.sirius.components.collaborative.api.IRepresentationConfiguration; -import org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor; import org.eclipse.sirius.components.collaborative.api.ISubscriptionManagerFactory; import org.eclipse.sirius.components.collaborative.editingcontext.api.IEditingContextEventProcessorExecutorServiceProvider; import org.eclipse.sirius.components.collaborative.forms.WidgetSubscriptionManager; @@ -128,14 +127,11 @@ public void afterConnectionClosed(WebSocketSession session, CloseStatus status) public IEventProcessorSubscriptionProvider eventProcessorSubscriptionProvider(IEditingContextEventProcessorRegistry editingContextEventProcessorRegistry) { return new IEventProcessorSubscriptionProvider() { @Override - public Flux getSubscription(String editingContextId, Class representationEventProcessorClass, - IRepresentationConfiguration representationConfiguration, IInput input) { - // @formatter:off + public Flux getSubscription(String editingContextId, IRepresentationConfiguration representationConfiguration, IInput input) { return editingContextEventProcessorRegistry.getOrCreateEditingContextEventProcessor(editingContextId) - .flatMap(processor -> processor.acquireRepresentationEventProcessor(representationEventProcessorClass, representationConfiguration, input)) + .flatMap(processor -> processor.acquireRepresentationEventProcessor(representationConfiguration, input)) .map(representationEventProcessor -> representationEventProcessor.getOutputEvents(input)) .orElse(Flux.empty()); - // @formatter:on } }; } diff --git a/packages/trees/backend/sirius-components-collaborative-trees/src/main/java/org/eclipse/sirius/components/collaborative/trees/TreeEventProcessorFactory.java b/packages/trees/backend/sirius-components-collaborative-trees/src/main/java/org/eclipse/sirius/components/collaborative/trees/TreeEventProcessorFactory.java index c9b3a043e69..d911fe13363 100644 --- a/packages/trees/backend/sirius-components-collaborative-trees/src/main/java/org/eclipse/sirius/components/collaborative/trees/TreeEventProcessorFactory.java +++ b/packages/trees/backend/sirius-components-collaborative-trees/src/main/java/org/eclipse/sirius/components/collaborative/trees/TreeEventProcessorFactory.java @@ -23,7 +23,6 @@ import org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicyRegistry; import org.eclipse.sirius.components.collaborative.api.ISubscriptionManagerFactory; import org.eclipse.sirius.components.collaborative.trees.api.ITreeEventHandler; -import org.eclipse.sirius.components.collaborative.trees.api.ITreeEventProcessor; import org.eclipse.sirius.components.collaborative.trees.api.ITreeService; import org.eclipse.sirius.components.collaborative.trees.api.TreeConfiguration; import org.eclipse.sirius.components.collaborative.trees.api.TreeCreationParameters; @@ -65,14 +64,13 @@ public TreeEventProcessorFactory(IRepresentationDescriptionSearchService represe } @Override - public boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration) { - return ITreeEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof TreeConfiguration; + public boolean canHandle(IRepresentationConfiguration configuration) { + return configuration instanceof TreeConfiguration; } @Override - public Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IEditingContext editingContext) { - if (ITreeEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof TreeConfiguration treeConfiguration) { + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { + if (configuration instanceof TreeConfiguration treeConfiguration) { Optional optionalTreeDescription = this.findTreeDescription(editingContext, treeConfiguration); if (optionalTreeDescription.isPresent()) { @@ -87,9 +85,7 @@ public Optional createRepresentatio IRepresentationEventProcessor treeEventProcessor = new TreeEventProcessor(editingContext, this.treeService, treeCreationParameters, this.treeEventHandlers, this.subscriptionManagerFactory.create(), new SimpleMeterRegistry(), this.representationRefreshPolicyRegistry); - return Optional.of(treeEventProcessor) - .filter(representationEventProcessorClass::isInstance) - .map(representationEventProcessorClass::cast); + return Optional.of(treeEventProcessor); } } return Optional.empty(); diff --git a/packages/trees/backend/sirius-components-trees-graphql/src/main/java/org/eclipse/sirius/components/trees/graphql/datafetchers/subscription/SubscriptionTreeEventDataFetcher.java b/packages/trees/backend/sirius-components-trees-graphql/src/main/java/org/eclipse/sirius/components/trees/graphql/datafetchers/subscription/SubscriptionTreeEventDataFetcher.java index 85e3fb72560..09dd6db54d7 100644 --- a/packages/trees/backend/sirius-components-trees-graphql/src/main/java/org/eclipse/sirius/components/trees/graphql/datafetchers/subscription/SubscriptionTreeEventDataFetcher.java +++ b/packages/trees/backend/sirius-components-trees-graphql/src/main/java/org/eclipse/sirius/components/trees/graphql/datafetchers/subscription/SubscriptionTreeEventDataFetcher.java @@ -19,7 +19,6 @@ import java.util.Objects; import org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher; -import org.eclipse.sirius.components.collaborative.trees.api.ITreeEventProcessor; import org.eclipse.sirius.components.collaborative.trees.api.TreeConfiguration; import org.eclipse.sirius.components.collaborative.trees.dto.TreeEventInput; import org.eclipse.sirius.components.core.api.IPayload; @@ -65,7 +64,7 @@ public Publisher> get(DataFetchingEnvironment enviro localContext.put(LocalContextConstants.EDITING_CONTEXT_ID, input.editingContextId()); localContext.put(LocalContextConstants.REPRESENTATION_ID, treeConfiguration.getId()); - return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), ITreeEventProcessor.class, treeConfiguration, input), input) + return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), treeConfiguration, input), input) .map(payload -> DataFetcherResult.newResult() .data(payload) .localContext(localContext) diff --git a/packages/validation/backend/sirius-components-collaborative-validation/src/main/java/org/eclipse/sirius/components/collaborative/validation/ValidationEventProcessorFactory.java b/packages/validation/backend/sirius-components-collaborative-validation/src/main/java/org/eclipse/sirius/components/collaborative/validation/ValidationEventProcessorFactory.java index f2f78213382..ed08fae57c0 100644 --- a/packages/validation/backend/sirius-components-collaborative-validation/src/main/java/org/eclipse/sirius/components/collaborative/validation/ValidationEventProcessorFactory.java +++ b/packages/validation/backend/sirius-components-collaborative-validation/src/main/java/org/eclipse/sirius/components/collaborative/validation/ValidationEventProcessorFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021 Obeo. + * Copyright (c) 2021, 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 @@ -23,7 +23,6 @@ import org.eclipse.sirius.components.collaborative.api.ISubscriptionManagerFactory; import org.eclipse.sirius.components.collaborative.validation.api.IValidationDescriptionProvider; import org.eclipse.sirius.components.collaborative.validation.api.IValidationEventHandler; -import org.eclipse.sirius.components.collaborative.validation.api.IValidationEventProcessor; import org.eclipse.sirius.components.collaborative.validation.api.ValidationConfiguration; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.components.validation.description.ValidationDescription; @@ -56,27 +55,21 @@ public ValidationEventProcessorFactory(IValidationDescriptionProvider validation } @Override - public boolean canHandle(Class representationEventProcessorClass, IRepresentationConfiguration configuration) { - return IValidationEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof ValidationConfiguration; + public boolean canHandle(IRepresentationConfiguration configuration) { + return configuration instanceof ValidationConfiguration; } @Override - public Optional createRepresentationEventProcessor(Class representationEventProcessorClass, IRepresentationConfiguration configuration, - IEditingContext editingContext) { - if (IValidationEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof ValidationConfiguration) { + public Optional createRepresentationEventProcessor(IRepresentationConfiguration configuration, IEditingContext editingContext) { + if (configuration instanceof ValidationConfiguration) { ValidationDescription validationDescription = this.validationDescriptionProvider.getDescription(); ValidationContext validationContext = new ValidationContext(null); IRepresentationEventProcessor validationEventProcessor = new ValidationEventProcessor(editingContext, validationDescription, validationContext, this.validationEventHandlers, this.subscriptionManagerFactory.create(), new SimpleMeterRegistry(), this.representationRefreshPolicyRegistry); - // @formatter:off - return Optional.of(validationEventProcessor) - .filter(representationEventProcessorClass::isInstance) - .map(representationEventProcessorClass::cast); - // @formatter:on + return Optional.of(validationEventProcessor); } - return Optional.empty(); } diff --git a/packages/validation/backend/sirius-components-validation-graphql/src/main/java/org/eclipse/sirius/components/validation/graphql/datafetchers/subscription/SubscriptionValidationEventDataFetcher.java b/packages/validation/backend/sirius-components-validation-graphql/src/main/java/org/eclipse/sirius/components/validation/graphql/datafetchers/subscription/SubscriptionValidationEventDataFetcher.java index 9d06d4db40d..a8ba36bcdf4 100644 --- a/packages/validation/backend/sirius-components-validation-graphql/src/main/java/org/eclipse/sirius/components/validation/graphql/datafetchers/subscription/SubscriptionValidationEventDataFetcher.java +++ b/packages/validation/backend/sirius-components-validation-graphql/src/main/java/org/eclipse/sirius/components/validation/graphql/datafetchers/subscription/SubscriptionValidationEventDataFetcher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021, 2023 Obeo. + * Copyright (c) 2021, 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 @@ -18,7 +18,6 @@ import java.util.Objects; import org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher; -import org.eclipse.sirius.components.collaborative.validation.api.IValidationEventProcessor; import org.eclipse.sirius.components.collaborative.validation.api.ValidationConfiguration; import org.eclipse.sirius.components.collaborative.validation.dto.ValidationEventInput; import org.eclipse.sirius.components.core.api.IPayload; @@ -63,7 +62,7 @@ public Publisher> get(DataFetchingEnvironment enviro localContext.put(LocalContextConstants.EDITING_CONTEXT_ID, input.editingContextId()); localContext.put(LocalContextConstants.REPRESENTATION_ID, validationConfiguration.getId()); - return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), IValidationEventProcessor.class, validationConfiguration, input), input) + return this.exceptionWrapper.wrapFlux(() -> this.eventProcessorSubscriptionProvider.getSubscription(input.editingContextId(), validationConfiguration, input), input) .map(payload -> DataFetcherResult.newResult() .data(payload) .localContext(localContext)