use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickEvent in project kie-wb-common by kiegroup.
the class ControlPointControlImpl method registerHandlers.
@SuppressWarnings("unchecked")
private void registerHandlers(final Element element, final Shape<?> shape) {
if (shape.getShapeView() instanceof HasEventHandlers && element instanceof Edge && element.getContent() instanceof ViewConnector) {
final HasEventHandlers hasEventHandlers = (HasEventHandlers) shape.getShapeView();
// Register handler on the Connector to Add a ControlPoint
MouseDoubleClickHandler eventHandler = new MouseDoubleClickHandler() {
@Override
public void handle(MouseDoubleClickEvent event) {
addControlPoint((Edge) element, new ControlPointImpl(event.getX(), event.getY()));
}
};
hasEventHandlers.addHandler(ViewEventType.MOUSE_DBL_CLICK, eventHandler);
registerHandler(element.getUUID(), eventHandler);
}
}
use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickEvent in project kie-wb-common by kiegroup.
the class ViewEventHandlerManager method registerDoubleClickHandler.
protected HandlerRegistration[] registerDoubleClickHandler(final ViewHandler<ViewEvent> eventHandler) {
return new HandlerRegistration[] { node.addNodeMouseDoubleClickHandler(nodeMouseDoubleClickEvent -> {
if (isEnabled()) {
skipClickHandler();
final MouseDoubleClickEvent event = new MouseDoubleClickEvent(nodeMouseDoubleClickEvent.getX(), nodeMouseDoubleClickEvent.getY(), nodeMouseDoubleClickEvent.getMouseEvent().getClientX(), nodeMouseDoubleClickEvent.getMouseEvent().getClientY());
event.setShiftKeyDown(nodeMouseDoubleClickEvent.isShiftKeyDown());
event.setAltKeyDown(nodeMouseDoubleClickEvent.isAltKeyDown());
event.setMetaKeyDown(nodeMouseDoubleClickEvent.isMetaKeyDown());
event.setButtonLeft(nodeMouseDoubleClickEvent.isButtonLeft());
event.setButtonMiddle(nodeMouseDoubleClickEvent.isButtonMiddle());
event.setButtonRight(nodeMouseDoubleClickEvent.isButtonRight());
eventHandler.handle(event);
restoreClickHandler();
}
}) };
}
use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickEvent 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