use of org.eclipse.sirius.components.collaborative.forms.dto.EditSelectSuccessPayload in project sirius-components by eclipse-sirius.
the class EditSelectEventHandler 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(), EditSelectInput.class.getSimpleName());
IPayload payload = new ErrorPayload(formInput.getId(), message);
ChangeDescription changeDescription = new ChangeDescription(ChangeKind.NOTHING, formInput.getRepresentationId(), formInput);
if (formInput instanceof EditSelectInput) {
EditSelectInput input = (EditSelectInput) formInput;
// @formatter:off
Optional<Select> optionalSelect = this.formQueryService.findWidget(form, input.getSelectId()).filter(Select.class::isInstance).map(Select.class::cast);
IStatus status = optionalSelect.map(Select::getNewValueHandler).map(handler -> handler.apply(input.getNewValue())).orElse(// $NON-NLS-1$
new Failure(""));
if (status instanceof Success) {
payload = new EditSelectSuccessPayload(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