Search in sources :

Example 1 with IFormEventHandler

use of org.eclipse.sirius.components.collaborative.forms.api.IFormEventHandler 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

List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 ChangeDescription (org.eclipse.sirius.components.collaborative.api.ChangeDescription)1 ChangeKind (org.eclipse.sirius.components.collaborative.api.ChangeKind)1 IRepresentationRefreshPolicy (org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicy)1 IRepresentationRefreshPolicyRegistry (org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicyRegistry)1 ISubscriptionManager (org.eclipse.sirius.components.collaborative.api.ISubscriptionManager)1 FormCreationParameters (org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters)1 IFormEventHandler (org.eclipse.sirius.components.collaborative.forms.api.IFormEventHandler)1 IFormEventProcessor (org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor)1 IFormInput (org.eclipse.sirius.components.collaborative.forms.api.IFormInput)1 IWidgetSubscriptionManager (org.eclipse.sirius.components.collaborative.forms.api.IWidgetSubscriptionManager)1 FormRefreshedEventPayload (org.eclipse.sirius.components.collaborative.forms.dto.FormRefreshedEventPayload)1 UpdateWidgetFocusInput (org.eclipse.sirius.components.collaborative.forms.dto.UpdateWidgetFocusInput)1 UpdateWidgetFocusSuccessPayload (org.eclipse.sirius.components.collaborative.forms.dto.UpdateWidgetFocusSuccessPayload)1 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)1 IInput (org.eclipse.sirius.components.core.api.IInput)1 IPayload (org.eclipse.sirius.components.core.api.IPayload)1