Search in sources :

Example 1 with IRepresentationEventProcessor

use of org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor in project sirius-components by eclipse-sirius.

the class EditingContextEventProcessor method handleRepresentationInput.

private void handleRepresentationInput(One<IPayload> payloadSink, IRepresentationInput representationInput) {
    Optional<IRepresentationEventProcessor> optionalRepresentationEventProcessor = Optional.ofNullable(this.representationEventProcessors.get(representationInput.getRepresentationId())).map(RepresentationEventProcessorEntry::getRepresentationEventProcessor);
    if (optionalRepresentationEventProcessor.isPresent()) {
        IRepresentationEventProcessor representationEventProcessor = optionalRepresentationEventProcessor.get();
        representationEventProcessor.handle(payloadSink, this.changeDescriptionSink, representationInput);
    } else {
        // $NON-NLS-1$
        this.logger.warn("No representation event processor found for event: {}", representationInput);
    }
}
Also used : IRepresentationEventProcessor(org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)

Example 2 with IRepresentationEventProcessor

use of org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor in project sirius-components by eclipse-sirius.

the class FormEventProcessorFactory method createRepresentationEventProcessor.

@Override
public <T extends IRepresentationEventProcessor> Optional<T> createRepresentationEventProcessor(Class<T> representationEventProcessorClass, IRepresentationConfiguration configuration, IEditingContext editingContext) {
    if (IFormEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof FormConfiguration) {
        FormConfiguration formConfiguration = (FormConfiguration) configuration;
        Optional<Form> optionalForm = this.representationSearchService.findById(editingContext, formConfiguration.getId(), Form.class);
        if (optionalForm.isPresent()) {
            Form form = optionalForm.get();
            // @formatter:off
            Optional<FormDescription> optionalFormDescription = this.representationDescriptionSearchService.findById(editingContext, form.getDescriptionId()).filter(FormDescription.class::isInstance).map(FormDescription.class::cast);
            // @formatter:on
            Optional<Object> optionalObject = this.objectService.getObject(editingContext, form.getTargetObjectId());
            if (optionalFormDescription.isPresent() && optionalObject.isPresent()) {
                FormDescription formDescription = optionalFormDescription.get();
                Object object = optionalObject.get();
                // @formatter:off
                FormCreationParameters formCreationParameters = FormCreationParameters.newFormCreationParameters(formConfiguration.getId()).editingContext(editingContext).formDescription(formDescription).objects(List.of(object)).build();
                // @formatter:on
                IRepresentationEventProcessor formEventProcessor = new FormEventProcessor(formCreationParameters, this.formEventHandlers, this.subscriptionManagerFactory.create(), this.widgetSubscriptionManagerFactory.create(), this.representationRefreshPolicyRegistry);
                // @formatter:off
                return Optional.of(formEventProcessor).filter(representationEventProcessorClass::isInstance).map(representationEventProcessorClass::cast);
            // @formatter:on
            }
        }
    }
    return Optional.empty();
}
Also used : IFormEventProcessor(org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor) Form(org.eclipse.sirius.components.forms.Form) IFormEventProcessor(org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor) FormCreationParameters(org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters) FormConfiguration(org.eclipse.sirius.components.collaborative.forms.api.FormConfiguration) FormDescription(org.eclipse.sirius.components.forms.description.FormDescription) IRepresentationEventProcessor(org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)

Example 3 with IRepresentationEventProcessor

use of org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor in project sirius-components by eclipse-sirius.

the class DiagramEventProcessorFactory method createRepresentationEventProcessor.

@Override
public <T extends IRepresentationEventProcessor> Optional<T> createRepresentationEventProcessor(Class<T> representationEventProcessorClass, IRepresentationConfiguration configuration, IEditingContext editingContext) {
    if (IDiagramEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof DiagramConfiguration) {
        DiagramConfiguration diagramConfiguration = (DiagramConfiguration) configuration;
        var optionalDiagram = this.representationSearchService.findById(editingContext, diagramConfiguration.getId(), Diagram.class);
        if (optionalDiagram.isPresent()) {
            Diagram diagram = optionalDiagram.get();
            // @formatter:off
            DiagramContext diagramContext = new DiagramContext(diagram);
            IRepresentationEventProcessor diagramEventProcessor = new DiagramEventProcessor(editingContext, diagramContext, this.diagramEventHandlers, this.subscriptionManagerFactory.create(), this.representationDescriptionSearchService, this.representationRefreshPolicyRegistry, this.diagramCreationService);
            return Optional.of(diagramEventProcessor).filter(representationEventProcessorClass::isInstance).map(representationEventProcessorClass::cast);
        // @formatter:on
        }
    }
    return Optional.empty();
}
Also used : IDiagramEventProcessor(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventProcessor) DiagramConfiguration(org.eclipse.sirius.components.collaborative.diagrams.api.DiagramConfiguration) IDiagramEventProcessor(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventProcessor) Diagram(org.eclipse.sirius.components.diagrams.Diagram) IRepresentationEventProcessor(org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)

Example 4 with IRepresentationEventProcessor

use of org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor in project sirius-components by eclipse-sirius.

the class SelectionEventProcessorFactory method createRepresentationEventProcessor.

@Override
public <T extends IRepresentationEventProcessor> Optional<T> createRepresentationEventProcessor(Class<T> representationEventProcessorClass, IRepresentationConfiguration configuration, IEditingContext editingContext) {
    if (ISelectionEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof SelectionConfiguration) {
        SelectionConfiguration selectionConfiguration = (SelectionConfiguration) configuration;
        // @formatter:off
        Optional<SelectionDescription> optionalSelectionDescription = this.representationDescriptionSearchService.findById(editingContext, selectionConfiguration.getSelectionId()).filter(SelectionDescription.class::isInstance).map(SelectionDescription.class::cast);
        // @formatter:on
        Optional<Object> optionalObject = this.objectService.getObject(editingContext, selectionConfiguration.getTargetObjectId());
        if (optionalSelectionDescription.isPresent() && optionalObject.isPresent()) {
            SelectionDescription selectionDescription = optionalSelectionDescription.get();
            Object object = optionalObject.get();
            IRepresentationEventProcessor selectionEventProcessor = new SelectionEventProcessor(editingContext, selectionDescription, selectionConfiguration.getId(), object, this.subscriptionManagerFactory.create(), this.representationRefreshPolicyRegistry);
            // @formatter:off
            return Optional.of(selectionEventProcessor).filter(representationEventProcessorClass::isInstance).map(representationEventProcessorClass::cast);
        // @formatter:on
        }
    }
    return Optional.empty();
}
Also used : ISelectionEventProcessor(org.eclipse.sirius.components.collaborative.selection.api.ISelectionEventProcessor) SelectionDescription(org.eclipse.sirius.components.selection.description.SelectionDescription) SelectionConfiguration(org.eclipse.sirius.components.collaborative.selection.api.SelectionConfiguration) ISelectionEventProcessor(org.eclipse.sirius.components.collaborative.selection.api.ISelectionEventProcessor) IRepresentationEventProcessor(org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)

Example 5 with IRepresentationEventProcessor

use of org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor in project sirius-components by eclipse-sirius.

the class ValidationEventProcessorFactory method createRepresentationEventProcessor.

@Override
public <T extends IRepresentationEventProcessor> Optional<T> createRepresentationEventProcessor(Class<T> representationEventProcessorClass, IRepresentationConfiguration configuration, IEditingContext editingContext) {
    if (IValidationEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && 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.empty();
}
Also used : ValidationDescription(org.eclipse.sirius.components.validation.description.ValidationDescription) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) IValidationEventProcessor(org.eclipse.sirius.components.collaborative.validation.api.IValidationEventProcessor) ValidationConfiguration(org.eclipse.sirius.components.collaborative.validation.api.ValidationConfiguration) IValidationEventProcessor(org.eclipse.sirius.components.collaborative.validation.api.IValidationEventProcessor) IRepresentationEventProcessor(org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)

Aggregations

IRepresentationEventProcessor (org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)8 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)2 FormCreationParameters (org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters)2 IFormEventProcessor (org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor)2 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 ChangeDescription (org.eclipse.sirius.components.collaborative.api.ChangeDescription)1 ChangeKind (org.eclipse.sirius.components.collaborative.api.ChangeKind)1