Search in sources :

Example 31 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration in project kie-wb-common by kiegroup.

the class WiresShapeViewExt method registerResizeHandler.

private HandlerRegistration[] registerResizeHandler(final ViewHandler<ResizeEvent> eventHandler) {
    final ResizeHandler resizeHandler = (ResizeHandler) eventHandler;
    setResizable(true);
    HandlerRegistration r0 = addWiresResizeStartHandler(wiresResizeStartEvent -> {
        final ResizeEvent event = buildResizeEvent(wiresResizeStartEvent);
        resizeHandler.start(event);
        rebuildTextBoundaries(event.getWidth(), event.getHeight());
    });
    HandlerRegistration r1 = addWiresResizeStepHandler(wiresResizeStepEvent -> {
        final ResizeEvent event = buildResizeEvent(wiresResizeStepEvent);
        resizeHandler.handle(event);
        rebuildTextBoundaries(event.getWidth(), event.getHeight());
    });
    HandlerRegistration r2 = addWiresResizeEndHandler(wiresResizeEndEvent -> {
        final ResizeEvent event = buildResizeEvent(wiresResizeEndEvent);
        resizeHandler.end(event);
        rebuildTextBoundaries(event.getWidth(), event.getHeight());
    });
    return new HandlerRegistration[] { r0, r1, r2 };
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) ResizeHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.ResizeHandler) AbstractWiresResizeEvent(com.ait.lienzo.client.core.shape.wires.event.AbstractWiresResizeEvent) ResizeEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.ResizeEvent)

Example 32 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration in project kie-wb-common by kiegroup.

the class WiresTextDecorator method registerDoubleClickHandler.

private void registerDoubleClickHandler() {
    HandlerRegistration registration = text.addNodeMouseDoubleClickHandler(event -> {
        if (null != textDblClickEventViewHandler) {
            eventHandlerManager.get().skipClickHandler();
            final TextDoubleClickEvent e = new TextDoubleClickEvent(event.getX(), event.getY(), event.getMouseEvent().getClientX(), event.getMouseEvent().getClientY());
            textDblClickEventViewHandler.handle(e);
            eventHandlerManager.get().restoreClickHandler();
        }
    });
    eventHandlerManager.get().addHandlersRegistration(ViewEventType.TEXT_DBL_CLICK, registration);
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) TextDoubleClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.TextDoubleClickEvent)

Example 33 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration in project kie-wb-common by kiegroup.

the class WiresTextDecorator method registerTextEnterHandler.

private void registerTextEnterHandler() {
    HandlerRegistration registration = text.addNodeMouseEnterHandler(event -> {
        if (null != textOverHandlerViewHandler && hasText()) {
            final TextEnterEvent textOverEvent = new TextEnterEvent(event.getX(), event.getY(), event.getMouseEvent().getClientX(), event.getMouseEvent().getClientY());
            textOverHandlerViewHandler.handle(textOverEvent);
        }
    });
    eventHandlerManager.get().addHandlersRegistration(ViewEventType.TEXT_ENTER, registration);
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) TextEnterEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.TextEnterEvent)

Example 34 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration in project kie-wb-common by kiegroup.

the class WiresTextDecorator method registerClickHandler.

private void registerClickHandler() {
    HandlerRegistration registration = text.addNodeMouseClickHandler(event -> {
        if (null != textClickEventViewHandler) {
            eventHandlerManager.get().skipClickHandler();
            final TextClickEvent e = new TextClickEvent(event.getX(), event.getY(), event.getMouseEvent().getClientX(), event.getMouseEvent().getClientY());
            textClickEventViewHandler.handle(e);
            eventHandlerManager.get().restoreClickHandler();
        }
    });
    eventHandlerManager.get().addHandlersRegistration(ViewEventType.TEXT_CLICK, registration);
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) TextClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.TextClickEvent)

Example 35 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration 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)

Aggregations

HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)48 Test (org.junit.Test)7 MouseEvent (com.google.gwt.event.dom.client.MouseEvent)4 ViewEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent)4 NodeMouseEnterEvent (com.ait.lienzo.client.core.event.NodeMouseEnterEvent)2 NodeMouseEnterHandler (com.ait.lienzo.client.core.event.NodeMouseEnterHandler)2 NodeMouseExitEvent (com.ait.lienzo.client.core.event.NodeMouseExitEvent)2 NodeMouseExitHandler (com.ait.lienzo.client.core.event.NodeMouseExitHandler)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 Widget (com.google.gwt.user.client.ui.Widget)2 Map (java.util.Map)2 MouseDoubleClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickEvent)2 MouseEnterEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseEnterEvent)2 CommandWithArg (org.rstudio.core.client.CommandWithArg)2 Mutable (org.rstudio.core.client.Mutable)2 Attribute (com.ait.lienzo.client.core.Attribute)1 AbstractNodeGestureEvent (com.ait.lienzo.client.core.event.AbstractNodeGestureEvent)1 NodeGestureChangeEvent (com.ait.lienzo.client.core.event.NodeGestureChangeEvent)1 NodeGestureChangeHandler (com.ait.lienzo.client.core.event.NodeGestureChangeHandler)1