Search in sources :

Example 1 with ArrangeAllInput

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

the class ArrangeAllEventHandlerTests method testArrangeAll.

@Test
public void testArrangeAll() {
    var handler = new ArrangeAllEventHandler(new ICollaborativeDiagramMessageService.NoOp(), new SimpleMeterRegistry());
    // $NON-NLS-1$//$NON-NLS-2$
    var input = new ArrangeAllInput(UUID.randomUUID(), "editingContextId", "representationId");
    assertThat(handler.canHandle(input)).isTrue();
    One<IPayload> payloadSink = Sinks.one();
    Many<ChangeDescription> changeDescriptionSink = Sinks.many().unicast().onBackpressureBuffer();
    IDiagramContext diagramContext = new DiagramContext(new TestDiagramBuilder().getDiagram(UUID.randomUUID().toString()));
    handler.handle(payloadSink, changeDescriptionSink, new IEditingContext.NoOp(), diagramContext, input);
    ChangeDescription changeDescription = changeDescriptionSink.asFlux().blockFirst();
    assertThat(changeDescription.getKind()).isEqualTo(DiagramChangeKind.DIAGRAM_LAYOUT_CHANGE);
    IPayload payload = payloadSink.asMono().block();
    assertThat(payload).isInstanceOf(ArrangeAllSuccessPayload.class);
    assertThat(diagramContext.getDiagramEvent()).isInstanceOf(ArrangeAllEvent.class);
}
Also used : SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) IPayload(org.eclipse.sirius.components.core.api.IPayload) ArrangeAllInput(org.eclipse.sirius.components.collaborative.diagrams.dto.ArrangeAllInput) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) DiagramContext(org.eclipse.sirius.components.collaborative.diagrams.DiagramContext) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) TestDiagramBuilder(org.eclipse.sirius.components.diagrams.tests.TestDiagramBuilder) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) ICollaborativeDiagramMessageService(org.eclipse.sirius.components.collaborative.diagrams.messages.ICollaborativeDiagramMessageService) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) Test(org.junit.jupiter.api.Test)

Example 2 with ArrangeAllInput

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

the class ArrangeAllEventHandler method handle.

@Override
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IEditingContext editingContext, IDiagramContext diagramContext, IDiagramInput diagramInput) {
    this.counter.increment();
    String message = this.messageService.invalidInput(diagramInput.getClass().getSimpleName(), InvokeSingleClickOnDiagramElementToolInput.class.getSimpleName());
    IPayload payload = new ErrorPayload(diagramInput.getId(), message);
    ChangeDescription changeDescription = new ChangeDescription(ChangeKind.NOTHING, diagramInput.getRepresentationId(), diagramInput);
    if (diagramInput instanceof ArrangeAllInput) {
        diagramContext.setDiagramEvent(new ArrangeAllEvent());
        payload = new ArrangeAllSuccessPayload(diagramInput.getId());
        changeDescription = new ChangeDescription(DiagramChangeKind.DIAGRAM_LAYOUT_CHANGE, diagramInput.getRepresentationId(), diagramInput);
    }
    payloadSink.tryEmitValue(payload);
    changeDescriptionSink.tryEmitNext(changeDescription);
}
Also used : InvokeSingleClickOnDiagramElementToolInput(org.eclipse.sirius.components.collaborative.diagrams.dto.InvokeSingleClickOnDiagramElementToolInput) ArrangeAllSuccessPayload(org.eclipse.sirius.components.collaborative.diagrams.dto.ArrangeAllSuccessPayload) ArrangeAllInput(org.eclipse.sirius.components.collaborative.diagrams.dto.ArrangeAllInput) ErrorPayload(org.eclipse.sirius.components.core.api.ErrorPayload) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) ArrangeAllEvent(org.eclipse.sirius.components.diagrams.events.ArrangeAllEvent) IPayload(org.eclipse.sirius.components.core.api.IPayload)

Aggregations

ChangeDescription (org.eclipse.sirius.components.collaborative.api.ChangeDescription)2 ArrangeAllInput (org.eclipse.sirius.components.collaborative.diagrams.dto.ArrangeAllInput)2 IPayload (org.eclipse.sirius.components.core.api.IPayload)2 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)1 DiagramContext (org.eclipse.sirius.components.collaborative.diagrams.DiagramContext)1 IDiagramContext (org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext)1 ArrangeAllSuccessPayload (org.eclipse.sirius.components.collaborative.diagrams.dto.ArrangeAllSuccessPayload)1 InvokeSingleClickOnDiagramElementToolInput (org.eclipse.sirius.components.collaborative.diagrams.dto.InvokeSingleClickOnDiagramElementToolInput)1 ICollaborativeDiagramMessageService (org.eclipse.sirius.components.collaborative.diagrams.messages.ICollaborativeDiagramMessageService)1 ErrorPayload (org.eclipse.sirius.components.core.api.ErrorPayload)1 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)1 ArrangeAllEvent (org.eclipse.sirius.components.diagrams.events.ArrangeAllEvent)1 TestDiagramBuilder (org.eclipse.sirius.components.diagrams.tests.TestDiagramBuilder)1 Test (org.junit.jupiter.api.Test)1