1 11 package org.eclipse.jdt.internal.launching; 12 13 14 import com.ibm.icu.text.MessageFormat; 15 import java.util.Map ; 16 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IProgressMonitor; 19 import org.eclipse.core.runtime.NullProgressMonitor; 20 import org.eclipse.debug.core.ILaunch; 21 import org.eclipse.debug.core.ILaunchConfiguration; 22 import org.eclipse.debug.core.model.IDebugTarget; 23 import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate; 24 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 25 import org.eclipse.jdt.launching.IVMConnector; 26 import org.eclipse.jdt.launching.JavaRuntime; 27 28 31 public class JavaRemoteApplicationLaunchConfigurationDelegate extends AbstractJavaLaunchConfigurationDelegate { 32 33 36 public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { 37 38 if (monitor == null) { 39 monitor = new NullProgressMonitor(); 40 } 41 42 monitor.beginTask(MessageFormat.format(LaunchingMessages.JavaRemoteApplicationLaunchConfigurationDelegate_Attaching_to__0_____1, new String []{configuration.getName()}), 3); 43 if (monitor.isCanceled()) { 45 return; 46 } 47 48 monitor.subTask(LaunchingMessages.JavaRemoteApplicationLaunchConfigurationDelegate_Verifying_launch_attributes____1); 49 50 String connectorId = getVMConnectorId(configuration); 51 IVMConnector connector = null; 52 if (connectorId == null) { 53 connector = JavaRuntime.getDefaultVMConnector(); 54 } else { 55 connector = JavaRuntime.getVMConnector(connectorId); 56 } 57 if (connector == null) { 58 abort(LaunchingMessages.JavaRemoteApplicationLaunchConfigurationDelegate_Connector_not_specified_2, null, IJavaLaunchConfigurationConstants.ERR_CONNECTOR_NOT_AVAILABLE); 59 } 60 61 Map argMap = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, (Map )null); 62 63 int connectTimeout = JavaRuntime.getPreferences().getInt(JavaRuntime.PREF_CONNECT_TIMEOUT); 64 argMap.put("timeout", ""+connectTimeout); 66 if (monitor.isCanceled()) { 68 return; 69 } 70 71 monitor.worked(1); 72 73 monitor.subTask(LaunchingMessages.JavaRemoteApplicationLaunchConfigurationDelegate_Creating_source_locator____2); 74 setDefaultSourceLocator(launch, configuration); 76 monitor.worked(1); 77 78 connector.connect(argMap, monitor, launch); 80 81 if (monitor.isCanceled()) { 83 IDebugTarget[] debugTargets = launch.getDebugTargets(); 84 for (int i = 0; i < debugTargets.length; i++) { 85 IDebugTarget target = debugTargets[i]; 86 if (target.canDisconnect()) { 87 target.disconnect(); 88 } 89 } 90 return; 91 } 92 93 monitor.done(); 94 } 95 96 } 97 | Popular Tags |