use of org.eclipse.sirius.components.collaborative.forms.dto.EditRadioSuccessPayload in project sirius-components by eclipse-sirius.
the class EditRadioEventHandler method handle.
@Override
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, Form form, IFormInput formInput) {
this.counter.increment();
String message = this.messageService.invalidInput(formInput.getClass().getSimpleName(), EditRadioInput.class.getSimpleName());
IPayload payload = new ErrorPayload(formInput.getId(), message);
ChangeDescription changeDescription = new ChangeDescription(ChangeKind.NOTHING, formInput.getRepresentationId(), formInput);
if (formInput instanceof EditRadioInput) {
EditRadioInput input = (EditRadioInput) formInput;
// @formatter:off
var optionalRadio = this.formQueryService.findWidget(form, input.getRadioId()).filter(Radio.class::isInstance).map(Radio.class::cast);
IStatus status = optionalRadio.map(Radio::getNewValueHandler).map(handler -> handler.apply(input.getNewValue())).orElse(// $NON-NLS-1$
new Failure(""));
if (status instanceof Success) {
payload = new EditRadioSuccessPayload(formInput.getId());
changeDescription = new ChangeDescription(ChangeKind.SEMANTIC_CHANGE, formInput.getRepresentationId(), formInput);
} else if (status instanceof Failure) {
payload = new ErrorPayload(formInput.getId(), ((Failure) status).getMessage());
}
}
changeDescriptionSink.tryEmitNext(changeDescription);
payloadSink.tryEmitValue(payload);
}
Aggregations