Search in sources :

Example 1 with DeleteFromDiagramSuccessPayload

use of org.eclipse.sirius.components.collaborative.diagrams.dto.DeleteFromDiagramSuccessPayload in project sirius-components by eclipse-sirius.

the class DeleteFromDiagramEventHandler method sendResponse.

private void sendResponse(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, List<String> errors, boolean atLeastOneSuccess, IDiagramContext diagramContext, DeleteFromDiagramInput diagramInput) {
    var changeDescription = new ChangeDescription(ChangeKind.SEMANTIC_CHANGE, diagramInput.getRepresentationId(), diagramInput);
    IPayload payload = new DeleteFromDiagramSuccessPayload(diagramInput.getId(), diagramContext.getDiagram());
    if (!errors.isEmpty()) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(this.messageService.deleteFailed());
        for (String error : errors) {
            stringBuilder.append(error);
        }
        changeDescription = new ChangeDescription(ChangeKind.NOTHING, diagramInput.getRepresentationId(), diagramInput);
        if (atLeastOneSuccess) {
            changeDescription = new ChangeDescription(ChangeKind.SEMANTIC_CHANGE, diagramInput.getRepresentationId(), diagramInput);
        }
        payload = new ErrorPayload(diagramInput.getId(), stringBuilder.toString());
    }
    payloadSink.tryEmitValue(payload);
    changeDescriptionSink.tryEmitNext(changeDescription);
}
Also used : ErrorPayload(org.eclipse.sirius.components.core.api.ErrorPayload) DeleteFromDiagramSuccessPayload(org.eclipse.sirius.components.collaborative.diagrams.dto.DeleteFromDiagramSuccessPayload) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) IPayload(org.eclipse.sirius.components.core.api.IPayload)

Aggregations

ChangeDescription (org.eclipse.sirius.components.collaborative.api.ChangeDescription)1 DeleteFromDiagramSuccessPayload (org.eclipse.sirius.components.collaborative.diagrams.dto.DeleteFromDiagramSuccessPayload)1 ErrorPayload (org.eclipse.sirius.components.core.api.ErrorPayload)1 IPayload (org.eclipse.sirius.components.core.api.IPayload)1