Search in sources :

Example 11 with CanvasSelectionEvent

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

the class MorphNodeActionTest method testAction.

@Test
public void testAction() {
    final MouseClickEvent event = mock(MouseClickEvent.class);
    ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, E_UUID, event);
    assertEquals(tested, cascade);
    verify(commandFactory, times(1)).morphNode(eq(element), eq(morphDefinition), eq(MORPH_TARGET_ID), eq(SSID_UUID));
    verify(sessionCommandManager, times(1)).execute(eq(canvasHandler), eq(morphNodeCommand));
    final ArgumentCaptor<CanvasSelectionEvent> eventArgumentCaptor = ArgumentCaptor.forClass(CanvasSelectionEvent.class);
    verify(canvasElementSelectedEvent, times(1)).fire(eventArgumentCaptor.capture());
    final CanvasSelectionEvent eCaptured = eventArgumentCaptor.getValue();
    assertEquals(E_UUID, eCaptured.getIdentifiers().iterator().next());
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) CanvasSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent) Test(org.junit.Test)

Example 12 with CanvasSelectionEvent

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

the class BaseSessionCommandKeyboardSelectionAwareTest method testHandleCanvasSelectionEventWhenCanvasRootIsSelected.

@Test
public void testHandleCanvasSelectionEventWhenCanvasRootIsSelected() {
    command.bind(session);
    List<String> selectedIds = new ArrayList<>();
    selectedIds.add(CANVAS_ROOT_ID);
    CanvasSelectionEvent selectionEvent = new CanvasSelectionEvent(canvasHandler, selectedIds);
    ((AbstractSelectionAwareSessionCommand) command).handleCanvasSelectionEvent(selectionEvent);
    assertFalse(command.isEnabled());
    verify(statusCallback, times(1)).execute();
}
Also used : CanvasSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 13 with CanvasSelectionEvent

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

the class BaseSessionCommandKeyboardSelectionAwareTest method testHandleCanvasSelectionEventWhenElementsAreSelected.

@Test
public void testHandleCanvasSelectionEventWhenElementsAreSelected() {
    command.bind(session);
    List<String> selectedIds = new ArrayList<>();
    selectedIds.add("id1");
    selectedIds.add("id2");
    CanvasSelectionEvent selectionEvent = new CanvasSelectionEvent(canvasHandler, selectedIds);
    ((AbstractSelectionAwareSessionCommand) command).handleCanvasSelectionEvent(selectionEvent);
    assertTrue(command.isEnabled());
    verify(statusCallback, times(1)).execute();
}
Also used : CanvasSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 14 with CanvasSelectionEvent

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

the class MapSelectionControl method enable.

@Override
public void enable(final H canvasHandler) {
    super.enable(canvasHandler);
    final Layer layer = canvasHandler.getCanvas().getLayer();
    // Click handler for the canvas area - cleans current selection, if any.
    final MouseClickHandler clickHandler = new MouseClickHandler() {

        @Override
        public void handle(final MouseClickEvent event) {
            if (event.isButtonLeft() || event.isButtonRight()) {
                clearSelection(false);
                final String canvasRootUUID = getRootUUID();
                fireCanvasClear();
                if (null != canvasRootUUID) {
                    selectionEventConsumer.accept(new CanvasSelectionEvent(canvasHandler, canvasRootUUID));
                }
            }
        }
    };
    layer.addHandler(ViewEventType.MOUSE_CLICK, clickHandler);
    this.layerClickHandler = clickHandler;
}
Also used : MouseClickHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickHandler) CanvasSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent) Layer(org.kie.workbench.common.stunner.core.client.canvas.Layer) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent)

Example 15 with CanvasSelectionEvent

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

the class ControlPointControlImplTest method setUp.

@Before
public void setUp() {
    super.setUp();
    initialControlPointPosition = new Point2D(0, 0);
    newControlPointPosition = new Point2D(10, 10);
    controlPoint1 = new ControlPointImpl(initialControlPointPosition);
    canvasSelectionEvent = new CanvasSelectionEvent(canvasHandler, EDGE_UUID);
    canvasControlPointDragStartEvent = new CanvasControlPointDragStartEvent(initialControlPointPosition);
    canvasControlPointDragEndEvent = new CanvasControlPointDragEndEvent(newControlPointPosition);
    canvasControlPointDoubleClickEvent = new CanvasControlPointDoubleClickEvent(initialControlPointPosition);
    controlPointControl = spy(new ControlPointControlImpl(canvasCommandFactory));
    when(canvas.getShape(EDGE_UUID)).thenReturn(connectorShape);
    when(graphIndex.get(EDGE_UUID)).thenReturn(edge);
    when(graphIndex.getEdge(EDGE_UUID)).thenReturn(edge);
    when(edge.getContent()).thenReturn(viewConnector);
    when(edge.getUUID()).thenReturn(EDGE_UUID);
    when(connectorShape.getShapeView()).thenReturn(shapeView);
    when(viewConnector.getControlPoints()).thenReturn(Arrays.asList(controlPoint1));
    controlPointControl.enable(canvasHandler);
    controlPointControl.setCommandManagerProvider(() -> commandManager);
    controlPointControl.register(edge);
}
Also used : CanvasSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) CanvasControlPointDragStartEvent(org.kie.workbench.common.stunner.core.client.canvas.event.controlpoint.CanvasControlPointDragStartEvent) CanvasControlPointDragEndEvent(org.kie.workbench.common.stunner.core.client.canvas.event.controlpoint.CanvasControlPointDragEndEvent) ControlPointImpl(org.kie.workbench.common.stunner.core.graph.content.view.ControlPointImpl) CanvasControlPointDoubleClickEvent(org.kie.workbench.common.stunner.core.client.canvas.event.controlpoint.CanvasControlPointDoubleClickEvent) Before(org.junit.Before)

Aggregations

CanvasSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent)15 Test (org.junit.Test)10 MouseClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent)5 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)4 MouseClickHandler (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickHandler)3 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 Layer (org.kie.workbench.common.stunner.core.client.canvas.Layer)2 CanvasClearSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent)2 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)2 Timer (com.google.gwt.user.client.Timer)1 Collections (java.util.Collections)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 RunWith (org.junit.runner.RunWith)1 AbstractCanvas (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvas)1 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)1 AddConnectorCommand (org.kie.workbench.common.stunner.core.client.canvas.command.AddConnectorCommand)1 AddNodeCommand (org.kie.workbench.common.stunner.core.client.canvas.command.AddNodeCommand)1