MCTDragDropHandler { public boolean perform() { boolean complete = false; List<DragDropMode> options = new ArrayList<DragDropMode>(); for (DragDropMode mode : modes) { if (mode.canPerform()) { options.add(mode); } } if (options.size() > 0) { Map<String, Object> hints = new HashMap<String, Object>(); hints.put(WindowManagerImpl.OPTION_TYPE, OptionBox.DEFAULT_OPTION); DragDropMode choice = options.size() == 1 ? options.get(0) : PlatformAccess.getPlatform().getWindowManager().showInputDialog( "Add Manifestation - " + dropView.getManifestedComponent().getDisplayName(), createDialogMessage(options), options.toArray(new DragDropMode[options.size()]), options.get(0), hints); if (choice != null) { try { PlatformAccess.getPlatform().getPersistenceProvider().startRelatedOperations(); choice.perform(); complete = true; } finally { PlatformAccess.getPlatform().getPersistenceProvider().completeRelatedOperations(complete); } } else { message = null; } } return complete; } MCTDragDropHandler(Collection<View> draggedViews, View dropView, int index); boolean perform(); Collection<AbstractComponent> getDroppedComponents(); String getMessage(); static final String CUSTOM_POLICY_KEY; static final String MOVE_NAME; static final String COPY_NAME; static final String LINK_NAME; static final String LINK_VERB; }
@Test public void testAllOptions() { MCTDragDropHandler handler = new MCTDragDropHandler(mockSelections, mockTarget, -1); handler.perform(); Mockito.verify(mockWindowManager).<Object>showInputDialog( Mockito.anyString(), Mockito.anyString(), Mockito.argThat(new ArgumentMatcher<Object[]>() { @Override public boolean matches(Object argument) { return ((Object[])argument).length == 3; } }), Mockito.<Object>any(), Mockito.<Map<String,Object>> any()); }