@Test @SuppressWarnings("unchecked") public void testMorphSomeContainerNode() { TestingGraphInstanceBuilder.TestGraph3 graphInstance = mockGraph3(); this.tested = new MorphCanvasNodeCommand(graphInstance.containerNode, NEW_SHAPE_SET_ID); CommandResult<CanvasViolation> result = tested.execute(canvasHandler); assertFalse(CommandUtils.isError(result)); verify(canvasHandler, times(1)).deregister(graphInstance.containerNode); verify(canvasHandler, times(1)).removeChild(graphInstance.parentNode, graphInstance.containerNode); verify(canvasHandler, times(1)).removeChild(graphInstance.containerNode, graphInstance.startNode); verify(canvasHandler, times(1)).removeChild(graphInstance.containerNode, graphInstance.intermNode); verify(canvasHandler, times(1)).removeChild(graphInstance.containerNode, graphInstance.endNode); verify(canvasHandler, times(1)).register(NEW_SHAPE_SET_ID, graphInstance.containerNode); verify(canvasHandler, times(1)).addChild(graphInstance.parentNode, graphInstance.containerNode); verify(canvasHandler, times(1)).addChild(graphInstance.containerNode, graphInstance.startNode); verify(canvasHandler, times(1)).addChild(graphInstance.containerNode, graphInstance.intermNode); verify(canvasHandler, times(1)).addChild(graphInstance.containerNode, graphInstance.endNode); verify(canvasHandler, times(1)).applyElementMutation(graphInstance.containerNode, MutationContext.STATIC); verify(edge1ShapeView, times(1)).moveToTop(); verify(edge2ShapeView, times(1)).moveToTop(); }
@Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Optional<Node> parentOptional = getParent(); final Optional<Node> dockParentOptional = getDockParent(candidate); final List<Node> dockedNodes = getDockedNodes(candidate); final List<Node> childNodes = getChildNodes(candidate); if (dockParentOptional.isPresent()) { context.undock(dockParentOptional.get(), candidate); } else { parentOptional.ifPresent(parent -> context.removeChild(parent, candidate)); } dockedNodes.stream().forEach(node -> context.undock(candidate, node)); childNodes.stream().forEach(node -> context.removeChild(candidate, node)); context.deregister(candidate); context.register(shapeSetId, candidate); dockedNodes.stream().forEach(node -> context.dock(candidate, node)); childNodes.stream().forEach(node -> context.addChild(candidate, node)); if (dockParentOptional.isPresent()) { context.dock(dockParentOptional.get(), candidate); } else { parentOptional.ifPresent(parent -> context.addChild(parent, candidate)); } updateConnectionEdges(context, candidate); context.applyElementMutation(candidate, MutationContext.STATIC); return buildResult(); }
MorphCanvasNodeCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Optional<Node> parentOptional = getParent(); final Optional<Node> dockParentOptional = getDockParent(candidate); final List<Node> dockedNodes = getDockedNodes(candidate); final List<Node> childNodes = getChildNodes(candidate); if (dockParentOptional.isPresent()) { context.undock(dockParentOptional.get(), candidate); } else { parentOptional.ifPresent(parent -> context.removeChild(parent, candidate)); } dockedNodes.stream().forEach(node -> context.undock(candidate, node)); childNodes.stream().forEach(node -> context.removeChild(candidate, node)); context.deregister(candidate); context.register(shapeSetId, candidate); dockedNodes.stream().forEach(node -> context.dock(candidate, node)); childNodes.stream().forEach(node -> context.addChild(candidate, node)); if (dockParentOptional.isPresent()) { context.dock(dockParentOptional.get(), candidate); } else { parentOptional.ifPresent(parent -> context.addChild(parent, candidate)); } updateConnectionEdges(context, candidate); context.applyElementMutation(candidate, MutationContext.STATIC); return buildResult(); } }
MorphCanvasNodeCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Optional<Node> parentOptional = getParent(); final Optional<Node> dockParentOptional = getDockParent(candidate); final List<Node> dockedNodes = getDockedNodes(candidate); final List<Node> childNodes = getChildNodes(candidate); if (dockParentOptional.isPresent()) { context.undock(dockParentOptional.get(), candidate); } else { parentOptional.ifPresent(parent -> context.removeChild(parent, candidate)); } dockedNodes.stream().forEach(node -> context.undock(candidate, node)); childNodes.stream().forEach(node -> context.removeChild(candidate, node)); context.deregister(candidate); context.register(shapeSetId, candidate); dockedNodes.stream().forEach(node -> context.dock(candidate, node)); childNodes.stream().forEach(node -> context.addChild(candidate, node)); if (dockParentOptional.isPresent()) { context.dock(dockParentOptional.get(), candidate); } else { parentOptional.ifPresent(parent -> context.addChild(parent, candidate)); } updateConnectionEdges(context, candidate); context.applyElementMutation(candidate, MutationContext.STATIC); return buildResult(); } MorphCanvasNodeCommand(final Node<? extends Definition<?>, Edge> candidate,
                                  final String shapeSetId); }
MorphCanvasNodeCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Optional<Node> parentOptional = getParent(); final Optional<Node> dockParentOptional = getDockParent(candidate); final List<Node> dockedNodes = getDockedNodes(candidate); final List<Node> childNodes = getChildNodes(candidate); if (dockParentOptional.isPresent()) { context.undock(dockParentOptional.get(), candidate); } else { parentOptional.ifPresent(parent -> context.removeChild(parent, candidate)); } dockedNodes.stream().forEach(node -> context.undock(candidate, node)); childNodes.stream().forEach(node -> context.removeChild(candidate, node)); context.deregister(candidate); context.register(shapeSetId, candidate); dockedNodes.stream().forEach(node -> context.dock(candidate, node)); childNodes.stream().forEach(node -> context.addChild(candidate, node)); if (dockParentOptional.isPresent()) { context.dock(dockParentOptional.get(), candidate); } else { parentOptional.ifPresent(parent -> context.addChild(parent, candidate)); } updateConnectionEdges(context, candidate); context.applyElementMutation(candidate, MutationContext.STATIC); return buildResult(); } MorphCanvasNodeCommand(final Node<? extends Definition<?>, Edge> candidate,
                                  final String shapeSetId); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); @Override String toString(); }
MorphCanvasNodeCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Optional<Node> parentOptional = getParent(); final Optional<Node> dockParentOptional = getDockParent(candidate); final List<Node> dockedNodes = getDockedNodes(candidate); final List<Node> childNodes = getChildNodes(candidate); if (dockParentOptional.isPresent()) { context.undock(dockParentOptional.get(), candidate); } else { parentOptional.ifPresent(parent -> context.removeChild(parent, candidate)); } dockedNodes.stream().forEach(node -> context.undock(candidate, node)); childNodes.stream().forEach(node -> context.removeChild(candidate, node)); context.deregister(candidate); context.register(shapeSetId, candidate); dockedNodes.stream().forEach(node -> context.dock(candidate, node)); childNodes.stream().forEach(node -> context.addChild(candidate, node)); if (dockParentOptional.isPresent()) { context.dock(dockParentOptional.get(), candidate); } else { parentOptional.ifPresent(parent -> context.addChild(parent, candidate)); } updateConnectionEdges(context, candidate); context.applyElementMutation(candidate, MutationContext.STATIC); return buildResult(); } MorphCanvasNodeCommand(final Node<? extends Definition<?>, Edge> candidate,
                                  final String shapeSetId); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); @Override String toString();  }