use of org.eclipse.sirius.components.collaborative.diagrams.dto.UpdateNodeBoundsSuccessPayload in project sirius-components by eclipse-sirius.
the class UpdateNodeBoundsEventHandler method handleUpdateNodeBounds.
private void handleUpdateNodeBounds(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IDiagramContext diagramContext, UpdateNodeBoundsInput diagramInput) {
// @formatter:off
Position newPosition = Position.newPosition().x(diagramInput.getNewPositionX()).y(diagramInput.getNewPositionY()).build();
Size newSize = Size.newSize().width(diagramInput.getNewWidth()).height(diagramInput.getNewHeight()).build();
// @formatter:on
Optional<Node> optionalNode = this.diagramQueryService.findNodeById(diagramContext.getDiagram(), diagramInput.getDiagramElementId());
if (optionalNode.isPresent()) {
Position oldPosition = optionalNode.get().getPosition();
// @formatter:off
Position delta = Position.newPosition().x(oldPosition.getX() - newPosition.getX()).y(oldPosition.getY() - newPosition.getY()).build();
// @formatter:on
diagramContext.setDiagramEvent(new ResizeEvent(diagramInput.getDiagramElementId(), delta, newSize));
payloadSink.tryEmitValue(new UpdateNodeBoundsSuccessPayload(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