use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent in project kie-wb-common by kiegroup.
the class DMNDeleteNodeToolboxActionTest method testOnMouseClickWhenNodeRequiresDeletionConfirmation.
@Test
public void testOnMouseClickWhenNodeRequiresDeletionConfirmation() {
final String nodeUuid = "node uuid";
final Element element = mock(Element.class);
final Node node = mock(Node.class);
final MouseClickEvent event = new MouseClickEvent(0, 0, 0, 0);
when(element.asNode()).thenReturn(node);
when(graphIndex.get(nodeUuid)).thenReturn(element);
when(deleteNodeConfirmation.requiresDeletionConfirmation(Collections.singleton(node))).thenReturn(true);
toolboxAction.onMouseClick(canvasHandler, nodeUuid, event);
verify(deleteNodeConfirmation).confirmDeletion(any(), any(), any());
verify(toolboxAction, never()).superOnMouseClick(canvasHandler, nodeUuid, event);
}
use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent in project kie-wb-common by kiegroup.
the class DMNEditDecisionToolboxActionTest method testActionWhenIsReadOnlyDiagram.
@Test
public void testActionWhenIsReadOnlyDiagram() {
when(readOnlyProvider.isReadOnlyDiagram()).thenReturn(true);
final MouseClickEvent event = mock(MouseClickEvent.class);
final ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, E_UUID, event);
assertEquals(tested, cascade);
final ArgumentCaptor<EditExpressionEvent> eventCaptor = ArgumentCaptor.forClass(EditExpressionEvent.class);
verify(editExpressionEvent, times(1)).fire(eventCaptor.capture());
final EditExpressionEvent editExprEvent = eventCaptor.getValue();
assertEquals(E_UUID, editExprEvent.getNodeUUID());
assertEquals(decision, editExprEvent.getHasExpression());
assertEquals(decision, editExprEvent.getHasName().get());
assertEquals(session, editExprEvent.getSession());
assertTrue(editExprEvent.isOnlyVisualChangeAllowed());
}
use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent 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));
}
use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent in project kie-wb-common by kiegroup.
the class MapSelectionControlTest method testLayerClickAndSelectRootElement.
@Test
public void testLayerClickAndSelectRootElement() {
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);
final ArgumentCaptor<CanvasSelectionEvent> elementSelectedEventArgumentCaptor = ArgumentCaptor.forClass(CanvasSelectionEvent.class);
verify(elementSelectedEvent, times(1)).fire(elementSelectedEventArgumentCaptor.capture());
verify(clearSelectionEvent, times(1)).fire(any(CanvasClearSelectionEvent.class));
final CanvasSelectionEvent ese = elementSelectedEventArgumentCaptor.getValue();
assertEquals(ROOT_UUID, ese.getIdentifiers().iterator().next());
}
use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent in project kie-wb-common by kiegroup.
the class ToolboxControlImpl method register.
@Override
@SuppressWarnings("unchecked")
public void register(final Element element) {
if (checkNotRegistered(element) && supportsToolbox(element)) {
final Shape shape = canvasHandler.getCanvas().getShape(element.getUUID());
final HasEventHandlers hasEventHandlers = (HasEventHandlers) shape.getShapeView();
if (hasEventHandlers.supports(ViewEventType.MOUSE_CLICK)) {
final MouseClickHandler clickHandler = new MouseClickHandler() {
@Override
public void handle(final MouseClickEvent event) {
if (event.isButtonLeft()) {
show(element);
}
}
};
hasEventHandlers.addHandler(ViewEventType.MOUSE_CLICK, clickHandler);
registerHandler(element.getUUID(), clickHandler);
}
}
}
Aggregations