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 };
}
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);
}
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);
}
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);
}
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));
}
Aggregations