Search in sources :

Example 1 with NodeMouseEnterEvent

use of com.ait.lienzo.client.core.event.NodeMouseEnterEvent in project lienzo-core by ahome-it.

the class LienzoHandlerManager method doCheckEnterExitShape.

// This will also return the shape under the cursor, for some optimization on Mouse Move
@SuppressWarnings("unchecked")
private final Shape<?> doCheckEnterExitShape(final INodeXYEvent event) {
    final int x = event.getX();
    final int y = event.getY();
    final Shape<?> shape = findShapeAtPoint(x, y);
    if (shape != null) {
        final IPrimitive<?> prim = shape.asPrimitive();
        if (null != m_over_prim) {
            if (prim != m_over_prim) {
                if (m_over_prim.isEventHandled(NodeMouseExitEvent.getType())) {
                    if (event instanceof AbstractNodeHumanInputEvent) {
                        m_over_prim.fireEvent(new NodeMouseExitEvent(((AbstractNodeHumanInputEvent<MouseEvent<?>, ?>) event).getHumanInputEvent(), x, y));
                    } else {
                        m_over_prim.fireEvent(new NodeMouseExitEvent(null, x, y));
                    }
                }
            }
        }
        if (prim != m_over_prim) {
            if ((null != prim) && (prim.isEventHandled(NodeMouseEnterEvent.getType()))) {
                if (event instanceof AbstractNodeHumanInputEvent) {
                    prim.fireEvent(new NodeMouseEnterEvent(((AbstractNodeHumanInputEvent<MouseEvent<?>, ?>) event).getHumanInputEvent(), x, y));
                } else {
                    prim.fireEvent(new NodeMouseEnterEvent(null, x, y));
                }
            }
            m_over_prim = prim;
        }
    } else {
        doCancelEnterExitShape(event);
    }
    return shape;
}
Also used : AbstractNodeHumanInputEvent(com.ait.lienzo.client.core.event.AbstractNodeHumanInputEvent) NodeMouseEnterEvent(com.ait.lienzo.client.core.event.NodeMouseEnterEvent) NodeMouseExitEvent(com.ait.lienzo.client.core.event.NodeMouseExitEvent) TouchPoint(com.ait.lienzo.client.core.event.TouchPoint)

Example 2 with NodeMouseEnterEvent

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

the class AbstractActionsToolboxViewTest method testAddButton.

@SuppressWarnings("unchecked")
protected void testAddButton(final String title) {
    // Verify tootlip.
    verify(toolboxTooltip, times(1)).createItem(eq(title));
    verify(buttonItem, times(1)).tooltip(any());
    // Verify mouse enter.
    final ArgumentCaptor<NodeMouseEnterHandler> enterHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseEnterHandler.class);
    verify(buttonItem, times(1)).onMouseEnter(enterHandlerArgumentCaptor.capture());
    final NodeMouseEnterHandler enterHandler = enterHandlerArgumentCaptor.getValue();
    final NodeMouseEnterEvent mouseEnterEvent = mock(NodeMouseEnterEvent.class);
    enterHandler.onNodeMouseEnter(mouseEnterEvent);
    verify(canvasView, times(1)).setCursor(eq(AbstractCanvas.Cursors.POINTER));
    // Verify mouse exit.
    final ArgumentCaptor<NodeMouseExitHandler> exitHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseExitHandler.class);
    verify(buttonItem, times(1)).onMouseExit(exitHandlerArgumentCaptor.capture());
    final NodeMouseExitHandler exitHandler = exitHandlerArgumentCaptor.getValue();
    final NodeMouseExitEvent mouseExitEvent = mock(NodeMouseExitEvent.class);
    exitHandler.onNodeMouseExit(mouseExitEvent);
    verify(canvasView, times(1)).setCursor(eq(AbstractCanvas.Cursors.DEFAULT));
}
Also used : NodeMouseEnterEvent(com.ait.lienzo.client.core.event.NodeMouseEnterEvent) NodeMouseExitHandler(com.ait.lienzo.client.core.event.NodeMouseExitHandler) NodeMouseEnterHandler(com.ait.lienzo.client.core.event.NodeMouseEnterHandler) NodeMouseExitEvent(com.ait.lienzo.client.core.event.NodeMouseExitEvent)

Example 3 with NodeMouseEnterEvent

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

the class AbstractActionsToolboxViewTest method testAddButton.

@SuppressWarnings("unchecked")
protected void testAddButton(final Consumer<MouseClickEvent> clickEventConsumer) {
    // Verify tootlip.
    verify(toolboxTooltip, times(1)).createItem(eq("title1"));
    verify(buttonItem, times(1)).tooltip(any(TooltipItem.class));
    // Verify mouse enter.
    final ArgumentCaptor<NodeMouseEnterHandler> enterHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseEnterHandler.class);
    verify(buttonItem, times(1)).onMouseEnter(enterHandlerArgumentCaptor.capture());
    final NodeMouseEnterHandler enterHandler = enterHandlerArgumentCaptor.getValue();
    final NodeMouseEnterEvent mouseEnterEvent = mock(NodeMouseEnterEvent.class);
    enterHandler.onNodeMouseEnter(mouseEnterEvent);
    verify(canvasView, times(1)).setCursor(eq(AbstractCanvas.Cursors.POINTER));
    // Verify mouse exit.
    final ArgumentCaptor<NodeMouseExitHandler> exitHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseExitHandler.class);
    verify(buttonItem, times(1)).onMouseExit(exitHandlerArgumentCaptor.capture());
    final NodeMouseExitHandler exitHandler = exitHandlerArgumentCaptor.getValue();
    final NodeMouseExitEvent mouseExitEvent = mock(NodeMouseExitEvent.class);
    exitHandler.onNodeMouseExit(mouseExitEvent);
    verify(canvasView, times(1)).setCursor(eq(AbstractCanvas.Cursors.AUTO));
    // Verify mouse click.
    final ArgumentCaptor<NodeMouseClickHandler> clickHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseClickHandler.class);
    verify(buttonItem, times(1)).onClick(clickHandlerArgumentCaptor.capture());
    final NodeMouseClickHandler clickHandler = clickHandlerArgumentCaptor.getValue();
    final NodeMouseClickEvent mouseClickEvent = mock(NodeMouseClickEvent.class);
    when(mouseClickEvent.getMouseEvent()).thenReturn(mock(MouseEvent.class));
    clickHandler.onNodeMouseClick(mouseClickEvent);
    verify(clickEventConsumer, times(1)).accept(any(MouseClickEvent.class));
}
Also used : NodeMouseClickHandler(com.ait.lienzo.client.core.event.NodeMouseClickHandler) MouseEvent(com.google.gwt.event.dom.client.MouseEvent) NodeMouseEnterEvent(com.ait.lienzo.client.core.event.NodeMouseEnterEvent) NodeMouseExitHandler(com.ait.lienzo.client.core.event.NodeMouseExitHandler) NodeMouseEnterHandler(com.ait.lienzo.client.core.event.NodeMouseEnterHandler) TooltipItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.TooltipItem) NodeMouseExitEvent(com.ait.lienzo.client.core.event.NodeMouseExitEvent) NodeMouseClickEvent(com.ait.lienzo.client.core.event.NodeMouseClickEvent) NodeMouseClickEvent(com.ait.lienzo.client.core.event.NodeMouseClickEvent) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent)

Example 4 with NodeMouseEnterEvent

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

the class ViewEventHandlerManagerTest method testMouseEnterHandler.

@Test
@SuppressWarnings("unchecked")
public void testMouseEnterHandler() {
    final ViewHandler<ViewEvent> clickHandler = mock(ViewHandler.class);
    final HandlerRegistration handlerRegistration = mock(HandlerRegistration.class);
    when(shape.addNodeMouseEnterHandler(any(NodeMouseEnterHandler.class))).thenReturn(handlerRegistration);
    tested.addHandler(ViewEventType.MOUSE_ENTER, clickHandler);
    final ArgumentCaptor<NodeMouseEnterHandler> clickHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseEnterHandler.class);
    verify(shape, times(1)).addNodeMouseEnterHandler(clickHandlerArgumentCaptor.capture());
    final NodeMouseEnterHandler nodeCLickHandler = clickHandlerArgumentCaptor.getValue();
    final NodeMouseEnterEvent clickEvent = mock(NodeMouseEnterEvent.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.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.onNodeMouseEnter(clickEvent);
    final ArgumentCaptor<ViewEvent> eventArgumentCaptor = ArgumentCaptor.forClass(ViewEvent.class);
    verify(clickHandler, times(1)).handle(eventArgumentCaptor.capture());
    final MouseEnterEvent viewEvent = (MouseEnterEvent) eventArgumentCaptor.getValue();
    assertEquals(x, viewEvent.getX(), 0d);
    assertEquals(y, viewEvent.getY(), 0d);
    assertEquals(x, viewEvent.getClientX(), 0d);
    assertEquals(y, viewEvent.getClientY(), 0d);
    assertTrue(viewEvent.isAltKeyDown());
    assertTrue(viewEvent.isMetaKeyDown());
    assertTrue(viewEvent.isShiftKeyDown());
    assertNotNull(tested.getRegistrationMap().get(ViewEventType.MOUSE_ENTER));
}
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) NodeMouseEnterEvent(com.ait.lienzo.client.core.event.NodeMouseEnterEvent) NodeMouseEnterEvent(com.ait.lienzo.client.core.event.NodeMouseEnterEvent) MouseEnterEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseEnterEvent) NodeMouseEnterHandler(com.ait.lienzo.client.core.event.NodeMouseEnterHandler) Test(org.junit.Test)

Aggregations

NodeMouseEnterEvent (com.ait.lienzo.client.core.event.NodeMouseEnterEvent)4 NodeMouseEnterHandler (com.ait.lienzo.client.core.event.NodeMouseEnterHandler)3 NodeMouseExitEvent (com.ait.lienzo.client.core.event.NodeMouseExitEvent)3 NodeMouseExitHandler (com.ait.lienzo.client.core.event.NodeMouseExitHandler)2 MouseEvent (com.google.gwt.event.dom.client.MouseEvent)2 AbstractNodeHumanInputEvent (com.ait.lienzo.client.core.event.AbstractNodeHumanInputEvent)1 NodeMouseClickEvent (com.ait.lienzo.client.core.event.NodeMouseClickEvent)1 NodeMouseClickHandler (com.ait.lienzo.client.core.event.NodeMouseClickHandler)1 TouchPoint (com.ait.lienzo.client.core.event.TouchPoint)1 HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)1 Test (org.junit.Test)1 MouseClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent)1 MouseEnterEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseEnterEvent)1 ViewEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent)1 TooltipItem (org.kie.workbench.common.stunner.lienzo.toolbox.items.TooltipItem)1