use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.
the class ActionsToolbox method addButton.
private void addButton(final ToolboxAction<AbstractCanvasHandler> action) {
final AbstractCanvasHandler canvasHandler = canvasHandlerSupplier.get();
getView().addButton(action.getGlyph(canvasHandler, uuid), action.getTitle(canvasHandler, uuid), event -> action.onMouseClick(canvasHandler, uuid, event));
}
use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.
the class CreateConnectorActionTest method testStartDrag.
@SuppressWarnings("unchecked")
private DragProxyCallback testStartDrag() {
final MouseClickEvent event = mock(MouseClickEvent.class);
when(event.getX()).thenReturn(100d);
when(event.getY()).thenReturn(500d);
when(graphBoundsIndexer.getAt(eq(100d), eq(500d))).thenReturn(targetNode);
ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, NODE_UUID, event);
assertEquals(tested, cascade);
verify(edge, times(1)).setSourceNode(eq(element));
verify(connectorDragProxyFactory, times(1)).proxyFor(eq(canvasHandler));
ArgumentCaptor<DragProxyCallback> proxyArgumentCaptor = ArgumentCaptor.forClass(DragProxyCallback.class);
verify(connectorDragProxyFactory, times(1)).show(any(ConnectorDragProxy.Item.class), eq(100), eq(500), proxyArgumentCaptor.capture());
final DragProxyCallback callback = proxyArgumentCaptor.getValue();
// Verify drag proxy start.
callback.onStart(0, 0);
assertNotNull(tested.getCanvasHighlight());
verify(graphBoundsIndexer, times(1)).setRootUUID(eq(ROOT_UUID));
verify(graphBoundsIndexer, times(1)).build(eq(graph));
verify(edgeBuilderControl, times(1)).enable(eq(canvasHandler));
ArgumentCaptor<RequiresCommandManager.CommandManagerProvider> providerArgumentCaptor = ArgumentCaptor.forClass(RequiresCommandManager.CommandManagerProvider.class);
verify(edgeBuilderControl, times(1)).setCommandManagerProvider(providerArgumentCaptor.capture());
RequiresCommandManager.CommandManagerProvider cmProvider = providerArgumentCaptor.getValue();
assertEquals(sessionCommandManager, cmProvider.getCommandManager());
return callback;
}
use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.
the class CreateNodeActionTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
when(canvasHandler.getGraphIndex()).thenReturn(graphIndex);
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(canvasHandler.getCanvas()).thenReturn(canvas);
when(canvasHandler.getShapeFactory(eq(SSID_UUID))).thenReturn(shapeFactory);
when(canvas.getLayer()).thenReturn(layer);
when(diagram.getGraph()).thenReturn(graph);
when(diagram.getMetadata()).thenReturn(metadata);
when(metadata.getShapeSetId()).thenReturn(SSID_UUID);
when(metadata.getCanvasRootUUID()).thenReturn(ROOT_UUID);
when(graphIndex.get(eq(NODE_UUID))).thenReturn(element);
when(graphIndex.getNode(eq(NODE_UUID))).thenReturn(element);
when(graphIndex.get(eq(EDGE_UUID))).thenReturn(edge);
when(graphIndex.getEdge(eq(EDGE_UUID))).thenReturn(edge);
when(graphIndex.get(eq(TARGET_NODE_UUID))).thenReturn(targetNode);
when(graphIndex.getNode(eq(TARGET_NODE_UUID))).thenReturn(targetNode);
when(element.getUUID()).thenReturn(NODE_UUID);
when(element.getContent()).thenReturn(elementContent);
when(element.asNode()).thenReturn(element);
when(edge.getUUID()).thenReturn(EDGE_UUID);
when(edge.asEdge()).thenReturn(edge);
when(targetNode.getUUID()).thenReturn(TARGET_NODE_UUID);
when(targetNode.asNode()).thenReturn(targetNode);
when(targetNode.getContent()).thenReturn(targetNodeContent);
when(sessionCommandManager.execute(eq(canvasHandler), any(Command.class))).thenReturn(CanvasCommandResultBuilder.SUCCESS);
when(elementContent.getBounds()).thenReturn(new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 100d)));
when(targetNodeContent.getBounds()).thenReturn(new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 100d)));
when(clientFactoryManager.newElement(anyString(), eq(EDGE_ID))).thenReturn((Element) edge);
when(clientFactoryManager.newElement(anyString(), eq(TARGET_NODE_ID))).thenReturn((Element) targetNode);
CanvasCommandFactory<AbstractCanvasHandler> canvasCommandFactory = new DefaultCanvasCommandFactory(null, null);
this.tested = new CreateNodeAction(definitionUtils, clientFactoryManager, canvasLayoutUtils, canvasElementSelectedEvent, translationService, sessionCommandManager, canvasCommandFactory).setEdgeId(EDGE_ID).setNodeId(TARGET_NODE_ID);
}
use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.
the class DeleteNodeActionTest method testSkipAction.
@Test
@SuppressWarnings("unchecked")
public void testSkipAction() {
this.tested = new DeleteNodeAction(translationService, sessionCommandManager, commandFactory, action -> false);
final MouseClickEvent event = mock(MouseClickEvent.class);
ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, E_UUID, event);
assertEquals(tested, cascade);
verify(sessionCommandManager, never()).execute(eq(canvasHandler), any(CanvasCommand.class));
}
use of org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler in project kie-wb-common by kiegroup.
the class DeleteNodeActionTest 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)).deleteNode(eq(element));
verify(sessionCommandManager, times(1)).execute(eq(canvasHandler), eq(deleteNodeCommand));
}
Aggregations