use of org.kie.workbench.common.stunner.core.client.shape.NodeShape in project kie-wb-common by kiegroup.
the class NodeProxyTest method verifyCreateTargetNode.
@SuppressWarnings("all")
private void verifyCreateTargetNode(CanvasCommand<AbstractCanvasHandler> addConnectorCommand, CanvasCommand<AbstractCanvasHandler> addNodeCommand, CanvasCommand<AbstractCanvasHandler> setTargetNodeCommand) {
tested.init();
tested.start(1d, 2d);
verify(proxy, times(1)).start(eq(1d), eq(2d));
NodeShape targetNodeShape = view.getShapeBuilder().get();
assertEquals(targetShape, targetNodeShape);
ArgumentCaptor<Command> commandCaptor = ArgumentCaptor.forClass(Command.class);
verify(proxy, times(1)).execute(commandCaptor.capture());
DeferredCompositeCommand command = (DeferredCompositeCommand) commandCaptor.getValue();
List commands = command.getCommands();
assertEquals(3, command.size());
DeferredCommand c0 = (DeferredCommand) commands.get(0);
assertEquals(addNodeCommand, c0.getCommand());
DeferredCommand c1 = (DeferredCommand) commands.get(1);
assertEquals(addConnectorCommand, c1.getCommand());
DeferredCommand c2 = (DeferredCommand) commands.get(2);
assertEquals(setTargetNodeCommand, c2.getCommand());
}
use of org.kie.workbench.common.stunner.core.client.shape.NodeShape in project kie-wb-common by kiegroup.
the class NodeProxy method onCreateProxy.
private NodeShape onCreateProxy() {
final CanvasCommandFactory<AbstractCanvasHandler> commandFactory = proxy.lookupCanvasFactory();
final Node<View<?>, Edge> parent = getParent();
proxy.execute(new DeferredCompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation>().deferCommand(() -> null != parent ? commandFactory.addChildNode(parent, targetNode, getShapeSetId()) : commandFactory.addNode(targetNode, getShapeSetId())).deferCommand(() -> commandFactory.addConnector(sourceNode, edge, MagnetConnection.Builder.atCenter(sourceNode), getShapeSetId())).deferCommand(() -> commandFactory.setTargetNode(targetNode, edge, MagnetConnection.Builder.forTarget(sourceNode, targetNode))).build());
final Canvas canvas = proxy.getCanvas();
final NodeShape targetShape = getTargetShape();
final Shape<?> edgeShape = canvas.getShape(edge.getUUID());
edgeShape.applyState(ShapeState.SELECTED);
return targetShape;
}
Aggregations