Source:
protected Command getCustomCommand(Request request) { final Map<DropStrategy, List<Command>> matchingStrategies = findStrategies(request); if (matchingStrategies.size() == 1) { DropStrategy ds = matchingStrategies.keySet().iterator().next(); if(ds instanceof TransactionalDropStrategy){ return matchingStrategies.get(ds).get(0); } else if(ds instanceof TransactionalCommandsDropStrategy){ return null; } else if(ds instanceof DefaultDropStrategy){ return matchingStrategies.get(ds).get(0); } else{ Activator.log.info("xds: "+ds); } } if (matchingStrategies.size() > 1) { boolean useDefault = true; if (request.getExtendedData().containsKey(EVENT_DETAIL)) { int eventDetailValue = (Integer) request.getExtendedData().get(EVENT_DETAIL); if ((eventDetailValue & DND.DROP_COPY) != 0) { useDefault = false; } } if (useDefault) { DropStrategy defaultStrategy = DropStrategyManager.instance.getDefaultDropStrategy(matchingStrategies.keySet()); if (defaultStrategy != null ) { if(defaultStrategy instanceof TransactionalCommandsDropStrategy ){ return null; } else if(defaultStrategy instanceof TransactionalDropStrategy){ return matchingStrategies.get(defaultStrategy).get(0); } } } Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); DefaultActionHandler handler = new DefaultActionHandler() { public void defaultActionSelected(Command defaultCommand) { DropStrategy defaultStrategy = findStrategy(matchingStrategies, defaultCommand); if (defaultStrategy != null) { DropStrategyManager.instance.setDefaultDropStrategy(matchingStrategies.keySet(), defaultStrategy); } } public String getLabel() { return "Change the default strategy"; } }; ArrayList<Command> proposalCommands = new ArrayList<Command>(); for(List<Command> cs: matchingStrategies.values()){ for(Command c : cs){ if(c!=null){ proposalCommands.add(c); } } } SelectAndExecuteCommand command = new SelectAndExecuteCommand("Select drop", shell, new LinkedList<Command>(proposalCommands), handler); return new ICommandProxy(command); } return null; }

Target:
protected Command getCustomCommand(Request request) { final Map<DropStrategy, List<Command>> matchingStrategies = findStrategies(request); if (matchingStrategies.size() == 1) { DropStrategy ds = matchingStrategies.keySet().iterator().next(); if(ds instanceof TransactionalDropStrategy){ return matchingStrategies.get(ds).get(0); } else if(ds instanceof TransactionalCommandsDropStrategy){ return null; } else if(ds instanceof DefaultDropStrategy){ return matchingStrategies.get(ds).get(0); } else{ Activator.log.warn("Drop strategy not taken into account: "+ds); return null; } } if (matchingStrategies.size() > 1) { boolean useDefault = true; if (request.getExtendedData().containsKey(EVENT_DETAIL)) { int eventDetailValue = (Integer) request.getExtendedData().get(EVENT_DETAIL); if ((eventDetailValue & DND.DROP_COPY) != 0) { useDefault = false; } } if (useDefault) { DropStrategy defaultStrategy = DropStrategyManager.instance.getDefaultDropStrategy(matchingStrategies.keySet()); if (defaultStrategy != null ) { if(defaultStrategy instanceof TransactionalCommandsDropStrategy ){ Activator.log.warn("Default strategies of type TransactionalCommandsDropStrategy are not taken into account"); return null; } else if(defaultStrategy instanceof TransactionalDropStrategy){ return matchingStrategies.get(defaultStrategy).get(0); } } } Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); DefaultActionHandler handler = new DefaultActionHandler() { public void defaultActionSelected(Command defaultCommand) { DropStrategy defaultStrategy = findStrategy(matchingStrategies, defaultCommand); if (defaultStrategy != null) { DropStrategyManager.instance.setDefaultDropStrategy(matchingStrategies.keySet(), defaultStrategy); } } public String getLabel() { return "Change the default strategy"; } }; ArrayList<Command> proposalCommands = new ArrayList<Command>(); for(List<Command> cs: matchingStrategies.values()){ for(Command c : cs){ if(c!=null){ proposalCommands.add(c); } } } SelectAndExecuteCommand command = new SelectAndExecuteCommand("Select drop", shell, new LinkedList<Command>(proposalCommands), handler); return new ICommandProxy(command); } return null; }