@Test public void testRegisterAndSetBounds() { tested.init(canvasHandler); assertFalse(tested.isRegistered(element)); tested.register(element); assertTrue(tested.isRegistered(element)); verify(shapeView, times(1)).setDragEnabled(eq(true)); verify(shapeEventHandler, times(1)).supports(eq(ViewEventType.MOUSE_ENTER)); verify(shapeEventHandler, times(1)).addHandler(eq(ViewEventType.MOUSE_ENTER), any(MouseEnterHandler.class)); verify(shapeEventHandler, times(1)).supports(eq(ViewEventType.MOUSE_EXIT)); verify(shapeEventHandler, times(1)).addHandler(eq(ViewEventType.MOUSE_EXIT), any(MouseEnterHandler.class)); ArgumentCaptor<DragHandler> dragHandlerArgumentCaptor = forClass(DragHandler.class); verify(shapeEventHandler).addHandler(eq(ViewEventType.DRAG), dragHandlerArgumentCaptor.capture()); dragHandlerArgumentCaptor.getValue().start(mock(DragEvent.class)); dragHandlerArgumentCaptor.getValue().end(mock(DragEvent.class)); ArgumentCaptor<CanvasSelectionEvent> canvasSelectionEventArgumentCaptor = forClass(CanvasSelectionEvent.class); verify(canvasSelectionEvent).fire(canvasSelectionEventArgumentCaptor.capture()); assertTrue(canvasSelectionEventArgumentCaptor.getValue().getIdentifiers().contains(element.getUUID())); }
@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);  }