Search in sources :

Example 1 with UpdateNodePositionSuccessPayload

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));
    }
}
Also used : UpdateNodePositionSuccessPayload(org.eclipse.sirius.components.collaborative.diagrams.dto.UpdateNodePositionSuccessPayload) ErrorPayload(org.eclipse.sirius.components.core.api.ErrorPayload) Position(org.eclipse.sirius.components.diagrams.Position) Node(org.eclipse.sirius.components.diagrams.Node) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) MoveEvent(org.eclipse.sirius.components.diagrams.events.MoveEvent)

Aggregations

ChangeDescription (org.eclipse.sirius.components.collaborative.api.ChangeDescription)1 UpdateNodePositionSuccessPayload (org.eclipse.sirius.components.collaborative.diagrams.dto.UpdateNodePositionSuccessPayload)1 ErrorPayload (org.eclipse.sirius.components.core.api.ErrorPayload)1 Node (org.eclipse.sirius.components.diagrams.Node)1 Position (org.eclipse.sirius.components.diagrams.Position)1 MoveEvent (org.eclipse.sirius.components.diagrams.events.MoveEvent)1