-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2618] Add pre and post-process around input processing
Bug: #2618 Signed-off-by: Florian ROUËNÉ <florian.rouene@obeosoft.com>
- Loading branch information
1 parent
e1223b4
commit 155ea2c
Showing
8 changed files
with
240 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
doc/adrs/121_add_process_before_and_after_input_handling.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
= ADR-121 - Add process before and after input handling | ||
|
||
== Context | ||
|
||
Today when you create a representation, you can only do so from the target element. | ||
It is not possible, for example, to create a new intermediate semantic element to link it. | ||
|
||
== Decision | ||
|
||
Add the possibility to programmatically make some action before and after the input processing. | ||
This pre-process should be able to change the input. | ||
These actions should be able to make some semantic changes. | ||
|
||
== Solution | ||
|
||
* Add two new interfaces: | ||
|
||
[source,java] | ||
---- | ||
public interface IInputPreProcessor { | ||
IInput preProcess(IEditingContext editingContext, IInput input, Many<ChangeDescription> changeDescriptionSink); | ||
} | ||
---- | ||
|
||
[source,java] | ||
---- | ||
public interface IInputPostProcessor { | ||
void postProcess(IEditingContext editingContext, IInput input, Many<ChangeDescription> changeDescriptionSink); | ||
} | ||
---- | ||
|
||
* In the `EditingContextEventProcessor#doHandle`, before invoking the _handleInput_ method, apply all the `IInputPreProcessor#preProcess` implementation on the input. | ||
The input can be changed by the `IInputPreProcessor`, if several implementations exist, the order must be considered. | ||
|
||
* The same way, just after the _handleInput_, apply all the `IInputPostProcessor#postProcess`. | ||
|
||
== Status | ||
|
||
Accepted |
28 changes: 28 additions & 0 deletions
28
...ve/src/main/java/org/eclipse/sirius/components/collaborative/api/IInputPostProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.collaborative.api; | ||
|
||
import org.eclipse.sirius.components.core.api.IEditingContext; | ||
import org.eclipse.sirius.components.core.api.IInput; | ||
|
||
import reactor.core.publisher.Sinks.Many; | ||
|
||
/** | ||
* API to provide actions after the input processing. | ||
* | ||
* @author frouene | ||
*/ | ||
public interface IInputPostProcessor { | ||
|
||
void postProcess(IEditingContext editingContext, IInput input, Many<ChangeDescription> changeDescriptionSink); | ||
} |
28 changes: 28 additions & 0 deletions
28
...ive/src/main/java/org/eclipse/sirius/components/collaborative/api/IInputPreProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.collaborative.api; | ||
|
||
import org.eclipse.sirius.components.core.api.IEditingContext; | ||
import org.eclipse.sirius.components.core.api.IInput; | ||
|
||
import reactor.core.publisher.Sinks.Many; | ||
|
||
/** | ||
* API to provide actions before the input processing. | ||
* | ||
* @author frouene | ||
*/ | ||
public interface IInputPreProcessor { | ||
|
||
IInput preProcess(IEditingContext editingContext, IInput input, Many<ChangeDescription> changeDescriptionSink); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...omponents/collaborative/editingcontext/EditingContextEventProcessorFactoryParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.collaborative.editingcontext; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.eclipse.sirius.components.collaborative.api.IEditingContextEventHandler; | ||
import org.eclipse.sirius.components.collaborative.api.IInputPostProcessor; | ||
import org.eclipse.sirius.components.collaborative.api.IInputPreProcessor; | ||
import org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessorComposedFactory; | ||
import org.eclipse.sirius.components.collaborative.editingcontext.api.IEditingContextEventProcessorExecutorServiceProvider; | ||
import org.eclipse.sirius.components.core.api.IEditingContextPersistenceService; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* Bundles the bean dependencies that {@link EditingContextEventProcessorFactory} needs into a single object for convenience. | ||
* | ||
* @author frouene | ||
*/ | ||
@Service | ||
public class EditingContextEventProcessorFactoryParameters { | ||
|
||
|
||
private final IEditingContextPersistenceService editingContextPersistenceService; | ||
|
||
private final List<IEditingContextEventHandler> editingContextEventHandlers; | ||
|
||
private final IRepresentationEventProcessorComposedFactory representationEventProcessorComposedFactory; | ||
|
||
private final IEditingContextEventProcessorExecutorServiceProvider executorServiceProvider; | ||
|
||
private final List<IInputPreProcessor> inputPreProcessors; | ||
|
||
private final List<IInputPostProcessor> inputPostProcessors; | ||
|
||
public EditingContextEventProcessorFactoryParameters(IEditingContextPersistenceService editingContextPersistenceService, List<IEditingContextEventHandler> editingContextEventHandlers, | ||
IRepresentationEventProcessorComposedFactory representationEventProcessorComposedFactory, IEditingContextEventProcessorExecutorServiceProvider executorServiceProvider, | ||
List<IInputPreProcessor> inputPreProcessors, List<IInputPostProcessor> inputPostProcessors) { | ||
this.editingContextPersistenceService = Objects.requireNonNull(editingContextPersistenceService); | ||
this.editingContextEventHandlers = Objects.requireNonNull(editingContextEventHandlers); | ||
this.representationEventProcessorComposedFactory = Objects.requireNonNull(representationEventProcessorComposedFactory); | ||
this.executorServiceProvider = Objects.requireNonNull(executorServiceProvider); | ||
this.inputPreProcessors = Objects.requireNonNull(inputPreProcessors); | ||
this.inputPostProcessors = Objects.requireNonNull(inputPostProcessors); | ||
} | ||
|
||
public IEditingContextPersistenceService getEditingContextPersistenceService() { | ||
return this.editingContextPersistenceService; | ||
} | ||
|
||
public List<IEditingContextEventHandler> getEditingContextEventHandlers() { | ||
return this.editingContextEventHandlers; | ||
} | ||
|
||
public IRepresentationEventProcessorComposedFactory getRepresentationEventProcessorComposedFactory() { | ||
return this.representationEventProcessorComposedFactory; | ||
} | ||
|
||
public IEditingContextEventProcessorExecutorServiceProvider getExecutorServiceProvider() { | ||
return this.executorServiceProvider; | ||
} | ||
|
||
public List<IInputPreProcessor> getInputPreProcessors() { | ||
return this.inputPreProcessors; | ||
} | ||
|
||
public List<IInputPostProcessor> getInputPostProcessors() { | ||
return this.inputPostProcessors; | ||
} | ||
} |
Oops, something went wrong.