use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickHandler in project kie-wb-common by kiegroup.
the class LienzoSelectionControlTest method testRegisterAndClick.
@Test
public void testRegisterAndClick() {
tested.init(canvasHandler);
tested.register(element);
verify(selectionControl, times(1)).register(eq(element));
ArgumentCaptor<MouseClickHandler> clickHandlerCaptor = ArgumentCaptor.forClass(MouseClickHandler.class);
verify(shapeViewHandlers, times(1)).supports(eq(ViewEventType.MOUSE_CLICK));
verify(shapeViewHandlers, times(1)).addHandler(eq(ViewEventType.MOUSE_CLICK), clickHandlerCaptor.capture());
final MouseClickHandler clickHandler = clickHandlerCaptor.getValue();
assertEquals(clickHandler, tested.getHandlers().get(ELEMENT_UUID));
MouseClickEvent event = mock(MouseClickEvent.class);
when(event.isButtonLeft()).thenReturn(true);
clickHandler.handle(event);
verify(selectionControl, times(1)).select(eq(element.getUUID()));
}
use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickHandler in project kie-wb-common by kiegroup.
the class LienzoSelectionControl method onRegister.
@Override
protected void onRegister(final Element element) {
super.onRegister(element);
final Shape<?> shape = getSelectionControl().getCanvas().getShape(element.getUUID());
if (null != shape) {
final ShapeView shapeView = shape.getShapeView();
if (shapeView instanceof HasEventHandlers) {
final HasEventHandlers hasEventHandlers = (HasEventHandlers) shapeView;
if (hasEventHandlers.supports(ViewEventType.MOUSE_CLICK)) {
final MouseClickHandler clickHandler = new MouseClickHandler() {
@Override
public void handle(final MouseClickEvent event) {
if (event.isButtonLeft() || event.isButtonRight()) {
singleSelect(element);
}
}
};
hasEventHandlers.addHandler(ViewEventType.MOUSE_CLICK, clickHandler);
registerHandler(shape.getUUID(), clickHandler);
}
}
}
}
use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickHandler in project kie-wb-common by kiegroup.
the class MapSelectionControl method doInit.
@Override
protected void doInit() {
// Click handler for the canvas area - cleans current selection, if any.
final MouseClickHandler clickHandler = new MouseClickHandler() {
@Override
public void handle(final MouseClickEvent event) {
if (event.isButtonLeft() || event.isButtonRight()) {
clearSelection(false);
final String canvasRootUUID = getRootUUID();
fireCanvasClear();
if (null != canvasRootUUID) {
selectionEventConsumer.accept(new CanvasSelectionEvent(canvasHandler, canvasRootUUID));
}
}
}
};
getCanvas().addHandler(ViewEventType.MOUSE_CLICK, clickHandler);
this.layerClickHandler = clickHandler;
}
use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickHandler in project kie-wb-common by kiegroup.
the class MapSelectionControl method enable.
@Override
public void enable(final H canvasHandler) {
super.enable(canvasHandler);
final Layer layer = canvasHandler.getCanvas().getLayer();
// Click handler for the canvas area - cleans current selection, if any.
final MouseClickHandler clickHandler = new MouseClickHandler() {
@Override
public void handle(final MouseClickEvent event) {
if (event.isButtonLeft() || event.isButtonRight()) {
clearSelection(false);
final String canvasRootUUID = getRootUUID();
fireCanvasClear();
if (null != canvasRootUUID) {
selectionEventConsumer.accept(new CanvasSelectionEvent(canvasHandler, canvasRootUUID));
}
}
}
};
layer.addHandler(ViewEventType.MOUSE_CLICK, clickHandler);
this.layerClickHandler = clickHandler;
}
use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickHandler in project kie-wb-common by kiegroup.
the class MapSelectionControlTest method testLayerClickAndClear.
@Test
public void testLayerClickAndClear() {
when(metadata.getCanvasRootUUID()).thenReturn(null);
tested.init(canvasHandler);
final ArgumentCaptor<MouseClickHandler> clickHandlerArgumentCaptor = ArgumentCaptor.forClass(MouseClickHandler.class);
verify(canvas, times(1)).addHandler(eq(ViewEventType.MOUSE_CLICK), clickHandlerArgumentCaptor.capture());
final MouseClickHandler clickHandler = clickHandlerArgumentCaptor.getValue();
final MouseClickEvent event = new MouseClickEvent(12, 20, 30, 40);
event.setButtonLeft(true);
event.setShiftKeyDown(false);
clickHandler.handle(event);
verify(clearSelectionEvent, times(1)).fire(any(CanvasClearSelectionEvent.class));
verify(elementSelectedEvent, never()).fire(any(CanvasSelectionEvent.class));
}
Aggregations