use of org.eclipse.sirius.components.collaborative.diagrams.dto.UpdateNodePositionSuccessPayload in project sirius-components by eclipse-sirius.
the class UpdateNodePositionEventHandler method handleUpdateNodePosition.
private void handleUpdateNodePosition(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IDiagramContext diagramContext, UpdateNodePositionInput diagramInput) {
Position newPosition = Position.at(diagramInput.getNewPositionX(), diagramInput.getNewPositionY());
Optional<Node> optionalNode = this.diagramQueryService.findNodeById(diagramContext.getDiagram(), diagramInput.getDiagramElementId());
if (optionalNode.isPresent()) {
diagramContext.setDiagramEvent(new MoveEvent(diagramInput.getDiagramElementId(), newPosition));
payloadSink.tryEmitValue(new UpdateNodePositionSuccessPayload(diagramInput.getId(), diagramContext.getDiagram()));
changeDescriptionSink.tryEmitNext(new ChangeDescription(DiagramChangeKind.DIAGRAM_LAYOUT_CHANGE, diagramInput.getRepresentationId(), diagramInput));
} else {
String message = this.messageService.nodeNotFound(String.valueOf(diagramInput.getDiagramElementId()));
payloadSink.tryEmitValue(new ErrorPayload(diagramInput.getId(), message));
changeDescriptionSink.tryEmitNext(new ChangeDescription(ChangeKind.NOTHING, diagramInput.getRepresentationId(), diagramInput));
}
}
Aggregations