fixed bug #11211. also fixed issue where apply button was active after creating new launch configs from the launch dialog (rather than the wizard).
authorwpaul
Mon, 21 Jun 2010 18:45:14 -0500
changeset 1513 8a8e855bd44e
parent 1512 8731dc95fb5a
child 1514 2f6eab894fc5
child 1523 2786ba7415f3
fixed bug #11211. also fixed issue where apply button was active after creating new launch configs from the launch dialog (rather than the wizard).
debuggercdi/com.nokia.cdt.debug.cw.symbian/src/com/nokia/cdt/debug/cw/symbian/SettingsData.java
--- a/debuggercdi/com.nokia.cdt.debug.cw.symbian/src/com/nokia/cdt/debug/cw/symbian/SettingsData.java	Mon Jun 21 17:49:53 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.cw.symbian/src/com/nokia/cdt/debug/cw/symbian/SettingsData.java	Mon Jun 21 18:45:14 2010 -0500
@@ -64,10 +64,12 @@
 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
 import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
 import com.nokia.carbide.remoteconnections.interfaces.IConnection;
+import com.nokia.carbide.remoteconnections.internal.registry.Registry;
 import com.nokia.cpp.internal.api.utils.core.PathUtils;
 
 import cwdbg.PreferenceConstants;
 
+@SuppressWarnings("restriction")
 public class SettingsData {
 
 	// NOTE: Many of these constants are mirrored in 
@@ -251,7 +253,7 @@
 			if (cpi != null) {
 				ICarbideBuildConfiguration buildConfig = cpi.getDefaultConfiguration();
 				String configName = projectName + " " + buildConfig.getDisplayString(); //$NON-NLS-1$
-				configuration.rename(DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configName));
+				setLaunchConfigurationName(configuration, configName);
 
 				// make sure the selected build configuration of the current project
 				// is an emulator build, otherwise warn them that we can't set default values.
@@ -345,6 +347,7 @@
 		//
 		configuration.setAttribute(PreferenceConstants.J_PN_RemoteProcessToLaunch, ""); //$NON-NLS-1$
 		configuration.setAttribute(PreferenceConstants.J_PN_ProgramArguments, ""); //$NON-NLS-1$
+		configuration.setAttribute(RemoteConnectionsTRKHelper.CONNECTION_ATTRIBUTE, Registry.CURRENT_CONNECTION_ID);
 
 	    HashSet<String> set = new HashSet<String>();
 	    set.add(ILaunchManager.DEBUG_MODE);
@@ -370,7 +373,7 @@
 			if (cpi != null) {
 				ICarbideBuildConfiguration buildConfig = cpi.getDefaultConfiguration();
 				String configName = projectName + " " + buildConfig.getDisplayString(); //$NON-NLS-1$
-				configuration.rename(DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configName));
+				setLaunchConfigurationName(configuration, configName);
 
 				// make sure the selected build configuration of the current project is not an emulator build
 				// otherwise warn them that we can't set default values.
@@ -405,7 +408,7 @@
 			if (cpi != null) {
 				ICarbideBuildConfiguration buildConfig = cpi.getDefaultConfiguration();
 				String configName = projectName + " " + buildConfig.getDisplayString(); //$NON-NLS-1$
-				configuration.rename(DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configName));
+				setLaunchConfigurationName(configuration, configName);
 
 				// make sure the selected build configuration of the current project is not an emulator build
 				// otherwise warn them that we can't set default values.
@@ -672,14 +675,14 @@
 		configuration.setAttribute(DebuggerCommonData.Host_App_Path, ""); //$NON-NLS-1$
 		configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
 		configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); //$NON-NLS-1$
-		if (project != null)
-		{
+		configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING);
+
+		if (project != null) {
 			configuration.setMappedResources( new IResource[] { project });
 		    ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project);
 			if (cpi != null) {
 				configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, cpi.getDefaultBuildConfigName());
-				}
-			
+			}
 		}
 		
 		// set rom log file defaults.  do this for all launch types since it shouldn't hurt
@@ -898,4 +901,20 @@
 		configuration.setAttribute(PreferenceConstants.J_PN_RemoteProcessToLaunch, PathUtils.convertPathToWindows(path));
 	}
 	
-}
\ No newline at end of file
+	private static void setLaunchConfigurationName(ILaunchConfigurationWorkingCopy config, String proposedName) {
+		String name = proposedName;
+		
+		// the call to generateLaunchConfigurationName below will replace all \'s with _'s
+		// the code below just removes any \ or : at the end of the SDK name, if for example
+		// they gave the SDK a name of "M:" or "M:\".
+		if (name.endsWith("\\]")) { //$NON-NLS-1$
+			name = name.substring(0, name.length() - 2) + "]"; //$NON-NLS-1$
+		}
+
+		if (name.endsWith(":]")) { //$NON-NLS-1$
+			name = name.substring(0, name.length() - 2) + "]"; //$NON-NLS-1$
+		}
+
+		config.rename(DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(name));
+	}
+}