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);
}
}
}
}
Aggregations