Search in sources :

Example 1 with IRepresentationInput

use of org.eclipse.sirius.components.core.api.IRepresentationInput in project sirius-components by eclipse-sirius.

the class EditingContextEventProcessor method doHandle.

/**
 * Finds the proper event handler to perform the task matching the given input event.
 *
 * @param payloadSink
 *            The sink to publish payload
 * @param inputEvent
 *            The input event
 * @return The response computed by the event handler
 */
private void doHandle(One<IPayload> payloadSink, IInput input) {
    // $NON-NLS-1$
    this.logger.trace("Input received: {}", input);
    if (input instanceof IRepresentationInput) {
        IRepresentationInput representationInput = (IRepresentationInput) input;
        this.handleRepresentationInput(payloadSink, representationInput);
    } else {
        this.handleInput(payloadSink, input);
    }
}
Also used : IRepresentationInput(org.eclipse.sirius.components.core.api.IRepresentationInput)

Example 2 with IRepresentationInput

use of org.eclipse.sirius.components.core.api.IRepresentationInput in project sirius-components by eclipse-sirius.

the class DiagramEventProcessor method handle.

@Override
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IRepresentationInput representationInput) {
    IRepresentationInput effectiveInput = representationInput;
    if (representationInput instanceof RenameRepresentationInput) {
        RenameRepresentationInput renameRepresentationInput = (RenameRepresentationInput) representationInput;
        effectiveInput = new RenameDiagramInput(renameRepresentationInput.getId(), renameRepresentationInput.getEditingContextId(), renameRepresentationInput.getRepresentationId(), renameRepresentationInput.getNewLabel());
    }
    if (effectiveInput instanceof IDiagramInput) {
        IDiagramInput diagramInput = (IDiagramInput) effectiveInput;
        Optional<IDiagramEventHandler> optionalDiagramEventHandler = this.diagramEventHandlers.stream().filter(handler -> handler.canHandle(diagramInput)).findFirst();
        if (optionalDiagramEventHandler.isPresent()) {
            IDiagramEventHandler diagramEventHandler = optionalDiagramEventHandler.get();
            diagramEventHandler.handle(payloadSink, changeDescriptionSink, this.editingContext, this.diagramContext, diagramInput);
        } else {
            // $NON-NLS-1$
            this.logger.warn("No handler found for event: {}", diagramInput);
        }
    }
}
Also used : IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) IDiagramInput(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramInput) LoggerFactory(org.slf4j.LoggerFactory) One(reactor.core.publisher.Sinks.One) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) IInput(org.eclipse.sirius.components.core.api.IInput) Diagram(org.eclipse.sirius.components.diagrams.Diagram) IRepresentation(org.eclipse.sirius.components.representations.IRepresentation) IRepresentationRefreshPolicyRegistry(org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicyRegistry) IDiagramEventProcessor(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventProcessor) ChangeKind(org.eclipse.sirius.components.collaborative.api.ChangeKind) ISubscriptionManager(org.eclipse.sirius.components.collaborative.api.ISubscriptionManager) Logger(org.slf4j.Logger) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) RenameRepresentationInput(org.eclipse.sirius.components.collaborative.dto.RenameRepresentationInput) IRepresentationDescriptionSearchService(org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService) IRepresentationInput(org.eclipse.sirius.components.core.api.IRepresentationInput) IRepresentationRefreshPolicy(org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicy) IDiagramCreationService(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramCreationService) Objects(java.util.Objects) RenameDiagramInput(org.eclipse.sirius.components.collaborative.diagrams.dto.RenameDiagramInput) Flux(reactor.core.publisher.Flux) List(java.util.List) IPayload(org.eclipse.sirius.components.core.api.IPayload) IDiagramEventHandler(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventHandler) Many(reactor.core.publisher.Sinks.Many) Optional(java.util.Optional) RenameDiagramInput(org.eclipse.sirius.components.collaborative.diagrams.dto.RenameDiagramInput) IDiagramInput(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramInput) IDiagramEventHandler(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventHandler) IRepresentationInput(org.eclipse.sirius.components.core.api.IRepresentationInput) RenameRepresentationInput(org.eclipse.sirius.components.collaborative.dto.RenameRepresentationInput)

Example 3 with IRepresentationInput

use of org.eclipse.sirius.components.core.api.IRepresentationInput in project sirius-components by eclipse-sirius.

the class ValidationEventProcessor method handle.

@Override
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IRepresentationInput representationInput) {
    if (representationInput instanceof IValidationInput) {
        IValidationInput validationInput = (IValidationInput) representationInput;
        // @formatter:off
        Optional<IValidationEventHandler> optionalValidationEventHandler = this.validationEventHandlers.stream().filter(handler -> handler.canHandle(validationInput)).findFirst();
        if (optionalValidationEventHandler.isPresent()) {
            IValidationEventHandler validationEventHandler = optionalValidationEventHandler.get();
            validationEventHandler.handle(payloadSink, changeDescriptionSink, this.validationContext.getValidation(), validationInput);
        } else {
            // $NON-NLS-1$
            this.logger.warn("No handler found for event: {}", validationInput);
        }
    }
}
Also used : ValidationComponent(org.eclipse.sirius.components.validation.components.ValidationComponent) Sinks(reactor.core.publisher.Sinks) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) LoggerFactory(org.slf4j.LoggerFactory) One(reactor.core.publisher.Sinks.One) IInput(org.eclipse.sirius.components.core.api.IInput) Timer(io.micrometer.core.instrument.Timer) Monitoring(org.eclipse.sirius.components.collaborative.api.Monitoring) IRepresentation(org.eclipse.sirius.components.representations.IRepresentation) IRepresentationRefreshPolicyRegistry(org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicyRegistry) EmitResult(reactor.core.publisher.Sinks.EmitResult) ValidationRenderer(org.eclipse.sirius.components.validation.render.ValidationRenderer) IValidationEventHandler(org.eclipse.sirius.components.collaborative.validation.api.IValidationEventHandler) IValidationInput(org.eclipse.sirius.components.collaborative.validation.api.IValidationInput) IValidationEventProcessor(org.eclipse.sirius.components.collaborative.validation.api.IValidationEventProcessor) ChangeKind(org.eclipse.sirius.components.collaborative.api.ChangeKind) ISubscriptionManager(org.eclipse.sirius.components.collaborative.api.ISubscriptionManager) Logger(org.slf4j.Logger) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) ValidationDescription(org.eclipse.sirius.components.validation.description.ValidationDescription) Mono(reactor.core.publisher.Mono) ValidationRefreshedEventPayload(org.eclipse.sirius.components.collaborative.validation.dto.ValidationRefreshedEventPayload) IRepresentationInput(org.eclipse.sirius.components.core.api.IRepresentationInput) IRepresentationRefreshPolicy(org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicy) Element(org.eclipse.sirius.components.representations.Element) Validation(org.eclipse.sirius.components.validation.Validation) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) Flux(reactor.core.publisher.Flux) List(java.util.List) IPayload(org.eclipse.sirius.components.core.api.IPayload) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) ValidationComponentProps(org.eclipse.sirius.components.validation.components.ValidationComponentProps) Many(reactor.core.publisher.Sinks.Many) Optional(java.util.Optional) VariableManager(org.eclipse.sirius.components.representations.VariableManager) IValidationEventHandler(org.eclipse.sirius.components.collaborative.validation.api.IValidationEventHandler) IValidationInput(org.eclipse.sirius.components.collaborative.validation.api.IValidationInput)

Example 4 with IRepresentationInput

use of org.eclipse.sirius.components.core.api.IRepresentationInput in project sirius-components by eclipse-sirius.

the class TreeEventProcessor method handle.

@Override
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IRepresentationInput representationInput) {
    if (representationInput instanceof ITreeInput) {
        ITreeInput treeInput = (ITreeInput) representationInput;
        Optional<ITreeEventHandler> optionalTreeEventHandler = this.treeEventHandlers.stream().filter(handler -> handler.canHandle(treeInput)).findFirst();
        if (optionalTreeEventHandler.isPresent()) {
            ITreeEventHandler treeEventHandler = optionalTreeEventHandler.get();
            treeEventHandler.handle(payloadSink, changeDescriptionSink, this.editingContext, this.currentTree.get(), treeInput);
        } else {
            // $NON-NLS-1$
            this.logger.warn("No handler found for event: {}", treeInput);
        }
    }
}
Also used : Sinks(reactor.core.publisher.Sinks) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) LoggerFactory(org.slf4j.LoggerFactory) One(reactor.core.publisher.Sinks.One) IInput(org.eclipse.sirius.components.core.api.IInput) AtomicReference(java.util.concurrent.atomic.AtomicReference) Timer(io.micrometer.core.instrument.Timer) Monitoring(org.eclipse.sirius.components.collaborative.api.Monitoring) IRepresentation(org.eclipse.sirius.components.representations.IRepresentation) IRepresentationRefreshPolicyRegistry(org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicyRegistry) EmitResult(reactor.core.publisher.Sinks.EmitResult) ITreeEventProcessor(org.eclipse.sirius.components.collaborative.trees.api.ITreeEventProcessor) ChangeKind(org.eclipse.sirius.components.collaborative.api.ChangeKind) ISubscriptionManager(org.eclipse.sirius.components.collaborative.api.ISubscriptionManager) Logger(org.slf4j.Logger) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) Mono(reactor.core.publisher.Mono) IRepresentationInput(org.eclipse.sirius.components.core.api.IRepresentationInput) ITreeEventHandler(org.eclipse.sirius.components.collaborative.trees.api.ITreeEventHandler) IRepresentationRefreshPolicy(org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicy) ITreeInput(org.eclipse.sirius.components.collaborative.trees.api.ITreeInput) ITreeService(org.eclipse.sirius.components.collaborative.trees.api.ITreeService) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) Flux(reactor.core.publisher.Flux) List(java.util.List) IPayload(org.eclipse.sirius.components.core.api.IPayload) TreeRefreshedEventPayload(org.eclipse.sirius.components.collaborative.trees.dto.TreeRefreshedEventPayload) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) TreeCreationParameters(org.eclipse.sirius.components.collaborative.trees.api.TreeCreationParameters) Many(reactor.core.publisher.Sinks.Many) Optional(java.util.Optional) Tree(org.eclipse.sirius.components.trees.Tree) ITreeInput(org.eclipse.sirius.components.collaborative.trees.api.ITreeInput) ITreeEventHandler(org.eclipse.sirius.components.collaborative.trees.api.ITreeEventHandler)

Example 5 with IRepresentationInput

use of org.eclipse.sirius.components.core.api.IRepresentationInput in project sirius-components by eclipse-sirius.

the class FormEventProcessor method handle.

@Override
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IRepresentationInput representationInput) {
    if (representationInput instanceof IFormInput) {
        IFormInput formInput = (IFormInput) representationInput;
        if (formInput instanceof UpdateWidgetFocusInput) {
            UpdateWidgetFocusInput input = (UpdateWidgetFocusInput) formInput;
            this.widgetSubscriptionManager.handle(input);
            payloadSink.tryEmitValue(new UpdateWidgetFocusSuccessPayload(representationInput.getId(), input.getWidgetId()));
            changeDescriptionSink.tryEmitNext(new ChangeDescription(ChangeKind.FOCUS_CHANGE, representationInput.getRepresentationId(), input));
        } else {
            Optional<IFormEventHandler> optionalFormEventHandler = this.formEventHandlers.stream().filter(handler -> handler.canHandle(formInput)).findFirst();
            if (optionalFormEventHandler.isPresent()) {
                IFormEventHandler formEventHandler = optionalFormEventHandler.get();
                formEventHandler.handle(payloadSink, changeDescriptionSink, this.currentForm.get(), formInput);
            } else {
                // $NON-NLS-1$
                this.logger.warn("No handler found for event: {}", formInput);
            }
        }
    }
}
Also used : UpdateWidgetFocusInput(org.eclipse.sirius.components.collaborative.forms.dto.UpdateWidgetFocusInput) IFormEventHandler(org.eclipse.sirius.components.collaborative.forms.api.IFormEventHandler) Sinks(reactor.core.publisher.Sinks) Form(org.eclipse.sirius.components.forms.Form) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) LoggerFactory(org.slf4j.LoggerFactory) One(reactor.core.publisher.Sinks.One) FormRenderer(org.eclipse.sirius.components.forms.renderer.FormRenderer) UpdateWidgetFocusSuccessPayload(org.eclipse.sirius.components.collaborative.forms.dto.UpdateWidgetFocusSuccessPayload) IInput(org.eclipse.sirius.components.core.api.IInput) AtomicReference(java.util.concurrent.atomic.AtomicReference) FormComponent(org.eclipse.sirius.components.forms.components.FormComponent) IRepresentation(org.eclipse.sirius.components.representations.IRepresentation) IRepresentationRefreshPolicyRegistry(org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicyRegistry) EmitResult(reactor.core.publisher.Sinks.EmitResult) ChangeKind(org.eclipse.sirius.components.collaborative.api.ChangeKind) ISubscriptionManager(org.eclipse.sirius.components.collaborative.api.ISubscriptionManager) Logger(org.slf4j.Logger) FormCreationParameters(org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters) IWidgetSubscriptionManager(org.eclipse.sirius.components.collaborative.forms.api.IWidgetSubscriptionManager) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) Mono(reactor.core.publisher.Mono) IRepresentationInput(org.eclipse.sirius.components.core.api.IRepresentationInput) IRepresentationRefreshPolicy(org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicy) Element(org.eclipse.sirius.components.representations.Element) Objects(java.util.Objects) IFormEventHandler(org.eclipse.sirius.components.collaborative.forms.api.IFormEventHandler) Flux(reactor.core.publisher.Flux) List(java.util.List) IPayload(org.eclipse.sirius.components.core.api.IPayload) GetOrCreateRandomIdProvider(org.eclipse.sirius.components.representations.GetOrCreateRandomIdProvider) UpdateWidgetFocusInput(org.eclipse.sirius.components.collaborative.forms.dto.UpdateWidgetFocusInput) FormComponentProps(org.eclipse.sirius.components.forms.components.FormComponentProps) Many(reactor.core.publisher.Sinks.Many) Optional(java.util.Optional) IFormInput(org.eclipse.sirius.components.collaborative.forms.api.IFormInput) FormRefreshedEventPayload(org.eclipse.sirius.components.collaborative.forms.dto.FormRefreshedEventPayload) VariableManager(org.eclipse.sirius.components.representations.VariableManager) IFormEventProcessor(org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor) UpdateWidgetFocusSuccessPayload(org.eclipse.sirius.components.collaborative.forms.dto.UpdateWidgetFocusSuccessPayload) IFormInput(org.eclipse.sirius.components.collaborative.forms.api.IFormInput) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription)

Aggregations

IRepresentationInput (org.eclipse.sirius.components.core.api.IRepresentationInput)5 List (java.util.List)4 Objects (java.util.Objects)4 Optional (java.util.Optional)4 ChangeDescription (org.eclipse.sirius.components.collaborative.api.ChangeDescription)4 ChangeKind (org.eclipse.sirius.components.collaborative.api.ChangeKind)4 IRepresentationRefreshPolicy (org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicy)4 IRepresentationRefreshPolicyRegistry (org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicyRegistry)4 ISubscriptionManager (org.eclipse.sirius.components.collaborative.api.ISubscriptionManager)4 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)4 IInput (org.eclipse.sirius.components.core.api.IInput)4 IPayload (org.eclipse.sirius.components.core.api.IPayload)4 IRepresentation (org.eclipse.sirius.components.representations.IRepresentation)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Flux (reactor.core.publisher.Flux)4 Many (reactor.core.publisher.Sinks.Many)4 One (reactor.core.publisher.Sinks.One)4 Mono (reactor.core.publisher.Mono)3 Sinks (reactor.core.publisher.Sinks)3