@Test @SuppressWarnings("unchecked") public void testExecuteAndUpdateMagnetLocations() { final MagnetConnection sourceConnection = new MagnetConnection.Builder() .magnet(0) .build(); final MagnetConnection targetConnection = new MagnetConnection.Builder() .magnet(0) .build(); when(edgeContent.getSourceConnection()).thenReturn(Optional.of(sourceConnection)); when(edgeContent.getTargetConnection()).thenReturn(Optional.of(targetConnection)); final CommandResult<CanvasViolation> result = tested.execute(canvasHandler); assertNotEquals(CommandResult.Type.ERROR, result.getType()); verify(edgeShape, times(1)).applyConnections(eq(edge), eq(sourceShapeView), eq(targetShapeView), any(MutationContext.class)); verify(canvasHandler, times(1)).notifyCanvasElementUpdated(eq(source)); verify(canvasHandler, times(1)).notifyCanvasElementUpdated(eq(target)); assertEquals(5d, sourceConnection.getLocation().getX(), 0d); assertEquals(5d, sourceConnection.getLocation().getY(), 0d); assertEquals(10d, targetConnection.getLocation().getX(), 0d); assertEquals(10d, targetConnection.getLocation().getY(), 0d); }
@Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Node source = edge.getSourceNode(); final Node target = edge.getTargetNode(); ShapeUtils.applyConnections(edge, context, MutationContext.STATIC); if (null != source) { context.notifyCanvasElementUpdated(source); } if (null != target) { context.notifyCanvasElementUpdated(target); } return buildResult(); }
SetCanvasConnectionCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Node source = edge.getSourceNode(); final Node target = edge.getTargetNode(); ShapeUtils.applyConnections(edge, context, MutationContext.STATIC); if (null != source) { context.notifyCanvasElementUpdated(source); } if (null != target) { context.notifyCanvasElementUpdated(target); } return buildResult(); } }
SetCanvasConnectionCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Node source = edge.getSourceNode(); final Node target = edge.getTargetNode(); ShapeUtils.applyConnections(edge, context, MutationContext.STATIC); if (null != source) { context.notifyCanvasElementUpdated(source); } if (null != target) { context.notifyCanvasElementUpdated(target); } return buildResult(); } SetCanvasConnectionCommand(final Edge<? extends ViewConnector<?>, Node> edge); }
SetCanvasConnectionCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Node source = edge.getSourceNode(); final Node target = edge.getTargetNode(); ShapeUtils.applyConnections(edge, context, MutationContext.STATIC); if (null != source) { context.notifyCanvasElementUpdated(source); } if (null != target) { context.notifyCanvasElementUpdated(target); } return buildResult(); } SetCanvasConnectionCommand(final Edge<? extends ViewConnector<?>, Node> edge); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); Edge<? extends View<?>, Node> getEdge(); @Override String toString(); }
SetCanvasConnectionCommand extends AbstractCanvasCommand { @Override @SuppressWarnings("unchecked") public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) { final Node source = edge.getSourceNode(); final Node target = edge.getTargetNode(); ShapeUtils.applyConnections(edge, context, MutationContext.STATIC); if (null != source) { context.notifyCanvasElementUpdated(source); } if (null != target) { context.notifyCanvasElementUpdated(target); } return buildResult(); } SetCanvasConnectionCommand(final Edge<? extends ViewConnector<?>, Node> edge); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context); Edge<? extends View<?>, Node> getEdge(); @Override String toString();  }