CompassDropController implements DropController { @Override public void onDrop(DragContext context) { Position p = compass.getDropPosition(); if (p == CompassPosition.NONE) { return; } compass.onDrop(context); final WorkbenchDragContext workbenchContext = dndManager.getWorkbenchContext(); final Menus menus = workbenchContext.getMenus(); final PanelDefinition sourcePanel = workbenchContext.getSourcePanel(); final PanelDefinition dropPanel = dropTarget.getPresenter().getDefinition(); if (sourcePanel.equals(dropPanel)) { if (sourcePanel.getParts() != null && sourcePanel.getParts().size() == 1) { return; } if (p == CompassPosition.SELF) { return; } } final PlaceRequest place = workbenchContext.getPlace(); firePartDroppedEvent(place); final Integer height = null; final Integer width = null; final Integer minHeight = workbenchContext.getMinHeight(); final Integer minWidth = workbenchContext.getMinWidth(); final PanelDefinition targetPanel = panelManager.addWorkbenchPanel(dropPanel, p, height, width, minHeight, minWidth); final UIPart uiPart = workbenchContext.getUiPart(); final PartDefinition sourcePart = workbenchContext.getSourcePart(); panelManager.addWorkbenchPart(place, sourcePart, targetPanel, menus, uiPart, workbenchContext.getContextId(), null, null); }  void setup(final WorkbenchPanelView<?> view); @Override //When entering a DecoratedWorkbenchPanel show the Compass void onEnter(DragContext context); @Override //Hide the DecoratedWorkbenchPanel's Compass void onLeave(DragContext context); @Override void onMove(DragContext context); @Override void onDrop(DragContext context); @Override Widget getDropTarget(); @Override void onPreviewDrop(DragContext context);  }
@Test public void onDropDoesNothing() { compassDropController.mockDropTargetPositionNone(); DragContext dragContext = mock(DragContext.class); compassDropController.onDrop(dragContext); verify(compassDropController.compass, never()).onDrop(dragContext); }
@Test public void onDropNoEffect() { compassDropController.mockDropTargetPosition(CompassPosition.SELF); compassDropController.mockSamePositionDrag(view); DragContext dragContext = mock(DragContext.class); compassDropController.onDrop(dragContext); verify(panelManager, never()).addWorkbenchPanel(any(PanelDefinition.class), any(Position.class), any(Integer.class), any(Integer.class), any(Integer.class), any(Integer.class)); }
@Test public void onDropHappens() { compassDropController.mockDropTargetPosition(CompassPosition.WEST); compassDropController.mockSamePositionDrag(view); DragContext dragContext = mock(DragContext.class); compassDropController.onDrop(dragContext); verify(panelManager).addWorkbenchPanel(any(PanelDefinition.class), any(Position.class), any(Integer.class), any(Integer.class), any(Integer.class), any(Integer.class)); verify(panelManager).addWorkbenchPart(any(PlaceRequest.class), any(PartDefinition.class), any(PanelDefinition.class), any(Menus.class), any(UIPart.class), any(String.class), isNull(Integer.class), isNull(Integer.class)); }