1 11 package org.eclipse.debug.internal.ui.launchConfigurations; 12 13 import java.util.HashSet ; 14 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.core.runtime.Status; 18 import org.eclipse.debug.core.ILaunchConfiguration; 19 import org.eclipse.debug.core.ILaunchDelegate; 20 import org.eclipse.debug.core.IStatusHandler; 21 import org.eclipse.debug.internal.ui.DebugUIPlugin; 22 import org.eclipse.jface.dialogs.IDialogConstants; 23 import org.eclipse.swt.widgets.Shell; 24 25 34 public class DuplicateLaunchDelegatesStatusHandler implements IStatusHandler { 35 36 39 public Object handleStatus(IStatus status, Object source) throws CoreException { 40 if(source instanceof Object []) { 41 Object [] infos = (Object []) source; 42 if(infos.length == 2) { 43 ILaunchConfiguration config = (ILaunchConfiguration) infos[0]; 44 String mode = (String ) infos[1]; 45 Shell shell = DebugUIPlugin.getShell(); 46 HashSet modes = new HashSet (); 47 modes.add(mode); 48 modes.addAll(config.getModes()); 49 SelectLaunchersDialog sldd = new SelectLaunchersDialog(shell, 50 config.getType().getDelegates(modes), 51 config.getWorkingCopy(), 52 mode); 53 if(sldd.open() != IDialogConstants.OK_ID) { 54 return Status.CANCEL_STATUS; 55 } 56 ILaunchDelegate delegate = config.getPreferredDelegate(modes); 58 if(delegate == null) { 59 delegate = config.getType().getPreferredDelegate(modes); 60 } 61 return (delegate == null ? Status.CANCEL_STATUS : Status.OK_STATUS); 62 } 63 } 64 return Status.CANCEL_STATUS; 65 } 66 } 67 | Popular Tags |