Search in sources :

Example 1 with CanvasShapeRemovedEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasShapeRemovedEvent in project kie-wb-common by kiegroup.

the class MapSelectionControlTest method testOnShapeRemovedEvent.

@Test
public void testOnShapeRemovedEvent() {
    tested.enable(canvasHandler);
    tested.register(element);
    tested.select(element);
    CanvasShapeRemovedEvent shapeRemovedEvent = new CanvasShapeRemovedEvent(canvas, shape);
    tested.onShapeRemoved(shapeRemovedEvent);
    assertTrue(tested.getSelectedItems().isEmpty());
    verify(shape, times(1)).applyState(eq(ShapeState.SELECTED));
    verify(shape, times(1)).applyState(eq(ShapeState.NONE));
    verify(shape, never()).applyState(eq(ShapeState.INVALID));
    verify(shape, never()).applyState(eq(ShapeState.HIGHLIGHT));
}
Also used : CanvasShapeRemovedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasShapeRemovedEvent) Test(org.junit.Test)

Example 2 with CanvasShapeRemovedEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasShapeRemovedEvent in project kie-wb-common by kiegroup.

the class ToolboxControlTest method testShapeRemovedEvent.

@Test
public void testShapeRemovedEvent() {
    final String uuid = "uuid1";
    when(delegated.isActive(eq(uuid))).thenReturn(true);
    final Shape shape = mock(Shape.class);
    when(shape.getUUID()).thenReturn(uuid);
    final CanvasShapeRemovedEvent event = new CanvasShapeRemovedEvent(canvas, shape);
    tested.onCanvasShapeRemovedEvent(event);
    verify(delegated, times(1)).destroy();
    verify(delegated, never()).show(any(Element.class));
    verify(delegated, never()).show(anyString());
}
Also used : Shape(org.kie.workbench.common.stunner.core.client.shape.Shape) Element(org.kie.workbench.common.stunner.core.graph.Element) Matchers.anyString(org.mockito.Matchers.anyString) CanvasShapeRemovedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasShapeRemovedEvent) Test(org.junit.Test)

Example 3 with CanvasShapeRemovedEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasShapeRemovedEvent in project kie-wb-common by kiegroup.

the class AbstractCanvas method deleteShape.

@Override
public Canvas deleteShape(final Shape shape) {
    deleteTransientShape(shape);
    fireCanvasShapeRemoved(shape);
    shapes.remove(shape);
    canvasShapeRemovedEvent.fire(new CanvasShapeRemovedEvent(this, shape));
    return this;
}
Also used : CanvasShapeRemovedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasShapeRemovedEvent)

Aggregations

CanvasShapeRemovedEvent (org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasShapeRemovedEvent)3 Test (org.junit.Test)2 Shape (org.kie.workbench.common.stunner.core.client.shape.Shape)1 Element (org.kie.workbench.common.stunner.core.graph.Element)1 Matchers.anyString (org.mockito.Matchers.anyString)1