1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

removed runtime.compatablity dependency

build on launch should now be scoped to referenced projects only.
update launch tab interaction to use new 3.0 methods
This commit is contained in:
David Inglis 2004-05-18 16:43:58 +00:00
parent b458ecd917
commit aa2dc61d05
11 changed files with 485 additions and 235 deletions

View file

@ -24,7 +24,7 @@
<import plugin="org.eclipse.cdt.debug.core"/> <import plugin="org.eclipse.cdt.debug.core"/>
<import plugin="org.eclipse.cdt.debug.ui"/> <import plugin="org.eclipse.cdt.debug.ui"/>
<import plugin="org.eclipse.core.boot"/> <import plugin="org.eclipse.core.boot"/>
<import plugin="org.eclipse.core.runtime.compatibility"/> <import plugin="org.eclipse.core.runtime"/>
</requires> </requires>

View file

@ -1,6 +1,5 @@
/* /*
* (c) Copyright QNX Software System Ltd. 2002. * (c) Copyright QNX Software System Ltd. 2002. All Rights Reserved.
* All Rights Reserved.
*/ */
package org.eclipse.cdt.launch; package org.eclipse.cdt.launch;
@ -9,14 +8,18 @@ import java.io.FileNotFoundException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
@ -26,8 +29,11 @@ import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.utils.spawner.EnvironmentReader; import org.eclipse.cdt.utils.spawner.EnvironmentReader;
import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -40,25 +46,34 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.IStatusHandler; import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
import org.eclipse.debug.core.model.IPersistableSourceLocator; import org.eclipse.debug.core.model.IPersistableSourceLocator;
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDelegate { abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegate {
abstract public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) protected static final IStatus complileErrorPromptStatus = new Status(IStatus.INFO, "org.eclipse.cdt.launch", 202, "", null); //$NON-NLS-1$ //$NON-NLS-2$
throws CoreException;
/** /**
* Return the save environment variables in the configuration. * The project containing the programs file being launched
* The array does not include the default environment of the target. */
* array[n] : name=value private IProject project;
/**
* A list of prequisite projects ordered by their build order.
*/
private List orderedProjects;
abstract public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException;
/**
* Return the save environment variables in the configuration. The array does not include the default environment of the target.
* array[n] : name=value
*/ */
protected String[] getEnvironmentArray(ILaunchConfiguration config) { protected String[] getEnvironmentArray(ILaunchConfiguration config) {
Map env = null; Map env = null;
try { try {
env = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map) null); env = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map) null);
} } catch (CoreException e) {
catch (CoreException e) {
} }
if (env == null) { if (env == null) {
return new String[0]; return new String[0];
@ -74,8 +89,8 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
} }
/** /**
* Return the save environment variables of this configuration. * Return the save environment variables of this configuration. The array does not include the default environment of the
* The array does not include the default environment of the target. * target.
*/ */
protected Properties getEnvironmentProperty(ILaunchConfiguration config) { protected Properties getEnvironmentProperty(ILaunchConfiguration config) {
Properties prop = new Properties(); Properties prop = new Properties();
@ -103,20 +118,16 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
} }
/** /**
* Expand the variable with the format ${key}. example: * Expand the variable with the format ${key}. example: HOME=/foobar NEWHOME = ${HOME}/project The environement NEWHOME will be
* HOME=/foobar * /foobar/project.
* NEWHOME = ${HOME}/project
* The environement NEWHOME will be /foobar/project.
*/ */
protected Properties expandEnvironment(ILaunchConfiguration config ) { protected Properties expandEnvironment(ILaunchConfiguration config) {
return expandEnvironment(getEnvironmentProperty(config)); return expandEnvironment(getEnvironmentProperty(config));
} }
/** /**
* Expand the variable with the format ${key}. example: * Expand the variable with the format ${key}. example: HOME=/foobar NEWHOME = ${HOME}/project The environement NEWHOME will be
* HOME=/foobar * /foobar/project.
* NEWHOME = ${HOME}/project
* The environement NEWHOME will be /foobar/project.
*/ */
protected Properties expandEnvironment(Properties props) { protected Properties expandEnvironment(Properties props) {
Enumeration names = props.propertyNames(); Enumeration names = props.propertyNames();
@ -135,11 +146,11 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
for (int i = 0; i < value.length(); i++) { for (int i = 0; i < value.length(); i++) {
ch = value.charAt(i); ch = value.charAt(i);
switch (ch) { switch (ch) {
case '\'': case '\'' :
if (prev != '\\') { if (prev != '\\') {
inSingleQuote = !inSingleQuote; inSingleQuote = !inSingleQuote;
} }
break; break;
case '$' : case '$' :
if (!inSingleQuote && prev != '\\') { if (!inSingleQuote && prev != '\\') {
@ -153,15 +164,15 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
} }
} }
} }
break; break;
case '}' : case '}' :
if (inMacro) { if (inMacro) {
inMacro = false; inMacro = false;
String v = null; String v = null;
String p = param.toString(); String p = param.toString();
/* Search in the current property only /*
* if it is not the same name. * Search in the current property only if it is not the same name.
*/ */
if (!p.equals(key)) { if (!p.equals(key)) {
v = props.getProperty(p); v = props.getProperty(p);
@ -181,7 +192,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
prev = ch; prev = ch;
continue; continue;
} }
break; break;
} /* switch */ } /* switch */
if (!inMacro) { if (!inMacro) {
@ -202,27 +213,27 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
} }
/** /**
* Returns the working directory specified by * Returns the working directory specified by the given launch configuration, or <code>null</code> if none.
* the given launch configuration, or <code>null</code> if none.
* *
* @deprecated Should use getWorkingDirectory() * @deprecated Should use getWorkingDirectory()
* @param configuration launch configuration * @param configuration
* @return the working directory specified by the given * launch configuration
* launch configuration, or <code>null</code> if none * @return the working directory specified by the given launch configuration, or <code>null</code> if none
* @exception CoreException if unable to retrieve the attribute * @exception CoreException
* if unable to retrieve the attribute
*/ */
public File getWorkingDir(ILaunchConfiguration configuration) throws CoreException { public File getWorkingDir(ILaunchConfiguration configuration) throws CoreException {
return getWorkingDirectory(configuration); return getWorkingDirectory(configuration);
} }
/** /**
* Returns the working directory specified by * Returns the working directory specified by the given launch configuration, or <code>null</code> if none.
* the given launch configuration, or <code>null</code> if none.
* *
* @param configuration launch configuration * @param configuration
* @return the working directory specified by the given * launch configuration
* launch configuration, or <code>null</code> if none * @return the working directory specified by the given launch configuration, or <code>null</code> if none
* @exception CoreException if unable to retrieve the attribute * @exception CoreException
* if unable to retrieve the attribute
*/ */
public File getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException { public File getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
return verifyWorkingDirectory(configuration); return verifyWorkingDirectory(configuration);
@ -237,17 +248,19 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
} }
/** /**
* Throws a core exception with an error status object built from * Throws a core exception with an error status object built from the given message, lower level exception, and error code.
* the given message, lower level exception, and error code.
* *
* @param message the status message * @param message
* @param exception lower level exception associated with the * the status message
* error, or <code>null</code> if none * @param exception
* @param code error code * lower level exception associated with the error, or <code>null</code> if none
* @param code
* error code
*/ */
protected void abort(String message, Throwable exception, int code) throws CoreException { protected void abort(String message, Throwable exception, int code) throws CoreException {
MultiStatus status = new MultiStatus(getPluginID(),code, message,exception); MultiStatus status = new MultiStatus(getPluginID(), code, message, exception);
status.add(new Status(IStatus.ERROR,getPluginID(),code, exception == null ? "" : exception.getLocalizedMessage(),exception)); //$NON-NLS-1$ status.add(new Status(IStatus.ERROR, getPluginID(), code, exception == null ? "" : exception.getLocalizedMessage(), //$NON-NLS-1$
exception));
throw new CoreException(status); throw new CoreException(status);
} }
@ -283,10 +296,13 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
/** /**
* Assigns a default source locator to the given launch if a source locator has not yet been assigned to it, and the associated * Assigns a default source locator to the given launch if a source locator has not yet been assigned to it, and the associated
* launch configuration does not specify a source locator. * launch configuration does not specify a source locator.
* *
* @param launch launch object * @param launch
* @param configuration configuration being launched * launch object
* @exception CoreException if unable to set the source locator * @param configuration
* configuration being launched
* @exception CoreException
* if unable to set the source locator
*/ */
protected void setSourceLocator(ILaunch launch, ILaunchConfiguration configuration) throws CoreException { protected void setSourceLocator(ILaunch launch, ILaunchConfiguration configuration) throws CoreException {
// set default source locator if none specified // set default source locator if none specified
@ -296,13 +312,14 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
if (id == null) { if (id == null) {
ICProject cProject = getCProject(configuration); ICProject cProject = getCProject(configuration);
if (cProject == null) { if (cProject == null) {
abort(LaunchUIPlugin.getResourceString("Launch.common.Project_does_not_exist"), null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); //$NON-NLS-1$ abort(LaunchUIPlugin.getResourceString("Launch.common.Project_does_not_exist"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
} }
sourceLocator = CDebugUIPlugin.createDefaultSourceLocator(); sourceLocator = CDebugUIPlugin.createDefaultSourceLocator();
sourceLocator.initializeDefaults(configuration); sourceLocator.initializeDefaults(configuration);
} else { } else {
sourceLocator = DebugPlugin.getDefault().getLaunchManager().newSourceLocator(id); sourceLocator = DebugPlugin.getDefault().getLaunchManager().newSourceLocator(id);
String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null); String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String) null);
if (memento == null) { if (memento == null) {
sourceLocator.initializeDefaults(configuration); sourceLocator.initializeDefaults(configuration);
} else { } else {
@ -315,7 +332,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
/** /**
* Returns the program arguments as a String. * Returns the program arguments as a String.
* *
* @return the program arguments as a String * @return the program arguments as a String
*/ */
public String getProgramArguments(ILaunchConfiguration config) throws CoreException { public String getProgramArguments(ILaunchConfiguration config) throws CoreException {
@ -324,7 +341,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
} }
/** /**
* Returns the program arguments as an array of individual arguments. * Returns the program arguments as an array of individual arguments.
* *
* @return the program arguments as an array of individual arguments * @return the program arguments as an array of individual arguments
*/ */
public String[] getProgramArgumentsArray(ILaunchConfiguration config) throws CoreException { public String[] getProgramArgumentsArray(ILaunchConfiguration config) throws CoreException {
@ -343,15 +360,10 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
protected ICDebugConfiguration getDebugConfig(ILaunchConfiguration config) throws CoreException { protected ICDebugConfiguration getDebugConfig(ILaunchConfiguration config) throws CoreException {
ICDebugConfiguration dbgCfg = null; ICDebugConfiguration dbgCfg = null;
try { try {
dbgCfg = dbgCfg = CDebugCorePlugin.getDefault().getDebugConfiguration(
CDebugCorePlugin.getDefault().getDebugConfiguration(
config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "")); //$NON-NLS-1$ config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "")); //$NON-NLS-1$
} } catch (CoreException e) {
catch (CoreException e) { IStatus status = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(),
IStatus status =
new Status(
IStatus.ERROR,
LaunchUIPlugin.getUniqueIdentifier(),
ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED, ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED,
LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Debugger_not_installed"), //$NON-NLS-1$ LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Debugger_not_installed"), //$NON-NLS-1$
e); e);
@ -371,30 +383,33 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
protected String renderTargetLabel(ICDebugConfiguration debugConfig) { protected String renderTargetLabel(ICDebugConfiguration debugConfig) {
String format = "{0} ({1})"; //$NON-NLS-1$ String format = "{0} ({1})"; //$NON-NLS-1$
String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis())); String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
return MessageFormat.format(format, new String[] { debugConfig.getName(), timestamp }); return MessageFormat.format(format, new String[]{debugConfig.getName(), timestamp});
} }
protected String renderProcessLabel(String commandLine) { protected String renderProcessLabel(String commandLine) {
String format = "{0} ({1})"; //$NON-NLS-1$ String format = "{0} ({1})"; //$NON-NLS-1$
String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis())); String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
return MessageFormat.format(format, new String[] { commandLine, timestamp }); return MessageFormat.format(format, new String[]{commandLine, timestamp});
} }
protected ICProject verifyCProject(ILaunchConfiguration config) throws CoreException { protected ICProject verifyCProject(ILaunchConfiguration config) throws CoreException {
String name = getProjectName(config); String name = getProjectName(config);
if (name == null) { if (name == null) {
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.C_Project_not_specified"), null, ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT); //$NON-NLS-1$ abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.C_Project_not_specified"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT);
} }
ICProject cproject = getCProject(config); ICProject cproject = getCProject(config);
if (cproject == null) { if (cproject == null) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
if (!project.exists()) { if (!project.exists()) {
abort( LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.Project_NAME_does_not_exist", name), null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); //$NON-NLS-1$ abort(LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.Project_NAME_does_not_exist", name), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
} else if (!project.isOpen()) {
abort(LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.Project_NAME_is_closed", name), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
} }
else if (!project.isOpen()) { abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Not_a_C_CPP_project"), null, //$NON-NLS-1$
abort( LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.Project_NAME_is_closed", name), null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
}
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Not_a_C_CPP_project"), null, ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); //$NON-NLS-1$
} }
return cproject; return cproject;
} }
@ -403,12 +418,16 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
ICProject cproject = verifyCProject(config); ICProject cproject = verifyCProject(config);
String fileName = getProgramName(config); String fileName = getProgramName(config);
if (fileName == null) { if (fileName == null) {
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Program_file_not_specified"), null, ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM); //$NON-NLS-1$ abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM);
} }
IFile programPath = ((IProject) cproject.getResource()).getFile(fileName); IFile programPath = ((IProject) cproject.getResource()).getFile(fileName);
if (programPath == null || !programPath.exists() || !programPath.getLocation().toFile().exists()) { if (programPath == null || !programPath.exists() || !programPath.getLocation().toFile().exists()) {
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Program_file_does_not_exist"), new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.PROGRAM_PATH_not_found", programPath.getLocation().toOSString())), ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST); //$NON-NLS-1$ //$NON-NLS-2$ abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Program_file_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString(
"AbstractCLaunchDelegate.PROGRAM_PATH_not_found", programPath.getLocation().toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
} }
return programPath; return programPath;
} }
@ -416,16 +435,16 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
protected IPath verifyProgramFile(ILaunchConfiguration config) throws CoreException { protected IPath verifyProgramFile(ILaunchConfiguration config) throws CoreException {
return getProgramFile(config).getLocation(); return getProgramFile(config).getLocation();
} }
/** /**
* Verifies the working directory specified by the given * Verifies the working directory specified by the given launch configuration exists, and returns the working directory, or
* launch configuration exists, and returns the working * <code>null</code> if none is specified.
* directory, or <code>null</code> if none is specified.
* *
* @param configuration launch configuration * @param configuration
* @return the working directory specified by the given * launch configuration
* launch configuration, or <code>null</code> if none * @return the working directory specified by the given launch configuration, or <code>null</code> if none
* @exception CoreException if unable to retrieve the attribute * @exception CoreException
* if unable to retrieve the attribute
*/ */
public File verifyWorkingDirectory(ILaunchConfiguration configuration) throws CoreException { public File verifyWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
IPath path = getWorkingDirectoryPath(configuration); IPath path = getWorkingDirectoryPath(configuration);
@ -436,30 +455,26 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
IProject p = cp.getProject(); IProject p = cp.getProject();
return p.getLocation().toFile(); return p.getLocation().toFile();
} }
} } else {
else {
if (path.isAbsolute()) { if (path.isAbsolute()) {
File dir = new File(path.toOSString()); File dir = new File(path.toOSString());
if (dir.isDirectory()) { if (dir.isDirectory()) {
return dir; return dir;
} else {
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString(
"AbstractCLaunchDelegate.PROGRAM_PATH_not_found", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
} }
else { } else {
abort(
LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException( LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.PROGRAM_PATH_not_found", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
}
}
else {
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path); IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
if (res instanceof IContainer && res.exists()) { if (res instanceof IContainer && res.exists()) {
return res.getLocation().toFile(); return res.getLocation().toFile();
} } else {
else { abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
abort( new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString(
LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$ "AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist", path.toOSString())), //$NON-NLS-1$
new FileNotFoundException( LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist", path.toOSString())), //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
} }
} }
} }
@ -467,6 +482,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
} }
private static class ArgumentParser { private static class ArgumentParser {
private String fArgs; private String fArgs;
private int fIndex = 0; private int fIndex = 0;
private int ch = -1; private int ch = -1;
@ -485,8 +501,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
if (ch == '"') { if (ch == '"') {
v.add(parseString()); v.add(parseString());
} } else {
else {
v.add(parseToken()); v.add(parseToken());
} }
} }
@ -525,7 +540,7 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
private String parseToken() { private String parseToken() {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
while (ch > 0 && !Character.isWhitespace((char) ch)) { while (ch > 0 && !Character.isWhitespace((char) ch)) {
if (ch == '\\') { if (ch == '\\') {
ch = getNext(); ch = getNext();
@ -535,15 +550,12 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
} }
buf.append((char) ch); buf.append((char) ch);
ch = getNext(); ch = getNext();
} } else if (ch == -1) { // Don't lose a trailing backslash
else if (ch == -1) { // Don't lose a trailing backslash
buf.append('\\'); buf.append('\\');
} }
} } else if (ch == '"') {
else if (ch == '"') {
buf.append(parseString()); buf.append(parseString());
} } else {
else {
buf.append((char) ch); buf.append((char) ch);
ch = getNext(); ch = getNext();
} }
@ -551,4 +563,195 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
return buf.toString(); return buf.toString();
} }
} }
}
/**
* Recursively creates a set of projects referenced by the current project
*
* @param project
* The current project
* @param referencedProjSet
* A set of referenced projects
* @throws CoreException
* if an error occurs while getting referenced projects from the current project
*/
private void getReferencedProjectSet(IProject project, HashSet referencedProjSet) throws CoreException {
IProject[] projects = project.getReferencedProjects();
for (int i = 0; i < projects.length; i++) {
IProject refProject = projects[i];
if (refProject.exists() && !referencedProjSet.contains(refProject)) {
referencedProjSet.add(refProject);
getReferencedProjectSet(refProject, referencedProjSet);
}
}
}
/**
* creates a list of project ordered by their build order from an unordered list of projects.
*
* @param resourceCollection
* The list of projects to sort.
* @return A new list of projects, ordered by build order.
*/
private List getBuildOrder(List resourceCollection) {
String[] orderedNames = ResourcesPlugin.getWorkspace().getDescription().getBuildOrder();
if (orderedNames != null) {
List orderedProjects = new ArrayList(resourceCollection.size());
//Projects may not be in the build order but should be built if selected
List unorderedProjects = new ArrayList(resourceCollection.size());
unorderedProjects.addAll(resourceCollection);
for (int i = 0; i < orderedNames.length; i++) {
String projectName = orderedNames[i];
for (int j = 0; j < resourceCollection.size(); j++) {
IProject project = (IProject) resourceCollection.get(j);
if (project.getName().equals(projectName)) {
orderedProjects.add(project);
unorderedProjects.remove(project);
break;
}
}
}
//Add anything not specified before we return
orderedProjects.addAll(unorderedProjects);
return orderedProjects;
}
// Try the project prerequisite order then
IProject[] projects = new IProject[resourceCollection.size()];
projects = (IProject[]) resourceCollection.toArray(projects);
IWorkspace.ProjectOrder po = ResourcesPlugin.getWorkspace().computeProjectOrder(projects);
ArrayList orderedProjects = new ArrayList();
orderedProjects.addAll(Arrays.asList(po.projects));
return orderedProjects;
}
/**
* Builds the current project and all of it's prerequisite projects if necessary. Respects specified build order if any exists.
*
* @param configuration
* the configuration being launched
* @param mode
* the mode the configuration is being launched in
* @param monitor
* progress monitor
* @return whether the debug platform should perform an incremental workspace build before the launch
* @throws CoreException
* if an exception occurrs while building
*/
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
if (orderedProjects != null) {
monitor.beginTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.building_projects"), //$NON-NLS-1$
orderedProjects.size() + 1);
for (Iterator i = orderedProjects.iterator(); i.hasNext();) {
IProject proj = (IProject) i.next();
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.building") + proj.getName()); //$NON-NLS-1$
proj.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
}
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractLaunchConfigurationDelegate.building") + project.getName()); //$NON-NLS-1$
project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
}
monitor.done();
return false; //don't build. I already did it or I threw an exception.
}
/**
* Searches for compile errors in the current project and any of its prerequisite projects. If any compile errors, give the user
* a chance to abort the launch and correct the errors.
*
* @param configuration
* @param mode
* @param monitor
* @return whether the launch should proceed
* @throws CoreException
* if an exception occurs while checking for compile errors.
*/
public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
try {
boolean continueLaunch = true;
if (orderedProjects != null) {
monitor.beginTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.searching_for_errors"), //$NON-NLS-1$
orderedProjects.size() + 1);
boolean compileErrorsInProjs = false;
//check prerequisite projects for compile errors.
for (Iterator i = orderedProjects.iterator(); i.hasNext();) {
IProject proj = (IProject) i.next();
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.searching_for_errors_in") //$NON-NLS-1$
+ proj.getName());
compileErrorsInProjs = existsErrors(proj);
if (compileErrorsInProjs) {
break;
}
}
//check current project, if prerequite projects were ok
if (!compileErrorsInProjs) {
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.searching_for_errors_in") //$NON-NLS-1$
+ project.getName());
compileErrorsInProjs = existsErrors(project);
}
//if compile errors exist, ask the user before continuing.
if (compileErrorsInProjs) {
IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
if (prompter != null) {
continueLaunch = ((Boolean) prompter.handleStatus(complileErrorPromptStatus, null)).booleanValue();
}
}
}
return continueLaunch;
} finally {
monitor.done();
}
}
/**
* Searches for compile errors in the specified project
*
* @param proj
* The project to search
* @return true if compile errors exist, otherwise false
*/
private boolean existsErrors(IProject proj) throws CoreException {
IMarker[] markers = proj.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
if (markers.length > 0) {
for (int j = 0; j < markers.length; j++) {
if (((Integer) markers[j].getAttribute(IMarker.SEVERITY)).intValue() == IMarker.SEVERITY_ERROR) {
return true;
}
}
}
return false;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate2#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration,
* java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
*/
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
// build project list
if (monitor != null) {
monitor.subTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.20")); //$NON-NLS-1$
}
orderedProjects = null;
ICProject cProject = getCProject(configuration);
if (cProject != null) {
project = cProject.getProject();
HashSet projectSet = new HashSet();
getReferencedProjectSet(project, projectSet);
orderedProjects = getBuildOrder(new ArrayList(projectSet));
}
// do generic launch checks
return super.preLaunchCheck(configuration, mode, monitor);
}
}

View file

@ -16,11 +16,11 @@ import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate; import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.cdt.ui.CElementLabelProvider;
import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
@ -113,7 +113,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
ICDebugConfiguration debugConfig = null; ICDebugConfiguration debugConfig = null;
ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations(); ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
List debugList = new ArrayList(debugConfigs.length); List debugList = new ArrayList(debugConfigs.length);
String os = BootLoader.getOS(); String os = Platform.getOS();
for (int i = 0; i < debugConfigs.length; i++) { for (int i = 0; i < debugConfigs.length; i++) {
String platform = debugConfigs[i].getPlatform(); String platform = debugConfigs[i].getPlatform();
if (platform == null || platform.equals(ICDebugConfiguration.PLATFORM_NATIVE) || platform.equals(os)) { if (platform == null || platform.equals(ICDebugConfiguration.PLATFORM_NATIVE) || platform.equals(os)) {

View file

@ -160,6 +160,14 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
abstract protected ICDebugConfiguration getConfigForCurrentDebugger(); abstract protected ICDebugConfiguration getConfigForCurrentDebugger();
abstract public void createControl(Composite parent); abstract public void createControl(Composite parent);
public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
ILaunchConfigurationTab dynamicTab = getDynamicTab();
if (dynamicTab != null) {
dynamicTab.activated(workingCopy);
}
}
public void initializeFrom(ILaunchConfiguration config) { public void initializeFrom(ILaunchConfiguration config) {
setLaunchConfiguration(config); setLaunchConfiguration(config);
ILaunchConfigurationTab dynamicTab = getDynamicTab(); ILaunchConfigurationTab dynamicTab = getDynamicTab();

View file

@ -4,6 +4,7 @@ import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
@ -22,11 +23,7 @@ public class LaunchImages {
// Subdirectory (under the package containing this class) where 16 color images are // Subdirectory (under the package containing this class) where 16 color images are
private static URL fgIconBaseURL; private static URL fgIconBaseURL;
static { static {
try { fgIconBaseURL= Platform.getBundle(LaunchUIPlugin.getUniqueIdentifier()).getEntry("/icons/"); //$NON-NLS-1$
fgIconBaseURL= new URL(LaunchUIPlugin.getDefault().getDescriptor().getInstallURL(), "icons/" ); //$NON-NLS-1$
} catch (MalformedURLException e) {
//LaunchUIPlugin.getDefault().log(e);
}
} }
private static final String T_TABS = "tabs/"; //$NON-NLS-1$ private static final String T_TABS = "tabs/"; //$NON-NLS-1$

View file

@ -1,10 +1,13 @@
package org.eclipse.cdt.launch.internal.ui; package org.eclipse.cdt.launch.internal.ui;
import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate; import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugEvent;
@ -16,20 +19,15 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.text.MessageFormat;
/* /*
* (c) Copyright QNX Software Systems Ltd. 2002. * (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
* All Rights Reserved.
*/ */
public class LaunchUIPlugin extends AbstractUIPlugin public class LaunchUIPlugin extends AbstractUIPlugin
implements IDebugEventSetListener { implements
public static final String PLUGIN_ID = LaunchUIPlugin.getUniqueIdentifier(); IDebugEventSetListener {
public static final String PLUGIN_ID = "org.eclipse.cdt.launch"; //$NON-NLS-1$
private static final String BUNDLE_NAME = "org.eclipse.cdt.launch.internal.ui.LaunchUIPluginResources";//$NON-NLS-1$ private static final String BUNDLE_NAME = "org.eclipse.cdt.launch.internal.ui.LaunchUIPluginResources";//$NON-NLS-1$
private static ResourceBundle resourceBundle = null; private static ResourceBundle resourceBundle = null;
@ -37,7 +35,7 @@ public class LaunchUIPlugin extends AbstractUIPlugin
// -------- static methods -------- // -------- static methods --------
static { static {
if ( resourceBundle == null ) { if (resourceBundle == null) {
// Acquire a reference to the .properties file for this plug-in // Acquire a reference to the .properties file for this plug-in
try { try {
resourceBundle = ResourceBundle.getBundle(BUNDLE_NAME); resourceBundle = ResourceBundle.getBundle(BUNDLE_NAME);
@ -46,31 +44,33 @@ public class LaunchUIPlugin extends AbstractUIPlugin
} }
} }
} }
/** /**
* Launch UI plug-in instance * Launch UI plug-in instance
*/ */
private static LaunchUIPlugin fgPlugin; private static LaunchUIPlugin fgPlugin;
private static Shell debugDialogShell; private static Shell debugDialogShell;
/** /**
* Constructor for LaunchUIPlugin. * Constructor for LaunchUIPlugin.
*
* @param descriptor * @param descriptor
*/ */
public LaunchUIPlugin(IPluginDescriptor descriptor) { public LaunchUIPlugin() {
super(descriptor); super();
setDefault(this); setDefault(this);
} }
/** /**
* Sets the Java Debug UI plug-in instance * Sets the Java Debug UI plug-in instance
* *
* @param plugin the plugin instance * @param plugin
* the plugin instance
*/ */
private static void setDefault(LaunchUIPlugin plugin) { private static void setDefault(LaunchUIPlugin plugin) {
fgPlugin = plugin; fgPlugin = plugin;
} }
/** /**
* Returns the Java Debug UI plug-in instance * Returns the Java Debug UI plug-in instance
* *
@ -79,17 +79,18 @@ public class LaunchUIPlugin extends AbstractUIPlugin
public static LaunchUIPlugin getDefault() { public static LaunchUIPlugin getDefault() {
return fgPlugin; return fgPlugin;
} }
public static Shell getShell() { public static Shell getShell() {
if (getActiveWorkbenchShell() != null) { if (getActiveWorkbenchShell() != null) {
return getActiveWorkbenchShell(); return getActiveWorkbenchShell();
} else { } else {
if ( debugDialogShell != null ) { if (debugDialogShell != null) {
if (!debugDialogShell.isDisposed() ) if (!debugDialogShell.isDisposed())
return debugDialogShell; return debugDialogShell;
debugDialogShell = null; debugDialogShell = null;
} }
IWorkbenchWindow[] windows = getDefault().getWorkbench().getWorkbenchWindows(); IWorkbenchWindow[] windows = getDefault().getWorkbench()
.getWorkbenchWindows();
return windows[0].getShell(); return windows[0].getShell();
} }
} }
@ -97,7 +98,7 @@ public class LaunchUIPlugin extends AbstractUIPlugin
public static void setDialogShell(Shell shell) { public static void setDialogShell(Shell shell) {
debugDialogShell = shell; debugDialogShell = shell;
} }
/** /**
* Convenience method which returns the unique identifier of this plugin. * Convenience method which returns the unique identifier of this plugin.
*/ */
@ -106,15 +107,16 @@ public class LaunchUIPlugin extends AbstractUIPlugin
// If the default instance is not yet initialized, // If the default instance is not yet initialized,
// return a static identifier. This identifier must // return a static identifier. This identifier must
// match the plugin id defined in plugin.xml // match the plugin id defined in plugin.xml
return "org.eclipse.cdt.launch"; //$NON-NLS-1$ return PLUGIN_ID;
} }
return getDefault().getDescriptor().getUniqueIdentifier(); return getDefault().getBundle().getSymbolicName();
} }
/** /**
* Logs the specified status with this plug-in's log. * Logs the specified status with this plug-in's log.
* *
* @param status status to log * @param status
* status to log
*/ */
public static void log(IStatus status) { public static void log(IStatus status) {
getDefault().getLog().log(status); getDefault().getLog().log(status);
@ -122,19 +124,23 @@ public class LaunchUIPlugin extends AbstractUIPlugin
/** /**
* Logs an internal error with the specified message. * Logs an internal error with the specified message.
* *
* @param message the error message to log * @param message
* the error message to log
*/ */
public static void logErrorMessage(String message) { public static void logErrorMessage(String message) {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, message, null)); log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR,
message, null));
} }
/** /**
* Logs an internal error with the specified throwable * Logs an internal error with the specified throwable
* *
* @param e the exception to be logged * @param e
*/ * the exception to be logged
*/
public static void log(Throwable e) { public static void log(Throwable e) {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e)); //$NON-NLS-1$ log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e
.getMessage(), e)); //$NON-NLS-1$
} }
/** /**
@ -144,8 +150,8 @@ public class LaunchUIPlugin extends AbstractUIPlugin
*/ */
public static IWorkbenchWindow getActiveWorkbenchWindow() { public static IWorkbenchWindow getActiveWorkbenchWindow() {
return getDefault().getWorkbench().getActiveWorkbenchWindow(); return getDefault().getWorkbench().getActiveWorkbenchWindow();
} }
public static IWorkbenchPage getActivePage() { public static IWorkbenchPage getActivePage() {
IWorkbenchWindow w = getActiveWorkbenchWindow(); IWorkbenchWindow w = getActiveWorkbenchWindow();
if (w != null) { if (w != null) {
@ -166,12 +172,16 @@ public class LaunchUIPlugin extends AbstractUIPlugin
} }
return null; return null;
} }
public static void errorDialog( String message, IStatus status ) { public static void errorDialog(String message, IStatus status) {
log(status); log(status);
Shell shell = getActiveWorkbenchShell(); Shell shell = getActiveWorkbenchShell();
if (shell != null) { if (shell != null) {
ErrorDialog.openError(shell, LaunchUIPlugin.getResourceString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$ ErrorDialog
.openError(
shell,
LaunchUIPlugin
.getResourceString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$
} }
} }
@ -179,47 +189,60 @@ public class LaunchUIPlugin extends AbstractUIPlugin
log(t); log(t);
Shell shell = getActiveWorkbenchShell(); Shell shell = getActiveWorkbenchShell();
if (shell != null) { if (shell != null) {
IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(), 1, t.getMessage(), null); //$NON-NLS-1$ IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(),
ErrorDialog.openError(shell, LaunchUIPlugin.getResourceString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$ 1, t.getMessage(), null); //$NON-NLS-1$
ErrorDialog
.openError(
shell,
LaunchUIPlugin
.getResourceString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$
} }
} }
/**
* @see org.eclipse.core.runtime.Plugin#shutdown() /*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/ */
public void shutdown() throws CoreException { public void start(BundleContext context) throws Exception {
DebugPlugin.getDefault().removeDebugEventListener(this); super.start(context);
super.shutdown(); DebugPlugin.getDefault().addDebugEventListener(this);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
DebugPlugin.getDefault().removeDebugEventListener(this);
super.stop(context);
} }
/** /**
* @see org.eclipse.core.runtime.Plugin#startup() * Notifies this listener of the given debug events. All of the events in
*/ * the given event collection occurred at the same location the program be
public void startup() throws CoreException { * run or debugged.
super.startup(); *
DebugPlugin.getDefault().addDebugEventListener(this); * @param events
} * the debug events
/**
* Notifies this listener of the given debug events.
* All of the events in the given event collection occurred
* at the same location the program be run or debugged.
*
* @param events the debug events
*/ */
public void handleDebugEvents(DebugEvent[] events) { public void handleDebugEvents(DebugEvent[] events) {
for (int i = 0; i < events.length; i++) { for (int i = 0; i < events.length; i++) {
if (events[i].getKind() == DebugEvent.TERMINATE) { if (events[i].getKind() == DebugEvent.TERMINATE) {
Object o = events[i].getSource(); Object o = events[i].getSource();
if (o instanceof IProcess) { if (o instanceof IProcess) {
IProcess proc = (IProcess)o; IProcess proc = (IProcess) o;
ICProject cproject = null; ICProject cproject = null;
try { try {
cproject = AbstractCLaunchDelegate.getCProject(proc.getLaunch().getLaunchConfiguration()); cproject = AbstractCLaunchDelegate.getCProject(proc
.getLaunch().getLaunchConfiguration());
} catch (CoreException e) { } catch (CoreException e) {
} }
if (cproject != null) { if (cproject != null) {
try { try {
cproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null); cproject.getProject().refreshLocal(
IResource.DEPTH_INFINITE, null);
} catch (CoreException e) { } catch (CoreException e) {
} }
} }
@ -239,27 +262,26 @@ public class LaunchUIPlugin extends AbstractUIPlugin
ResourceBundle bundle = LaunchUIPlugin.getDefault().getResourceBundle(); ResourceBundle bundle = LaunchUIPlugin.getDefault().getResourceBundle();
// No point trying if bundle is null as exceptions are costly // No point trying if bundle is null as exceptions are costly
if ( bundle != null ) if (bundle != null) {
{
try { try {
return bundle.getString(key); return bundle.getString(key);
} catch (MissingResourceException e) { } catch (MissingResourceException e) {
return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
} catch (NullPointerException e) { } catch (NullPointerException e) {
return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$ return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
} }
} }
// If we get here, then bundle is null. // If we get here, then bundle is null.
return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$ return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
} }
public static String getFormattedResourceString(String key, String arg) { public static String getFormattedResourceString(String key, String arg) {
return MessageFormat.format(getResourceString(key), new String[] { arg }); return MessageFormat.format(getResourceString(key), new String[]{arg});
} }
public static String getFormattedResourceString(String key, String[] args) { public static String getFormattedResourceString(String key, String[] args) {
return MessageFormat.format(getResourceString(key), args); return MessageFormat.format(getResourceString(key), args);
} }
} }

View file

@ -9,6 +9,10 @@ AbstractCLaunchDelegate.Project_NAME_does_not_exist=Project {0} does not exist
AbstractCLaunchDelegate.Project_NAME_is_closed=Project {0} is closed AbstractCLaunchDelegate.Project_NAME_is_closed=Project {0} is closed
AbstractCLaunchDelegate.PROGRAM_PATH_not_found={0} not found AbstractCLaunchDelegate.PROGRAM_PATH_not_found={0} not found
AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist={0} Does not exist. AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist={0} Does not exist.
AbstractCLaunchConfigurationDelegate.building_projects=Building prerequisite project list
AbstractCLaunchConfigurationDelegate.building=Building
AbstractCLaunchConfigurationDelegate.searching_for_errors=Searching for compile errors
AbstractCLaunchConfigurationDelegate.searching_for_errors_in=Searching for compile errors in
LocalCLaunchConfigurationDelegate.Launching_Local_C_Application=Launching Local C Application LocalCLaunchConfigurationDelegate.Launching_Local_C_Application=Launching Local C Application
LocalCLaunchConfigurationDelegate.No_Process_ID_selected=No Process ID selected LocalCLaunchConfigurationDelegate.No_Process_ID_selected=No Process ID selected

View file

@ -1,6 +1,5 @@
/* /*
* (c) Copyright QNX Software System Ltd. 2002. * (c) Copyright QNX Software System Ltd. 2002. All Rights Reserved.
* All Rights Reserved.
*/ */
package org.eclipse.cdt.launch.ui; package org.eclipse.cdt.launch.ui;
@ -14,8 +13,8 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab; import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
@ -32,7 +31,6 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.help.WorkbenchHelp;
public class CDebuggerTab extends AbstractCDebuggerTab { public class CDebuggerTab extends AbstractCDebuggerTab {
protected Combo fDCombo; protected Combo fDCombo;
@ -48,12 +46,12 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
Composite comp = new Composite(parent, SWT.NONE); Composite comp = new Composite(parent, SWT.NONE);
setControl(comp); setControl(comp);
WorkbenchHelp.setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB); WorkbenchHelp.setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB);
GridLayout layout = new GridLayout(2, false); GridLayout layout = new GridLayout(2, false);
comp.setLayout(layout); comp.setLayout(layout);
Composite comboComp = new Composite(comp, SWT.NONE); Composite comboComp = new Composite(comp, SWT.NONE);
layout = new GridLayout(2, false); layout = new GridLayout(2, false);
comboComp.setLayout(layout); comboComp.setLayout(layout);
@ -61,6 +59,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
dlabel.setText(LaunchUIPlugin.getResourceString("Launch.common.DebuggerColon")); //$NON-NLS-1$ dlabel.setText(LaunchUIPlugin.getResourceString("Launch.common.DebuggerColon")); //$NON-NLS-1$
fDCombo = new Combo(comboComp, SWT.DROP_DOWN | SWT.READ_ONLY); fDCombo = new Combo(comboComp, SWT.DROP_DOWN | SWT.READ_ONLY);
fDCombo.addModifyListener(new ModifyListener() { fDCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
updateComboFromSelection(); updateComboFromSelection();
} }
@ -73,6 +72,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
radioComp.setLayout(radioLayout); radioComp.setLayout(radioLayout);
fRunButton = createRadioButton(radioComp, LaunchUIPlugin.getResourceString("CDebuggerTab.Run_program_in_debugger")); //$NON-NLS-1$ fRunButton = createRadioButton(radioComp, LaunchUIPlugin.getResourceString("CDebuggerTab.Run_program_in_debugger")); //$NON-NLS-1$
fRunButton.addSelectionListener(new SelectionAdapter() { fRunButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
if (fRunButton.getSelection() == true) { if (fRunButton.getSelection() == true) {
fStopInMain.setEnabled(true); fStopInMain.setEnabled(true);
@ -84,35 +84,37 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
}); });
fAttachButton = createRadioButton(radioComp, LaunchUIPlugin.getResourceString("CDebuggerTab.Attach_to_running_process")); //$NON-NLS-1$ fAttachButton = createRadioButton(radioComp, LaunchUIPlugin.getResourceString("CDebuggerTab.Attach_to_running_process")); //$NON-NLS-1$
fAttachButton.addSelectionListener(new SelectionAdapter() { fAttachButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
Composite optionComp = new Composite(comp, SWT.NONE); Composite optionComp = new Composite(comp, SWT.NONE);
layout = new GridLayout(2, false); layout = new GridLayout(2, false);
optionComp.setLayout(layout); optionComp.setLayout(layout);
gd = new GridData(); gd = new GridData();
gd.horizontalSpan = 2; gd.horizontalSpan = 2;
optionComp.setLayoutData(gd); optionComp.setLayoutData(gd);
fStopInMain = new Button(optionComp, SWT.CHECK); fStopInMain = new Button(optionComp, SWT.CHECK);
fStopInMain.setText(LaunchUIPlugin.getResourceString("CDebuggerTab.Stop_at_main_on_startup")); //$NON-NLS-1$ fStopInMain.setText(LaunchUIPlugin.getResourceString("CDebuggerTab.Stop_at_main_on_startup")); //$NON-NLS-1$
fStopInMain.addSelectionListener(new SelectionAdapter() { fStopInMain.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
fVarBookKeeping = new Button(optionComp, SWT.CHECK); fVarBookKeeping = new Button(optionComp, SWT.CHECK);
fVarBookKeeping.setText(LaunchUIPlugin.getResourceString("CDebuggerTab.Automatically_track_values_of_variables")); //$NON-NLS-1$ fVarBookKeeping.setText(LaunchUIPlugin.getResourceString("CDebuggerTab.Automatically_track_values_of_variables")); //$NON-NLS-1$
fVarBookKeeping.addSelectionListener(new SelectionAdapter() { fVarBookKeeping.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
Group debuggerGroup = new Group(comp, SWT.SHADOW_ETCHED_IN); Group debuggerGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
debuggerGroup.setText(LaunchUIPlugin.getResourceString("CDebuggerTab.Debugger_Options")); //$NON-NLS-1$ debuggerGroup.setText(LaunchUIPlugin.getResourceString("CDebuggerTab.Debugger_Options")); //$NON-NLS-1$
setDynamicTabHolder(debuggerGroup); setDynamicTabHolder(debuggerGroup);
@ -138,6 +140,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
fDCombo.removeAll(); fDCombo.removeAll();
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations(); debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
Arrays.sort(debugConfigs, new Comparator() { Arrays.sort(debugConfigs, new Comparator() {
public int compare(Object o1, Object o2) { public int compare(Object o1, Object o2) {
ICDebugConfiguration ic1 = (ICDebugConfiguration) o1; ICDebugConfiguration ic1 = (ICDebugConfiguration) o1;
ICDebugConfiguration ic2 = (ICDebugConfiguration) o2; ICDebugConfiguration ic2 = (ICDebugConfiguration) o2;
@ -148,17 +151,17 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
int selndx = -1; int selndx = -1;
for (int i = 0; i < debugConfigs.length; i++) { for (int i = 0; i < debugConfigs.length; i++) {
if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN) if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)
|| debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) { || debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
String debuggerPlatform = debugConfigs[i].getPlatform(); String debuggerPlatform = debugConfigs[i].getPlatform();
boolean isNative = configPlatform.equals(BootLoader.getOS()); boolean isNative = configPlatform.equals(Platform.getOS());
if (debuggerPlatform.equalsIgnoreCase(configPlatform) if (debuggerPlatform.equalsIgnoreCase(configPlatform)
|| (isNative && debuggerPlatform.equalsIgnoreCase(ICDebugConfiguration.PLATFORM_NATIVE))) { || (isNative && debuggerPlatform.equalsIgnoreCase(ICDebugConfiguration.PLATFORM_NATIVE))) {
if (debugConfigs[i].supportsCPU(programCPU)) { if (debugConfigs[i].supportsCPU(programCPU)) {
fDCombo.add(debugConfigs[i].getName()); fDCombo.add(debugConfigs[i].getName());
fDCombo.setData(Integer.toString(x), debugConfigs[i]); fDCombo.setData(Integer.toString(x), debugConfigs[i]);
// select first exact matching debugger for platform or requested selection // select first exact matching debugger for platform or requested selection
if ((selndx == -1 && debuggerPlatform.equalsIgnoreCase(configPlatform)) if ((selndx == -1 && debuggerPlatform.equalsIgnoreCase(configPlatform))
|| selection.equals(debugConfigs[i].getID())) { || selection.equals(debugConfigs[i].getID())) {
selndx = x; selndx = x;
} }
x++; x++;
@ -185,9 +188,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
fAttachButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)); fAttachButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH));
fAttachButton.setSelection(false); fAttachButton.setSelection(false);
try { try {
String mode = String mode = getLaunchConfiguration().getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
getLaunchConfiguration().getAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN) && fRunButton.isEnabled()) { if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN) && fRunButton.isEnabled()) {
fRunButton.setSelection(true); fRunButton.setSelection(true);
@ -209,21 +210,27 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
super.setDefaults(config); super.setDefaults(config);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, DEFAULT_STOP_AT_MAIN); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, DEFAULT_STOP_AT_MAIN);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false);
config.setAttribute( config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); }
public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
super.activated(workingCopy);
try {
String id = workingCopy.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
if (getDebugConfig() == null || !getDebugConfig().getID().equals(id) || !validateDebuggerConfig(workingCopy)) {
loadDebuggerComboBox(workingCopy, id);
}
} catch (CoreException e) {
}
} }
public void initializeFrom(ILaunchConfiguration config) { public void initializeFrom(ILaunchConfiguration config) {
super.initializeFrom(config); super.initializeFrom(config);
try { try {
String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$ String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
if (getDebugConfig() == null || !getDebugConfig().getID().equals(id)) { loadDebuggerComboBox(config, id);
loadDebuggerComboBox(config, id); String mode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
}
String mode =
config.getAttribute(
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) { if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
fRunButton.setSelection(true); fRunButton.setSelection(true);
@ -247,16 +254,15 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
if (isValid(config)) { if (isValid(config)) {
super.performApply(config); super.performApply(config);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, !fVarBookKeeping.getSelection()); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING,
!fVarBookKeeping.getSelection());
if (fAttachButton.getSelection() == true) { if (fAttachButton.getSelection() == true) {
config.setAttribute( config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
} else { } else {
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection()); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection());
config.setAttribute( config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
} }
} }
} }
@ -293,7 +299,8 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
} }
String debuggerPlatform = debugConfig.getPlatform(); String debuggerPlatform = debugConfig.getPlatform();
boolean isNative = platform.equals(projectPlatform); boolean isNative = platform.equals(projectPlatform);
if (debuggerPlatform.equalsIgnoreCase(projectPlatform) || (isNative && debuggerPlatform.equalsIgnoreCase(ICDebugConfiguration.PLATFORM_NATIVE))) { if (debuggerPlatform.equalsIgnoreCase(projectPlatform)
|| (isNative && debuggerPlatform.equalsIgnoreCase(ICDebugConfiguration.PLATFORM_NATIVE))) {
if (debugConfig.supportsCPU(projectCPU)) { if (debugConfig.supportsCPU(projectCPU)) {
return true; return true;
} }
@ -302,8 +309,8 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
} }
/** /**
* Return the class that implements <code>ILaunchConfigurationTab</code> * Return the class that implements <code>ILaunchConfigurationTab</code> that is registered against the debugger id of the
* that is registered against the debugger id of the currently selected debugger. * currently selected debugger.
*/ */
protected ICDebugConfiguration getConfigForCurrentDebugger() { protected ICDebugConfiguration getConfigForCurrentDebugger() {
int selectedIndex = fDCombo.getSelectionIndex(); int selectedIndex = fDCombo.getSelectionIndex();
@ -317,4 +324,4 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
super.updateLaunchConfigurationDialog(); super.updateLaunchConfigurationDialog();
} }
} }

View file

@ -7,12 +7,12 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
@ -122,7 +122,7 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
} }
protected String getPlatform(ILaunchConfiguration config) { protected String getPlatform(ILaunchConfiguration config) {
String platform = BootLoader.getOS(); String platform = Platform.getOS();
try { try {
return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PLATFORM, platform); return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PLATFORM, platform);
} }

View file

@ -23,16 +23,17 @@ import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.ui.CElementImageDescriptor; import org.eclipse.cdt.ui.CElementImageDescriptor;
import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.cdt.ui.CElementLabelProvider;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
@ -315,16 +316,16 @@ public class CMainTab extends CLaunchConfigurationTab {
dialog.setValidator(new ISelectionStatusValidator() { dialog.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object [] selection) { public IStatus validate(Object [] selection) {
if(selection.length == 0 || !(selection[0] instanceof IFile)) { if(selection.length == 0 || !(selection[0] instanceof IFile)) {
return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_file"), null); //$NON-NLS-1$ return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_file"), null); //$NON-NLS-1$
} else { } else {
try { try {
ICElement celement = cproject.findElement(((IFile)selection[0]).getProjectRelativePath()); ICElement celement = cproject.findElement(((IFile)selection[0]).getProjectRelativePath());
if(celement == null || if(celement == null ||
(celement.getElementType() != ICElement.C_BINARY && celement.getElementType() != ICElement.C_ARCHIVE)) { (celement.getElementType() != ICElement.C_BINARY && celement.getElementType() != ICElement.C_ARCHIVE)) {
return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$ return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
} }
return new Status(IStatus.OK, LaunchUIPlugin.PLUGIN_ID, IStatus.OK, celement.getResource().getName(), null); return new Status(IStatus.OK, LaunchUIPlugin.getUniqueIdentifier(), IStatus.OK, celement.getResource().getName(), null);
} catch(Exception ex) { } catch(Exception ex) {
return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$ return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
} }
@ -421,7 +422,7 @@ public class CMainTab extends CLaunchConfigurationTab {
protected ICProject[] getCProjects() throws CModelException { protected ICProject[] getCProjects() throws CModelException {
ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects(); ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects();
ArrayList list = new ArrayList(cproject.length); ArrayList list = new ArrayList(cproject.length);
boolean isNative = filterPlatform.equals(BootLoader.getOS()); boolean isNative = filterPlatform.equals(Platform.getOS());
for (int i = 0; i < cproject.length; i++) { for (int i = 0; i < cproject.length; i++) {
ICDescriptor cdesciptor = null; ICDescriptor cdesciptor = null;

View file

@ -113,13 +113,22 @@ public class CorefileDebuggerTab extends AbstractCDebuggerTab {
initializingComboBox = false; initializingComboBox = false;
} }
public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
super.activated(workingCopy);
try {
String id = workingCopy.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
if (getDebugConfig() == null || !getDebugConfig().getID().equals(id) || !validateDebuggerConfig(workingCopy)) {
loadDebuggerComboBox(workingCopy, id);
}
} catch (CoreException e) {
}
}
public void initializeFrom(ILaunchConfiguration config) { public void initializeFrom(ILaunchConfiguration config) {
super.initializeFrom(config); super.initializeFrom(config);
try { try {
String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$ String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
if (getDebugConfig() == null || !getDebugConfig().getID().equals(id)) { loadDebuggerComboBox(config, id);
loadDebuggerComboBox(config, id);
}
} catch (CoreException e) { } catch (CoreException e) {
return; return;
} }
@ -165,7 +174,6 @@ public class CorefileDebuggerTab extends AbstractCDebuggerTab {
return true; return true;
} }
} }
setDebugConfig(null);
return false; return false;
} }