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