Merge commit
authorEd Swartz <ed.swartz@nokia.com>
Wed, 07 Apr 2010 14:48:51 -0500
changeset 1173 3356621aee34
parent 1172 d1378138ca79 (diff)
parent 1166 4e2ef6f4eab3 (current diff)
child 1174 d7dbe15da669
child 1177 d3e3d03a295a
child 1184 745221c781a3
Merge commit
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideProjectInfo.java	Wed Apr 07 11:58:17 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideProjectInfo.java	Wed Apr 07 14:48:51 2010 -0500
@@ -34,6 +34,7 @@
 import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
 import com.nokia.carbide.cdt.internal.builder.ui.BuilderPreferencePage;
 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
+import com.nokia.cpp.internal.api.utils.core.PathUtils;
 import com.nokia.cpp.internal.api.utils.core.TrackedResource;
 
 
@@ -94,7 +95,7 @@
 				if (storage != null) {
 					String orig = storage.getAttribute(PROJECT_RELATIVE_INFFILE_PROPS_KEY);
 					if (orig != null){
-						projectRelativeBldInfPath = new Path(orig);
+						projectRelativeBldInfPath = PathUtils.createPath(orig);
 					}
 
 					orig = storage.getAttribute(BLD_FROM_INF_PROPS_KEY);
--- a/debuggercdi/com.nokia.cdt.debug.cw.symbian/src/com/nokia/cdt/debug/cw/symbian/SettingsData.java	Wed Apr 07 11:58:17 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.cw.symbian/src/com/nokia/cdt/debug/cw/symbian/SettingsData.java	Wed Apr 07 14:48:51 2010 -0500
@@ -976,6 +976,17 @@
 		return false;
 	}
 	
+	public static boolean isSysTRKConfiguration(ILaunchConfiguration configuration) {
+		try {
+			ILaunchConfigurationType configurationType = configuration.getType();
+			String id = configurationType.getIdentifier();
+			return id.equals(SYS_TRK_LAUNCH_TYPE_ID);
+		} catch (CoreException e) {
+		}
+		
+		return false;
+	}
+	
 	public static boolean isEmulatorConfiguration(ILaunchConfiguration configuration) {
 		try {
 			ILaunchConfigurationType configurationType = configuration.getType();
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AbstractSymbianLaunchShortcut.java	Wed Apr 07 11:58:17 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AbstractSymbianLaunchShortcut.java	Wed Apr 07 14:48:51 2010 -0500
@@ -1,5 +1,6 @@
 package com.nokia.cdt.internal.debug.launch;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.cdt.debug.core.executables.Executable;
@@ -12,20 +13,33 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugModelPresentation;
 import org.eclipse.debug.ui.ILaunchShortcut2;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
 
 import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
 import com.nokia.cdt.debug.common.internal.executables.SymbianSourceFileRemapping;
+import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
 
 public abstract class AbstractSymbianLaunchShortcut implements ILaunchShortcut2 {
 
 	protected abstract void launchProject(IProject project, Executable executable, IPath defaultMMP, String mode);
 
+	/**
+	 * Override to tell whether this existing configuration matches the type of
+	 * one the shortcut would create. The default implementation returns true
+	 * for all configurations.
+	 */
+	protected boolean isSupportedConfiguration(ILaunchConfiguration config) throws CoreException {
+		return true;
+	}
+	
 	public void launch(IEditorPart editor, String mode) {
 		// launch an existing config if one exists
 		ILaunchConfiguration[] configs = getLaunchConfigurations(editor);
@@ -33,7 +47,7 @@
 			// just launch the first one that supports the mode
 			for (ILaunchConfiguration config : configs) {
 				try {
-					if (config.supportsMode(mode)) {
+					if (config.supportsMode(mode) && isSupportedConfiguration(config)) {
 						DebugUITools.launch(configs[0], mode);
 						return;
 					}
@@ -57,17 +71,30 @@
 		// launch an existing config if one exists
 		ILaunchConfiguration[] configs = getLaunchConfigurations(selection);
 		if (configs.length > 0) {
-			// just launch the first one that supports the mode
-			for (ILaunchConfiguration config : configs) {
+			// find all the ones that support the mode and shortcut (#11013)
+			List<ILaunchConfiguration> matches = new ArrayList<ILaunchConfiguration>();
+			for (int i = 0; i < configs.length; i++) {
+				ILaunchConfiguration config = configs[i];
 				try {
-					if (config.supportsMode(mode)) {
-						DebugUITools.launch(configs[0], mode);
-						return;
+					if (config.supportsMode(mode) && isSupportedConfiguration(config)) {
+						matches.add(config);
 					}
 				} catch (CoreException e) {
 					e.printStackTrace();
 				}
 			}
+			// if only one matches, just launch
+			if (matches.size() > 0) {
+				if (matches.size() == 1 || WorkbenchUtils.isJUnitRunning()) {
+					DebugUITools.launch(matches.get(0), mode);
+				} else {
+					// else, ask the user
+					ILaunchConfiguration selected = chooseConfiguration(matches, mode);
+					if (selected != null)
+						DebugUITools.launch(selected, mode);
+				}
+				return;
+			}
 		}
 		
 		IPath defaultMMP = null;
@@ -88,7 +115,7 @@
 				if (file != null)
 				{
 					IPath filePath = file.getLocation();
-					if ("mmp".equalsIgnoreCase(filePath.getFileExtension()))
+					if ("mmp".equalsIgnoreCase(filePath.getFileExtension())) //$NON-NLS-1$
 					{
 						defaultMMP = filePath;
 					}
@@ -111,6 +138,27 @@
 			}
 		}
 	}
+	
+	/**
+	 * Show a selection dialog that allows the user to choose one of the specified
+	 * launch configurations.  Return the chosen config, or <code>null</code> if the
+	 * user cancelled the dialog.
+	 */
+	protected ILaunchConfiguration chooseConfiguration(List<ILaunchConfiguration> configList, String mode) {
+		IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
+		ElementListSelectionDialog dialog = new ElementListSelectionDialog(WorkbenchUtils.getSafeShell(), labelProvider);
+		dialog.setElements(configList.toArray());
+		dialog.setTitle(Messages.getString("AbstractSymbianLaunchShortcut.ChooseConfigTitle"));  //$NON-NLS-1$
+		dialog.setMessage(Messages.getString("AbstractSymbianLaunchShortcut.ChooseConfigLabel"));  //$NON-NLS-1$
+		dialog.setMultipleSelection(false);
+		int result = dialog.open();
+		labelProvider.dispose();
+		if (result == Window.OK) {
+			return (ILaunchConfiguration) dialog.getFirstResult();
+		}
+		return null;
+	}
+
 
 	public ILaunchConfiguration[] getLaunchConfigurations(ISelection selection) {
 		IPath defaultMMP = null;
@@ -127,7 +175,7 @@
 				if (file != null)
 				{
 					IPath filePath = file.getLocation();
-					if ("mmp".equalsIgnoreCase(filePath.getFileExtension()))
+					if ("mmp".equalsIgnoreCase(filePath.getFileExtension())) //$NON-NLS-1$
 					{
 						defaultMMP = filePath;
 					}
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/BoardLaunchShortcut.java	Wed Apr 07 11:58:17 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/BoardLaunchShortcut.java	Wed Apr 07 14:48:51 2010 -0500
@@ -18,8 +18,11 @@
 
 import org.eclipse.cdt.debug.core.executables.Executable;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.ILaunchConfiguration;
 
+import com.nokia.cdt.debug.cw.symbian.SettingsData;
 import com.nokia.cdt.internal.debug.launch.LaunchPlugin.ILaunchCreationWizardFactory;
 import com.nokia.cdt.internal.debug.launch.wizard.AbstractLaunchWizard;
 import com.nokia.cdt.internal.debug.launch.wizard.ILaunchCreationWizard;
@@ -29,6 +32,15 @@
 
 public class BoardLaunchShortcut extends AbstractSymbianLaunchShortcut {
 	
+	/* (non-Javadoc)
+	 * @see com.nokia.cdt.internal.debug.launch.AbstractSymbianLaunchShortcut#isSupportedConfiguration(org.eclipse.debug.core.ILaunchConfiguration)
+	 */
+	@Override
+	protected boolean isSupportedConfiguration(ILaunchConfiguration config)
+			throws CoreException {
+		return SettingsData.isStopModeConfiguration(config);
+	}
+	
 	@Override
 	protected void launchProject(IProject project, Executable executable, IPath defaultMMP, String mode) {
 		LaunchPlugin.getDefault().launchProject(project, executable, defaultMMP, mode, 
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/EmulatorLaunchShortcut.java	Wed Apr 07 11:58:17 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/EmulatorLaunchShortcut.java	Wed Apr 07 14:48:51 2010 -0500
@@ -18,8 +18,11 @@
 
 import org.eclipse.cdt.debug.core.executables.Executable;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.ILaunchConfiguration;
 
+import com.nokia.cdt.debug.cw.symbian.SettingsData;
 import com.nokia.cdt.internal.debug.launch.LaunchPlugin.ILaunchCreationWizardFactory;
 import com.nokia.cdt.internal.debug.launch.wizard.ILaunchCreationWizard;
 import com.nokia.cdt.internal.debug.launch.wizard.LaunchCreationWizardInstance;
@@ -27,6 +30,16 @@
 
 public class EmulatorLaunchShortcut extends AbstractSymbianLaunchShortcut {
 	
+	/* (non-Javadoc)
+	 * @see com.nokia.cdt.internal.debug.launch.AbstractSymbianLaunchShortcut#isSupportedConfiguration(org.eclipse.debug.core.ILaunchConfiguration)
+	 */
+	@Override
+	protected boolean isSupportedConfiguration(ILaunchConfiguration config)
+			throws CoreException {
+		
+		return SettingsData.isEmulatorConfiguration(config);
+	}
+	
 	@Override
 	protected void launchProject(IProject project, Executable executable, IPath defaultMMP, String mode) {
 		LaunchPlugin.getDefault().launchProject(project, executable, defaultMMP, mode, 
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java	Wed Apr 07 11:58:17 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java	Wed Apr 07 14:48:51 2010 -0500
@@ -391,12 +391,16 @@
 		}
 		String defaultConfigName = getDefaultLaunchConfigName(project, executable);
 		ArrayList<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();
+		
 		// Try the configurations not from the launch history
+		// EJS 100407: match more than one configuration if possible: there may be several for the same
+		// project and executable (stop mode, run mode, app trk, sys trk, etc).  These will have
+		// suffixes like "(1)", "(2)", etc.  So look for String#contains instead of String#equals.
 		ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
 		try {
 			ILaunchConfiguration[] launches = launchManager.getLaunchConfigurations();
 			for (ILaunchConfiguration launchConfiguration : launches) {
-				if (launchConfiguration.getName().equals(defaultConfigName) || 
+				if (launchConfiguration.getName().contains(defaultConfigName) || 
 						launchConfiguration.getAttribute(SettingsData.ATTR_originalName, launchConfiguration.getName()).equals(defaultConfigName))
 				{
 					if (defaultExecutable != null)
@@ -407,7 +411,6 @@
 					}
 					else
 						configs.add(launchConfiguration);
-					break;
 				}					
 			}
 		} catch (CoreException e) { 
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/PhoneLaunchShortcut.java	Wed Apr 07 11:58:17 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/PhoneLaunchShortcut.java	Wed Apr 07 14:48:51 2010 -0500
@@ -18,11 +18,14 @@
 
 import org.eclipse.cdt.debug.core.executables.Executable;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.ILaunchConfiguration;
 
 import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
 import com.nokia.carbide.remoteconnections.interfaces.IConnectionTypeProvider;
 import com.nokia.carbide.remoteconnections.interfaces.IService;
+import com.nokia.cdt.debug.cw.symbian.SettingsData;
 import com.nokia.cdt.internal.debug.launch.LaunchPlugin.ILaunchCreationWizardFactory;
 import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizard;
 import com.nokia.cdt.internal.debug.launch.wizard.ILaunchCreationWizard;
@@ -30,6 +33,15 @@
 
 public class PhoneLaunchShortcut extends AbstractSymbianLaunchShortcut {
 
+	/* (non-Javadoc)
+	 * @see com.nokia.cdt.internal.debug.launch.AbstractSymbianLaunchShortcut#isSupportedConfiguration(org.eclipse.debug.core.ILaunchConfiguration)
+	 */
+	@Override
+	protected boolean isSupportedConfiguration(ILaunchConfiguration config)
+			throws CoreException {
+		return SettingsData.isAppTRKConfiguration(config) || SettingsData.isSysTRKConfiguration(config);
+	}
+	
 	@Override
 	protected void launchProject(IProject project, Executable executable, IPath defaultMMP, String mode) {
 		LaunchPlugin.getDefault().launchProject(project, executable, defaultMMP, mode, 
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/messages.properties	Wed Apr 07 11:58:17 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/messages.properties	Wed Apr 07 14:48:51 2010 -0500
@@ -1,3 +1,5 @@
+AbstractSymbianLaunchShortcut.ChooseConfigLabel=Select the launch configuration:
+AbstractSymbianLaunchShortcut.ChooseConfigTitle=Choose configuration
 LaunchPlugin.0=Carbide_Sys_TRK
 LaunchPlugin.1=System TRK Debugging
 LaunchPlugin.17=No binaries found for project. Unable to launch.
--- a/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/sharedui/BuilderSelectionComposite.java	Wed Apr 07 11:58:17 2010 -0500
+++ b/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/sharedui/BuilderSelectionComposite.java	Wed Apr 07 14:48:51 2010 -0500
@@ -74,28 +74,37 @@
     public IStatus validate() {
 		useSBSv2Builder = true;
 		IStatus status = null;
-		if (builderCombo != null && builderCombo.getSelectionIndex() == 1) {
-
-			IPath sbsBinPath = SBSv2Utils.getSBSBinDirectory();
-			
-			// if SBSv2 is selected, make sure SBS_HOME is defined
-			if (SBSv2Utils.getSBSBinDirectory() == null){
-				status = new Status(Status.ERROR, ProjectUIPlugin.PLUGIN_ID, "SBS_HOME environment variable is not defined. Carbide needs this variable to find the base SBS install.");
-			}
-			
-			// check to see if SBS_HOME directory really exists
-			else if (!sbsBinPath.toFile().exists()){
-				status = new Status(Status.ERROR, ProjectUIPlugin.PLUGIN_ID, "SBS_HOME environment variable path does not exist: " + sbsBinPath.toOSString());
-			}
-			
-			// check the raptor version
-			else if (SDKCorePlugin.getSDKManager().getSBSv2Version(false).getMajor() == 0){
-				// Try to scan again....
-				if (SDKCorePlugin.getSDKManager().getSBSv2Version(true).getMajor() == 0){
-					status = new Status(Status.WARNING, ProjectUIPlugin.PLUGIN_ID, "SBS version cannot be determined, some SBS functionality may not work. Please check your SBS installation.");
+		if (builderCombo != null) {
+			if (builderCombo.getSelectionIndex() == 0) {
+				if (!SBSv2Utils.enableSBSv1Support()) {
+					status = new Status(Status.ERROR, ProjectUIPlugin.PLUGIN_ID, "SBSv1 is not supported on this system.");
 				}
 			}
+			else if (builderCombo.getSelectionIndex() == 1) {
 
+				IPath sbsBinPath = SBSv2Utils.getSBSBinDirectory();
+				
+				// if SBSv2 is selected, make sure SBS_HOME is defined
+				if (SBSv2Utils.getSBSBinDirectory() == null){
+					status = new Status(Status.ERROR, ProjectUIPlugin.PLUGIN_ID, "SBS_HOME environment variable is not defined. Carbide needs this variable to find the base SBS install.");
+				}
+				
+				// check to see if SBS_HOME directory really exists
+				else if (!sbsBinPath.toFile().exists()){
+					status = new Status(Status.ERROR, ProjectUIPlugin.PLUGIN_ID, "SBS_HOME environment variable path does not exist: " + sbsBinPath.toOSString());
+				}
+				
+				// check the raptor version
+				else if (SDKCorePlugin.getSDKManager().getSBSv2Version(false).getMajor() == 0){
+					// Try to scan again....
+					if (SDKCorePlugin.getSDKManager().getSBSv2Version(true).getMajor() == 0){
+						status = new Status(Status.WARNING, ProjectUIPlugin.PLUGIN_ID, "SBS version cannot be determined, some SBS functionality may not work. Please check your SBS installation.");
+					}
+				}
+
+			} else {
+				useSBSv2Builder = false;
+			}
 		} else {
 			useSBSv2Builder = false;
 		}