@Test @SuppressWarnings("unchecked") public void testLocationAcceptor() { tested.init(canvasHandler); tested.register(element); ArgumentCaptor<ILocationAcceptor> locationAcceptorArgumentCaptor = ArgumentCaptor.forClass(ILocationAcceptor.class); verify(wiresManager, times(1)).setLocationAcceptor(locationAcceptorArgumentCaptor.capture()); final ILocationAcceptor locationAcceptor = locationAcceptorArgumentCaptor.getValue(); final WiresShapeView wiresContainer = mock(WiresShapeView.class); when(wiresContainer.getUUID()).thenReturn(ELEMENT_UUID); final com.ait.lienzo.client.core.types.Point2D point = new com.ait.lienzo.client.core.types.Point2D(40d, 50d); locationAcceptor.accept(new WiresContainer[]{wiresContainer}, new com.ait.lienzo.client.core.types.Point2D[]{point}); ArgumentCaptor<CanvasCommand> commandArgumentCaptor = forClass(CanvasCommand.class); verify(commandManager, times(1)).execute(eq(canvasHandler), commandArgumentCaptor.capture()); final CompositeCommand command = (CompositeCommand) commandArgumentCaptor.getValue(); UpdateElementPositionCommand updateElementPositionCommand = (UpdateElementPositionCommand) command.getCommands().get(0); assertEquals(element, updateElementPositionCommand.getElement()); assertEquals(new Point2D(40d, 50d), updateElementPositionCommand.getLocation()); }
@Override @SuppressWarnings("unchecked") public void register(final Element element) { if (null != element.asNode() && checkNotRegistered(element)) { final AbstractCanvas<?> canvas = canvasHandler.getAbstractCanvas(); final Shape<?> shape = canvas.getShape(element.getUUID()); final ShapeView shapeView = shape.getShapeView(); shapeView.setDragEnabled(true); ensureDragConstraints(canvas, shapeView); if (shape.getShapeView() instanceof HasEventHandlers) { final HasEventHandlers hasEventHandlers = (HasEventHandlers) shapeView; if (supportsMouseEnter(hasEventHandlers) && supportsMouseExit(hasEventHandlers)) { final MouseEnterHandler overHandler = new MouseEnterHandler() { @Override public void handle(MouseEnterEvent event) { canvasHandler.getAbstractCanvas().getView().setCursor(AbstractCanvas.Cursors.MOVE); } }; hasEventHandlers.addHandler(ViewEventType.MOUSE_ENTER, overHandler); registerHandler(shape.getUUID(), overHandler); final MouseExitHandler outHandler = new MouseExitHandler() { @Override public void handle(MouseExitEvent event) { canvasHandler.getAbstractCanvas().getView().setCursor(AbstractCanvas.Cursors.DEFAULT); } }; hasEventHandlers.addHandler(ViewEventType.MOUSE_EXIT, outHandler); registerHandler(shape.getUUID(), outHandler); final DragHandler dragHandler = new DragHandler() { @Override public void start(DragEvent event) { } @Override public void end(DragEvent event) { selectionEvent.fire(new CanvasSelectionEvent(canvasHandler, shape.getUUID())); } @Override public void handle(DragEvent event) { } }; hasEventHandlers.addHandler(ViewEventType.DRAG, dragHandler); registerHandler(shape.getUUID(), dragHandler); } } } }
LocationControlImpl extends AbstractCanvasHandlerRegistrationControl<AbstractCanvasHandler> implements LocationControl<AbstractCanvasHandler, Element>,
                   CanvasControl.SessionAware<EditorSession> { @Override @SuppressWarnings("unchecked") public void register(final Element element) { if (null != element.asNode() && checkNotRegistered(element)) { final AbstractCanvas<?> canvas = canvasHandler.getAbstractCanvas(); final Shape<?> shape = canvas.getShape(element.getUUID()); final ShapeView shapeView = shape.getShapeView(); shapeView.setDragEnabled(true); ensureDragConstraints(canvas, shapeView); if (shape.getShapeView() instanceof HasEventHandlers) { final HasEventHandlers hasEventHandlers = (HasEventHandlers) shapeView; if (supportsMouseEnter(hasEventHandlers) && supportsMouseExit(hasEventHandlers)) { final MouseEnterHandler overHandler = new MouseEnterHandler() { @Override public void handle(MouseEnterEvent event) { canvasHandler.getAbstractCanvas().getView().setCursor(AbstractCanvas.Cursors.MOVE); } }; hasEventHandlers.addHandler(ViewEventType.MOUSE_ENTER, overHandler); registerHandler(shape.getUUID(), overHandler); final MouseExitHandler outHandler = new MouseExitHandler() { @Override public void handle(MouseExitEvent event) { canvasHandler.getAbstractCanvas().getView().setCursor(AbstractCanvas.Cursors.DEFAULT); } }; hasEventHandlers.addHandler(ViewEventType.MOUSE_EXIT, outHandler); registerHandler(shape.getUUID(), outHandler); final DragHandler dragHandler = new DragHandler() { @Override public void start(DragEvent event) { } @Override public void end(DragEvent event) { selectionEvent.fire(new CanvasSelectionEvent(canvasHandler, shape.getUUID())); } @Override public void handle(DragEvent event) { } }; hasEventHandlers.addHandler(ViewEventType.DRAG, dragHandler); registerHandler(shape.getUUID(), dragHandler); } } } } }
LocationControlImpl extends AbstractCanvasHandlerRegistrationControl<AbstractCanvasHandler> implements LocationControl<AbstractCanvasHandler, Element>,
                   CanvasControl.SessionAware<EditorSession> { @Override @SuppressWarnings("unchecked") public void register(final Element element) { if (null != element.asNode() && checkNotRegistered(element)) { final AbstractCanvas<?> canvas = canvasHandler.getAbstractCanvas(); final Shape<?> shape = canvas.getShape(element.getUUID()); final ShapeView shapeView = shape.getShapeView(); shapeView.setDragEnabled(true); ensureDragConstraints(canvas, shapeView); if (shape.getShapeView() instanceof HasEventHandlers) { final HasEventHandlers hasEventHandlers = (HasEventHandlers) shapeView; if (supportsMouseEnter(hasEventHandlers) && supportsMouseExit(hasEventHandlers)) { final MouseEnterHandler overHandler = new MouseEnterHandler() { @Override public void handle(MouseEnterEvent event) { canvasHandler.getAbstractCanvas().getView().setCursor(AbstractCanvas.Cursors.MOVE); } }; hasEventHandlers.addHandler(ViewEventType.MOUSE_ENTER, overHandler); registerHandler(shape.getUUID(), overHandler); final MouseExitHandler outHandler = new MouseExitHandler() { @Override public void handle(MouseExitEvent event) { canvasHandler.getAbstractCanvas().getView().setCursor(AbstractCanvas.Cursors.DEFAULT); } }; hasEventHandlers.addHandler(ViewEventType.MOUSE_EXIT, outHandler); registerHandler(shape.getUUID(), outHandler); final DragHandler dragHandler = new DragHandler() { @Override public void start(DragEvent event) { } @Override public void end(DragEvent event) { selectionEvent.fire(new CanvasSelectionEvent(canvasHandler, shape.getUUID())); } @Override public void handle(DragEvent event) { } }; hasEventHandlers.addHandler(ViewEventType.DRAG, dragHandler); registerHandler(shape.getUUID(), dragHandler); } } } } protected  LocationControlImpl(); @Inject  LocationControlImpl(final CanvasCommandFactory<AbstractCanvasHandler> canvasCommandFactory,
                               final Event<ShapeLocationsChangedEvent> shapeLocationsChangedEvent,
                               final Event<CanvasSelectionEvent> selectionEvent); }
LocationControlImpl extends AbstractCanvasHandlerRegistrationControl<AbstractCanvasHandler> implements LocationControl<AbstractCanvasHandler, Element>,
                   CanvasControl.SessionAware<EditorSession> { @Override @SuppressWarnings("unchecked") public void register(final Element element) { if (null != element.asNode() && checkNotRegistered(element)) { final AbstractCanvas<?> canvas = canvasHandler.getAbstractCanvas(); final Shape<?> shape = canvas.getShape(element.getUUID()); final ShapeView shapeView = shape.getShapeView(); shapeView.setDragEnabled(true); ensureDragConstraints(canvas, shapeView); if (shape.getShapeView() instanceof HasEventHandlers) { final HasEventHandlers hasEventHandlers = (HasEventHandlers) shapeView; if (supportsMouseEnter(hasEventHandlers) && supportsMouseExit(hasEventHandlers)) { final MouseEnterHandler overHandler = new MouseEnterHandler() { @Override public void handle(MouseEnterEvent event) { canvasHandler.getAbstractCanvas().getView().setCursor(AbstractCanvas.Cursors.MOVE); } }; hasEventHandlers.addHandler(ViewEventType.MOUSE_ENTER, overHandler); registerHandler(shape.getUUID(), overHandler); final MouseExitHandler outHandler = new MouseExitHandler() { @Override public void handle(MouseExitEvent event) { canvasHandler.getAbstractCanvas().getView().setCursor(AbstractCanvas.Cursors.DEFAULT); } }; hasEventHandlers.addHandler(ViewEventType.MOUSE_EXIT, outHandler); registerHandler(shape.getUUID(), outHandler); final DragHandler dragHandler = new DragHandler() { @Override public void start(DragEvent event) { } @Override public void end(DragEvent event) { selectionEvent.fire(new CanvasSelectionEvent(canvasHandler, shape.getUUID())); } @Override public void handle(DragEvent event) { } }; hasEventHandlers.addHandler(ViewEventType.DRAG, dragHandler); registerHandler(shape.getUUID(), dragHandler); } } } } protected  LocationControlImpl(); @Inject  LocationControlImpl(final CanvasCommandFactory<AbstractCanvasHandler> canvasCommandFactory,
                               final Event<ShapeLocationsChangedEvent> shapeLocationsChangedEvent,
                               final Event<CanvasSelectionEvent> selectionEvent); Collection<String> getSelectedIDs(); @Override void bind(final EditorSession session); void handleArrowKeys(final Key... keys); @Override void setCommandManagerProvider(final CommandManagerProvider<AbstractCanvasHandler> provider); @Override @SuppressWarnings("unchecked") void register(final Element element); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> move(final Element[] elements,
                                               final Point2D[] locations); }
LocationControlImpl extends AbstractCanvasHandlerRegistrationControl<AbstractCanvasHandler> implements LocationControl<AbstractCanvasHandler, Element>,
                   CanvasControl.SessionAware<EditorSession> { @Override @SuppressWarnings("unchecked") public void register(final Element element) { if (null != element.asNode() && checkNotRegistered(element)) { final AbstractCanvas<?> canvas = canvasHandler.getAbstractCanvas(); final Shape<?> shape = canvas.getShape(element.getUUID()); final ShapeView shapeView = shape.getShapeView(); shapeView.setDragEnabled(true); ensureDragConstraints(canvas, shapeView); if (shape.getShapeView() instanceof HasEventHandlers) { final HasEventHandlers hasEventHandlers = (HasEventHandlers) shapeView; if (supportsMouseEnter(hasEventHandlers) && supportsMouseExit(hasEventHandlers)) { final MouseEnterHandler overHandler = new MouseEnterHandler() { @Override public void handle(MouseEnterEvent event) { canvasHandler.getAbstractCanvas().getView().setCursor(AbstractCanvas.Cursors.MOVE); } }; hasEventHandlers.addHandler(ViewEventType.MOUSE_ENTER, overHandler); registerHandler(shape.getUUID(), overHandler); final MouseExitHandler outHandler = new MouseExitHandler() { @Override public void handle(MouseExitEvent event) { canvasHandler.getAbstractCanvas().getView().setCursor(AbstractCanvas.Cursors.DEFAULT); } }; hasEventHandlers.addHandler(ViewEventType.MOUSE_EXIT, outHandler); registerHandler(shape.getUUID(), outHandler); final DragHandler dragHandler = new DragHandler() { @Override public void start(DragEvent event) { } @Override public void end(DragEvent event) { selectionEvent.fire(new CanvasSelectionEvent(canvasHandler, shape.getUUID())); } @Override public void handle(DragEvent event) { } }; hasEventHandlers.addHandler(ViewEventType.DRAG, dragHandler); registerHandler(shape.getUUID(), dragHandler); } } } } protected  LocationControlImpl(); @Inject  LocationControlImpl(final CanvasCommandFactory<AbstractCanvasHandler> canvasCommandFactory,
                               final Event<ShapeLocationsChangedEvent> shapeLocationsChangedEvent,
                               final Event<CanvasSelectionEvent> selectionEvent); Collection<String> getSelectedIDs(); @Override void bind(final EditorSession session); void handleArrowKeys(final Key... keys); @Override void setCommandManagerProvider(final CommandManagerProvider<AbstractCanvasHandler> provider); @Override @SuppressWarnings("unchecked") void register(final Element element); @Override @SuppressWarnings("unchecked") CommandResult<CanvasViolation> move(final Element[] elements,
                                               final Point2D[] locations);  }