use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent 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.MouseClickEvent in project kie-wb-common by kiegroup.
the class MorphNodeToolboxActionTest method testAction.
@Test
public void testAction() {
final MouseClickEvent event = mock(MouseClickEvent.class);
ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, E_UUID, event);
assertEquals(tested, cascade);
verify(commandFactory, times(1)).morphNode(eq(element), eq(morphDefinition), eq(MORPH_TARGET_ID), eq(SSID_UUID));
verify(sessionCommandManager, times(1)).execute(eq(canvasHandler), eq(morphNodeCommand));
final ArgumentCaptor<CanvasSelectionEvent> eventArgumentCaptor = ArgumentCaptor.forClass(CanvasSelectionEvent.class);
verify(canvasElementSelectedEvent, times(1)).fire(eventArgumentCaptor.capture());
final CanvasSelectionEvent eCaptured = eventArgumentCaptor.getValue();
assertEquals(E_UUID, eCaptured.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 CreateNodeToolboxActionTest method testOnMouseClick.
@Test
public void testOnMouseClick() {
when(canvasLayoutUtils.getNext(eq(canvasHandler), eq(element), eq(targetNode))).thenReturn(new Point2D(100d, 500d));
final MouseClickEvent event = mock(MouseClickEvent.class);
when(event.getX()).thenReturn(100d);
when(event.getY()).thenReturn(500d);
ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, NODE_UUID, event);
assertEquals(tested, cascade);
verify(action).executeAction(canvasHandler, NODE_UUID, TARGET_NODE_ID, EDGE_ID);
}
use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent in project kie-wb-common by kiegroup.
the class DeleteNodeToolboxActionTest method testAction.
@Test
public void testAction() {
final MouseClickEvent event = mock(MouseClickEvent.class);
final ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, E_UUID, event);
assertEquals(tested, cascade);
verify(commandFactory, times(1)).deleteNode(eq(element));
verify(sessionCommandManager, times(1)).execute(eq(canvasHandler), eq(deleteNodeCommand));
verify(clearSelectionEventEventSourceMock).fire(any(CanvasClearSelectionEvent.class));
}
use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent in project kie-wb-common by kiegroup.
the class DeleteNodeToolboxActionTest method testSkipAction.
@Test
@SuppressWarnings("unchecked")
public void testSkipAction() {
this.tested = new DeleteNodeToolboxAction(translationService, sessionCommandManager, commandFactories, definitionUtils, action -> false, clearSelectionEventEventSourceMock);
final MouseClickEvent event = mock(MouseClickEvent.class);
final ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, E_UUID, event);
assertEquals(tested, cascade);
verify(sessionCommandManager, never()).execute(eq(canvasHandler), any(CanvasCommand.class));
verify(clearSelectionEventEventSourceMock, never()).fire(any(CanvasClearSelectionEvent.class));
}
Aggregations