Search in sources :

Example 6 with NodeMouseDoubleClickEvent

use of com.ait.lienzo.client.core.event.NodeMouseDoubleClickEvent in project kie-wb-common by kiegroup.

the class ViewEventHandlerManagerTest method testDoubleClickHandler.

@Test
@SuppressWarnings("unchecked")
public void testDoubleClickHandler() {
    final ViewHandler<ViewEvent> clickHandler = mock(ViewHandler.class);
    final HandlerRegistration handlerRegistration = mock(HandlerRegistration.class);
    when(node.addNodeMouseDoubleClickHandler(any(NodeMouseDoubleClickHandler.class))).thenReturn(handlerRegistration);
    tested.addHandler(ViewEventType.MOUSE_DBL_CLICK, clickHandler);
    final ArgumentCaptor<NodeMouseDoubleClickHandler> clickHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseDoubleClickHandler.class);
    verify(node, times(1)).addNodeMouseDoubleClickHandler(clickHandlerArgumentCaptor.capture());
    final NodeMouseDoubleClickHandler nodeCLickHandler = clickHandlerArgumentCaptor.getValue();
    final NodeMouseDoubleClickEvent clickEvent = mock(NodeMouseDoubleClickEvent.class);
    final MouseEvent mouseEvent = mock(MouseEvent.class);
    final int x = 102;
    final int y = 410;
    when(clickEvent.getX()).thenReturn(x);
    when(clickEvent.getY()).thenReturn(y);
    when(clickEvent.isButtonLeft()).thenReturn(true);
    when(clickEvent.isButtonRight()).thenReturn(true);
    when(clickEvent.isButtonMiddle()).thenReturn(true);
    when(clickEvent.isShiftKeyDown()).thenReturn(true);
    when(clickEvent.isAltKeyDown()).thenReturn(true);
    when(clickEvent.isMetaKeyDown()).thenReturn(true);
    when(clickEvent.getMouseEvent()).thenReturn(mouseEvent);
    when(mouseEvent.getClientX()).thenReturn(x);
    when(mouseEvent.getClientY()).thenReturn(y);
    nodeCLickHandler.onNodeMouseDoubleClick(clickEvent);
    final ArgumentCaptor<ViewEvent> eventArgumentCaptor = ArgumentCaptor.forClass(ViewEvent.class);
    verify(clickHandler, times(1)).handle(eventArgumentCaptor.capture());
    final MouseDoubleClickEvent viewEvent = (MouseDoubleClickEvent) eventArgumentCaptor.getValue();
    assertEquals(x, viewEvent.getX(), 0d);
    assertEquals(y, viewEvent.getY(), 0d);
    assertEquals(x, viewEvent.getClientX(), 0d);
    assertEquals(y, viewEvent.getClientY(), 0d);
    assertTrue(viewEvent.isButtonLeft());
    assertTrue(viewEvent.isButtonRight());
    assertTrue(viewEvent.isButtonMiddle());
    assertTrue(viewEvent.isAltKeyDown());
    assertTrue(viewEvent.isMetaKeyDown());
    assertTrue(viewEvent.isShiftKeyDown());
    assertNotNull(tested.getRegistrationMap().get(ViewEventType.MOUSE_DBL_CLICK));
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) MouseEvent(com.google.gwt.event.dom.client.MouseEvent) ViewEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent) MouseDoubleClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickEvent) NodeMouseDoubleClickEvent(com.ait.lienzo.client.core.event.NodeMouseDoubleClickEvent) NodeMouseDoubleClickEvent(com.ait.lienzo.client.core.event.NodeMouseDoubleClickEvent) NodeMouseDoubleClickHandler(com.ait.lienzo.client.core.event.NodeMouseDoubleClickHandler) Test(org.junit.Test)

Example 7 with NodeMouseDoubleClickEvent

use of com.ait.lienzo.client.core.event.NodeMouseDoubleClickEvent in project drools-wb by kiegroup.

the class GuidedDecisionTablePresenterTest method checkRegisteredNodeMouseDoubleClickHandlerOverHeader.

@Test
@SuppressWarnings("unchecked")
public void checkRegisteredNodeMouseDoubleClickHandlerOverHeader() {
    final ArgumentCaptor<NodeMouseDoubleClickHandler> nodeMouseDoubleClickHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseDoubleClickHandler.class);
    // dtPresenter.setContent(...) is called by the base tests @Before method
    verify(view, times(1)).registerNodeMouseDoubleClickHandler(nodeMouseDoubleClickHandlerArgumentCaptor.capture());
    final NodeMouseDoubleClickHandler nodeMouseDoubleClickHandler = nodeMouseDoubleClickHandlerArgumentCaptor.getValue();
    assertNotNull(nodeMouseDoubleClickHandler);
    // Mouse over Header, not pinned
    final NodeMouseDoubleClickEvent event = mock(NodeMouseDoubleClickEvent.class);
    when(view.isNodeMouseEventOverCaption(eq(event))).thenReturn(true);
    when(modellerPresenter.isGridPinned()).thenReturn(false);
    nodeMouseDoubleClickHandler.onNodeMouseDoubleClick(event);
    verify(dtPresenter, times(1)).enterPinnedMode(eq(view), any(Command.class));
    // Mouse over Header, pinned
    when(modellerPresenter.isGridPinned()).thenReturn(true);
    nodeMouseDoubleClickHandler.onNodeMouseDoubleClick(event);
    verify(dtPresenter, times(1)).exitPinnedMode(any(Command.class));
}
Also used : Command(com.google.gwt.user.client.Command) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) NodeMouseDoubleClickEvent(com.ait.lienzo.client.core.event.NodeMouseDoubleClickEvent) NodeMouseDoubleClickHandler(com.ait.lienzo.client.core.event.NodeMouseDoubleClickHandler) Test(org.junit.Test)

Aggregations

NodeMouseDoubleClickEvent (com.ait.lienzo.client.core.event.NodeMouseDoubleClickEvent)7 NodeMouseDoubleClickHandler (com.ait.lienzo.client.core.event.NodeMouseDoubleClickHandler)4 NodeMouseClickEvent (com.ait.lienzo.client.core.event.NodeMouseClickEvent)3 Test (org.junit.Test)3 MouseEvent (com.google.gwt.event.dom.client.MouseEvent)2 HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)2 ViewEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent)2 NodeGestureChangeEvent (com.ait.lienzo.client.core.event.NodeGestureChangeEvent)1 NodeGestureEndEvent (com.ait.lienzo.client.core.event.NodeGestureEndEvent)1 NodeGestureStartEvent (com.ait.lienzo.client.core.event.NodeGestureStartEvent)1 NodeMouseDownEvent (com.ait.lienzo.client.core.event.NodeMouseDownEvent)1 NodeMouseMoveEvent (com.ait.lienzo.client.core.event.NodeMouseMoveEvent)1 NodeMouseOutEvent (com.ait.lienzo.client.core.event.NodeMouseOutEvent)1 NodeMouseOverEvent (com.ait.lienzo.client.core.event.NodeMouseOverEvent)1 NodeMouseUpEvent (com.ait.lienzo.client.core.event.NodeMouseUpEvent)1 NodeMouseWheelEvent (com.ait.lienzo.client.core.event.NodeMouseWheelEvent)1 NodeTouchCancelEvent (com.ait.lienzo.client.core.event.NodeTouchCancelEvent)1 NodeTouchEndEvent (com.ait.lienzo.client.core.event.NodeTouchEndEvent)1 NodeTouchMoveEvent (com.ait.lienzo.client.core.event.NodeTouchMoveEvent)1 NodeTouchStartEvent (com.ait.lienzo.client.core.event.NodeTouchStartEvent)1