diff options
author | David Inglis | 2004-10-18 14:48:50 +0000 |
---|---|---|
committer | David Inglis | 2004-10-18 14:48:50 +0000 |
commit | a192c2f172621fd921dbaebb14ee66fcee4f8f12 (patch) | |
tree | d2ca625499099bc3a77896c02323b0a8741779ca /launch | |
parent | 206203d375007f2d08035af6617503c6b69015d6 (diff) | |
download | org.eclipse.cdt-a192c2f172621fd921dbaebb14ee66fcee4f8f12.tar.gz org.eclipse.cdt-a192c2f172621fd921dbaebb14ee66fcee4f8f12.tar.xz org.eclipse.cdt-a192c2f172621fd921dbaebb14ee66fcee4f8f12.zip |
- Update to new ICDIDebugger interface deprecating old
- Added seperate launch configuration for attaching to pid
Diffstat (limited to 'launch')
23 files changed, 1121 insertions, 822 deletions
diff --git a/launch/org.eclipse.cdt.launch/ChangeLog b/launch/org.eclipse.cdt.launch/ChangeLog index 5feba40be14..47f411bf81e 100644 --- a/launch/org.eclipse.cdt.launch/ChangeLog +++ b/launch/org.eclipse.cdt.launch/ChangeLog @@ -1,3 +1,10 @@ +2004-10-18 David Inglis + + Update to new ICDIDebugger interface deprecating old + Added seperate launch configuration for attaching to pid + + * lots of files changed + 2004-10-17 Alain Magloire Remove deprecated method in CDI adjust the implementation. * src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java diff --git a/launch/org.eclipse.cdt.launch/plugin.properties b/launch/org.eclipse.cdt.launch/plugin.properties index 24aba4dc1f3..bbc700cb5c9 100644 --- a/launch/org.eclipse.cdt.launch/plugin.properties +++ b/launch/org.eclipse.cdt.launch/plugin.properties @@ -11,8 +11,9 @@ pluginName=C/C++ Development Tools Launching Support providerName=Eclipse.org -LocalCDTLaunch.name= C/C++ Local -CoreFileCDTLaunch.name= C/C++ Postmortem debugger +LocalCDTLaunch.name=C/C++ Local Application +LocalAttachCDTLaunch.name=C/C++ Attach to Local Application +CoreFileCDTLaunch.name=C/C++ Postmortem debugger CApplicationShortcut.label=Local C/C++ Application ContextualRunCApplication.label=Run Local C/C++ Application diff --git a/launch/org.eclipse.cdt.launch/plugin.xml b/launch/org.eclipse.cdt.launch/plugin.xml index e55977af88c..52f087748fa 100644 --- a/launch/org.eclipse.cdt.launch/plugin.xml +++ b/launch/org.eclipse.cdt.launch/plugin.xml @@ -32,42 +32,59 @@ point="org.eclipse.debug.core.launchConfigurationTypes"> <launchConfigurationType name="%LocalCDTLaunch.name" - delegate="org.eclipse.cdt.launch.internal.LocalCLaunchConfigurationDelegate" + delegate="org.eclipse.cdt.launch.internal.LocalRunLaunchDelegate" modes="run,debug" public="true" - id="org.eclipse.cdt.launch.localCLaunch"> + id="org.eclipse.cdt.launch.localRunLaunch"> + </launchConfigurationType> + <launchConfigurationType + name="%LocalAttachCDTLaunch.name" + delegate="org.eclipse.cdt.launch.internal.LocalAttachLaunchDelegate" + modes="debug" + public="true" + id="org.eclipse.cdt.launch.localAttachLaunch"> </launchConfigurationType> <launchConfigurationType name="%CoreFileCDTLaunch.name" delegate="org.eclipse.cdt.launch.internal.CoreFileLaunchDelegate" modes="debug" public="true" - id="org.eclipse.cdt.launch.coreFileCLaunch"> + id="org.eclipse.cdt.launch.coreFileLaunch"> </launchConfigurationType> </extension> <extension point="org.eclipse.debug.ui.launchConfigurationTypeImages"> <launchConfigurationTypeImage icon="icons/c_app.gif" - configTypeID="org.eclipse.cdt.launch.localCLaunch" - id="org.eclipse.cdt.launch.localCLaunchImage"> + configTypeID="org.eclipse.cdt.launch.localRunLaunch" + id="org.eclipse.cdt.launch.localRunLaunchImage"> </launchConfigurationTypeImage> <launchConfigurationTypeImage icon="icons/c_app.gif" - configTypeID="org.eclipse.cdt.launch.coreFileCLaunch" - id="org.eclipse.cdt.launch.coreFileCLaunchImage"> + configTypeID="org.eclipse.cdt.launch.localAttachLaunch" + id="org.eclipse.cdt.launch.localAttachLaunchImage"> + </launchConfigurationTypeImage> + <launchConfigurationTypeImage + icon="icons/c_app.gif" + configTypeID="org.eclipse.cdt.launch.coreFileLaunch" + id="org.eclipse.cdt.launch.coreFileLaunchImage"> </launchConfigurationTypeImage> </extension> <extension point="org.eclipse.debug.ui.launchConfigurationTabGroups"> <launchConfigurationTabGroup - type="org.eclipse.cdt.launch.localCLaunch" - class="org.eclipse.cdt.launch.internal.ui.LocalCLaunchConfigurationTabGroup" - id="org.eclipse.cdt.launch.localClaunchConfigurationTabGroup"> + type="org.eclipse.cdt.launch.localRunLaunch" + class="org.eclipse.cdt.launch.internal.ui.LocalRunLaunchConfigurationTabGroup" + id="org.eclipse.cdt.launch.localRunLaunchTabGroup"> + </launchConfigurationTabGroup> + <launchConfigurationTabGroup + type="org.eclipse.cdt.launch.localAttachLaunch" + class="org.eclipse.cdt.launch.internal.ui.LocalAttachLaunchConfigurationTabGroup" + id="org.eclipse.cdt.launch.localAttachLaunchTabGroup"> </launchConfigurationTabGroup> <launchConfigurationTabGroup - type="org.eclipse.cdt.launch.coreFileCLaunch" - class="org.eclipse.cdt.launch.internal.ui.CoreFileCLaunchConfigurationTabGroup" + type="org.eclipse.cdt.launch.coreFileLaunch" + class="org.eclipse.cdt.launch.internal.ui.CoreFileLaunchConfigurationTabGroup" id="org.eclipse.cdt.launch.voreFileCLaunchTabGroup"> </launchConfigurationTabGroup> </extension> diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java index c57d93881c6..6fdeb7787d8 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java @@ -1,17 +1,16 @@ -/********************************************************************** - * Copyright (c) 2002 - 2004 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html +/******************************************************************************* + * Copyright (c) 2002 - 2004 QNX Software Systems and others. All rights + * reserved. This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 which accompanies this + * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html * - * Contributors: - * QNX Software Systems - Initial API and implementation -***********************************************************************/ + * Contributors: QNX Software Systems - Initial API and implementation + ******************************************************************************/ package org.eclipse.cdt.launch; import java.io.File; import java.io.FileNotFoundException; +import java.io.IOException; import java.text.DateFormat; import java.text.MessageFormat; import java.util.ArrayList; @@ -26,12 +25,16 @@ import java.util.Properties; import java.util.Map.Entry; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.IBinaryParser; +import org.eclipse.cdt.core.ICExtensionReference; +import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable; import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.utils.spawner.EnvironmentReader; import org.eclipse.core.resources.IContainer; @@ -306,6 +309,24 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null); } + public static IPath getProgramPath(ILaunchConfiguration configuration) throws CoreException { + String path = getProgramName(configuration); + if (path == null) { + return null; + } + return new Path(path); + } + + /** + * @param launch + * @param config + * @throws CoreException + * @deprecated + */ + protected void setSourceLocator(ILaunch launch, ILaunchConfiguration config) throws CoreException { + setDefaultSourceLocator(launch, config); + } + /** * 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 @@ -318,7 +339,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat * @exception CoreException * if unable to set the source locator */ - protected void setSourceLocator(ILaunch launch, ILaunchConfiguration configuration) throws CoreException { + protected void setDefaultSourceLocator(ILaunch launch, ILaunchConfiguration configuration) throws CoreException { // set default source locator if none specified if (launch.getSourceLocator() == null) { IPersistableSourceLocator sourceLocator; @@ -326,7 +347,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat if (id == null) { ICProject cProject = getCProject(configuration); if (cProject == null) { - abort(LaunchUIPlugin.getResourceString("Launch.common.Project_does_not_exist"), null, //$NON-NLS-1$ + abort(LaunchMessages.getString("Launch.common.Project_does_not_exist"), null, //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); } sourceLocator = CDebugUIPlugin.createDefaultSourceLocator(); @@ -375,11 +396,13 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat ICDebugConfiguration dbgCfg = null; try { dbgCfg = CDebugCorePlugin.getDefault().getDebugConfiguration( - config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "")); //$NON-NLS-1$ + config.getAttribute( + ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, + "")); //$NON-NLS-1$ } catch (CoreException e) { IStatus status = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED, - LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Debugger_not_installed"), //$NON-NLS-1$ + LaunchMessages.getString("AbstractCLaunchDelegate.Debugger_not_installed"), //$NON-NLS-1$ e); IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status); @@ -411,45 +434,78 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat String format = "{0} ({1})"; //$NON-NLS-1$ String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis())); return MessageFormat.format(format, new String[]{ - LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Debugger_Process"), timestamp}); //$NON-NLS-1$ + LaunchMessages.getString("AbstractCLaunchDelegate.Debugger_Process"), timestamp}); //$NON-NLS-1$ + } + + + /** + * @param config + * @return + * @throws CoreException + * @deprecated + */ + protected IFile getProgramFile(ILaunchConfiguration config) throws CoreException { + ICProject cproject = verifyCProject(config); + String fileName = getProgramName(config); + if (fileName == null) { + abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM); + } + + IFile programPath = ((IProject)cproject.getResource()).getFile(fileName); + if (programPath == null || !programPath.exists() || !programPath.getLocation().toFile().exists()) { + abort( + LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_does_not_exist"), //$NON-NLS-1$ + new FileNotFoundException( + LaunchMessages.getFormattedString( + "AbstractCLaunchDelegate.PROGRAM_PATH_not_found", programPath.getLocation().toOSString())), //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST); + } + return programPath; } protected ICProject verifyCProject(ILaunchConfiguration config) throws CoreException { String name = getProjectName(config); if (name == null) { - abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.C_Project_not_specified"), null, //$NON-NLS-1$ + abort(LaunchMessages.getString("AbstractCLaunchDelegate.C_Project_not_specified"), null, //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT); } ICProject cproject = getCProject(config); if (cproject == null) { IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(name); if (!proj.exists()) { - abort(LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.Project_NAME_does_not_exist", name), null, //$NON-NLS-1$ + abort( + LaunchMessages.getFormattedString("AbstractCLaunchDelegate.Project_NAME_does_not_exist", name), null, //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); } else if (!proj.isOpen()) { - abort(LaunchUIPlugin.getFormattedResourceString("AbstractCLaunchDelegate.Project_NAME_is_closed", name), null, //$NON-NLS-1$ + abort(LaunchMessages.getFormattedString("AbstractCLaunchDelegate.Project_NAME_is_closed", name), null, //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); } - abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Not_a_C_CPP_project"), null, //$NON-NLS-1$ + abort(LaunchMessages.getString("AbstractCLaunchDelegate.Not_a_C_CPP_project"), null, //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); } return cproject; } - protected IFile getProgramFile(ILaunchConfiguration config) throws CoreException { + protected IPath verifyProgramPath(ILaunchConfiguration config) throws CoreException { ICProject cproject = verifyCProject(config); - String fileName = getProgramName(config); - if (fileName == null) { - abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$ + IPath programPath = getProgramPath(config); + if (programPath == null) { + abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM); } - - IFile programPath = ((IProject)cproject.getResource()).getFile(fileName); - if (programPath == null || !programPath.exists() || !programPath.getLocation().toFile().exists()) { - 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$ + if (!programPath.isAbsolute()) { + IFile wsProgramPath = cproject.getProject().getFile(programPath); + programPath = wsProgramPath.getLocation(); + } + if (!programPath.toFile().exists()) { + abort( + LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_does_not_exist"), //$NON-NLS-1$ + new FileNotFoundException( + LaunchMessages.getFormattedString( + "AbstractCLaunchDelegate.PROGRAM_PATH_not_found", programPath.toOSString())), //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST); + } return programPath; } @@ -485,18 +541,22 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat if (dir.isDirectory()) { return dir; } - 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$ + abort( + LaunchMessages.getString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$ + new FileNotFoundException( + LaunchMessages.getFormattedString( + "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); if (res instanceof IContainer && res.exists()) { return res.getLocation().toFile(); } - abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$ - new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString( - "AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist", path.toOSString())), //$NON-NLS-1$ + abort( + LaunchMessages.getString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$ + new FileNotFoundException( + LaunchMessages.getFormattedString( + "AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist", path.toOSString())), //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST); } } @@ -669,16 +729,16 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat 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); + monitor.beginTask(LaunchMessages.getString("AbstractCLaunchDelegate.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$ + monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.building") + proj.getName()); //$NON-NLS-1$ proj.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); } - monitor.subTask(LaunchUIPlugin.getResourceString("AbstractLaunchConfigurationDelegate.building") + project.getName()); //$NON-NLS-1$ + monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.building") + project.getName()); //$NON-NLS-1$ project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); } monitor.done(); @@ -701,15 +761,15 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat try { boolean continueLaunch = true; if (orderedProjects != null) { - monitor.beginTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.searching_for_errors"), //$NON-NLS-1$ - orderedProjects.size() + 1); + monitor.beginTask(LaunchMessages.getString("AbstractCLaunchDelegate.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$ + monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.searching_for_errors_in") //$NON-NLS-1$ + proj.getName()); compileErrorsInProjs = existsErrors(proj); if (compileErrorsInProjs) { @@ -719,7 +779,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat //check current project, if prerequite projects were ok if (!compileErrorsInProjs) { - monitor.subTask(LaunchUIPlugin.getResourceString("AbstractCLaunchConfigurationDelegate.searching_for_errors_in") //$NON-NLS-1$ + monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.searching_for_errors_in") //$NON-NLS-1$ + project.getName()); compileErrorsInProjs = existsErrors(project); } @@ -768,7 +828,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat 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$ + monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.20")); //$NON-NLS-1$ } orderedProjects = null; ICProject cProject = getCProject(configuration); @@ -782,4 +842,31 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat return super.preLaunchCheck(configuration, mode, monitor); } + /** + * @param project + * @param exePath + * @return + * @throws CoreException + */ + protected IBinaryExecutable createBinary(ICProject project, IPath exePath) throws CoreException { + ICExtensionReference[] parserRef = CCorePlugin.getDefault().getBinaryParserExtensions(project.getProject()); + for (int i = 0; i < parserRef.length; i++) { + try { + IBinaryParser parser = (IBinaryParser)parserRef[i].createExtension(); + IBinaryExecutable exe = (IBinaryExecutable)parser.getBinary(exePath); + if (exe != null) { + return exe; + } + } catch (ClassCastException e) { + } catch (IOException e) { + } + } + IBinaryParser parser = CCorePlugin.getDefault().getDefaultBinaryParser(); + try { + return (IBinaryExecutable)parser.getBinary(exePath); + } catch (IOException e) { + } + return null; + } + }
\ No newline at end of file diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java index c1e8e813c43..5ed40a2ee36 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java @@ -24,11 +24,13 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.launch.AbstractCLaunchDelegate; +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.SubProgressMonitor; @@ -73,7 +75,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut { config.launch(mode, null); } } catch (CoreException e) { - LaunchUIPlugin.errorDialog(LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.LaunchFailed"), e.getStatus()); //$NON-NLS-1$ + LaunchUIPlugin.errorDialog(LaunchMessages.getString("CApplicationLaunchShortcut.LaunchFailed"), e.getStatus()); //$NON-NLS-1$ } } @@ -91,10 +93,10 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut { candidateConfigs = new ArrayList(configs.length); for (int i = 0; i < configs.length; i++) { ILaunchConfiguration config = configs[i]; - String programName = AbstractCLaunchDelegate.getProgramName(config); + IPath programPath = AbstractCLaunchDelegate.getProgramPath(config); String projectName = AbstractCLaunchDelegate.getProjectName(config); - String name = bin.getResource().getProjectRelativePath().toString(); - if (programName != null && programName.equals(name)) { + IPath name = bin.getResource().getProjectRelativePath(); + if (programPath != null && programPath.equals(name)) { if (projectName != null && projectName.equals(bin.getCProject().getProject().getName())) { candidateConfigs.add(config); } @@ -228,16 +230,16 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut { } protected String getDebugConfigDialogTitleString(ICDebugConfiguration [] configList, String mode) { - return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.LaunchDebugConfigSelection"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.LaunchDebugConfigSelection"); //$NON-NLS-1$ } protected String getDebugConfigDialogMessageString(ICDebugConfiguration [] configList, String mode) { if (mode.equals(ILaunchManager.DEBUG_MODE)) { - return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.ChooseConfigToDebug"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseConfigToDebug"); //$NON-NLS-1$ } else if (mode.equals(ILaunchManager.RUN_MODE)) { - return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.ChooseConfigToRun"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseConfigToRun"); //$NON-NLS-1$ } - return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Invalid_launch_mode_1"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_1"); //$NON-NLS-1$ } @@ -262,16 +264,16 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut { } protected String getLaunchSelectionDialogTitleString(List configList, String mode) { - return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.LaunchConfigSelection"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.LaunchConfigSelection"); //$NON-NLS-1$ } protected String getLaunchSelectionDialogMessageString(List binList, String mode) { if (mode.equals(ILaunchManager.DEBUG_MODE)) { - return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.ChooseLaunchConfigToDebug"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToDebug"); //$NON-NLS-1$ } else if (mode.equals(ILaunchManager.RUN_MODE)) { - return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.ChooseLaunchConfigToRun"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToRun"); //$NON-NLS-1$ } - return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Invalid_launch_mode_2"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_2"); //$NON-NLS-1$ } /** @@ -310,8 +312,8 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut { dialog.setElements(binList.toArray()); dialog.setTitle(getBinarySelectionDialogTitleString(binList, mode)); //$NON-NLS-1$ dialog.setMessage(getBinarySelectionDialogMessageString(binList, mode)); //$NON-NLS-1$ - dialog.setUpperListLabel(LaunchUIPlugin.getResourceString("Launch.common.BinariesColon")); //$NON-NLS-1$ - dialog.setLowerListLabel(LaunchUIPlugin.getResourceString("Launch.common.QualifierColon")); //$NON-NLS-1$ + dialog.setUpperListLabel(LaunchMessages.getString("Launch.common.BinariesColon")); //$NON-NLS-1$ + dialog.setLowerListLabel(LaunchMessages.getString("Launch.common.QualifierColon")); //$NON-NLS-1$ dialog.setMultipleSelection(false); if (dialog.open() == Window.OK) { return (IBinary) dialog.getFirstResult(); @@ -321,16 +323,16 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut { } protected String getBinarySelectionDialogTitleString(List binList, String mode) { - return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.CLocalApplication"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.CLocalApplication"); //$NON-NLS-1$ } protected String getBinarySelectionDialogMessageString(List binList, String mode) { if (mode.equals(ILaunchManager.DEBUG_MODE)) { - return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.ChooseLocalAppToDebug"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToDebug"); //$NON-NLS-1$ } else if (mode.equals(ILaunchManager.RUN_MODE)) { - return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.ChooseLocalAppToRun"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToRun"); //$NON-NLS-1$ } - return LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Invalid_launch_mode_3"); //$NON-NLS-1$ + return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_3"); //$NON-NLS-1$ } /** @@ -386,12 +388,12 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut { } catch (InterruptedException e) { return; } catch (InvocationTargetException e) { - MessageDialog.openError(getShell(), LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Application_Launcher"), e.getMessage()); //$NON-NLS-1$ + MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), e.getMessage()); //$NON-NLS-1$ return; } int count = results.size(); if (count == 0) { - MessageDialog.openError(getShell(), LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Application_Launcher"), LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Launch_failed_no_binaries")); //$NON-NLS-1$ //$NON-NLS-2$ + MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_binaries")); //$NON-NLS-1$ //$NON-NLS-2$ } else if (count > 1) { bin = chooseBinary(results, mode); } else { @@ -402,7 +404,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut { launch(bin, mode); } } else { - MessageDialog.openError(getShell(), LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Application_Launcher"), LaunchUIPlugin.getResourceString("CApplicationLaunchShortcut.Launch_failed_no_project_selected")); //$NON-NLS-1$ //$NON-NLS-2$ + MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_project_selected")); //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java index ba6ed607f6d..43d490a5d90 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java @@ -1,15 +1,14 @@ -/********************************************************************** - * Copyright (c) 2002 - 2004 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html +/******************************************************************************* + * Copyright (c) 2002 - 2004 QNX Software Systems and others. All rights + * reserved. This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 which accompanies this + * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html * - * Contributors: - * QNX Software Systems - Initial API and implementation -***********************************************************************/ + * Contributors: QNX Software Systems - Initial API and implementation + ******************************************************************************/ package org.eclipse.cdt.launch.internal; +import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; @@ -18,8 +17,8 @@ import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDISession; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.launch.AbstractCLaunchDelegate; +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; -import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -27,9 +26,11 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.model.IProcess; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; @@ -42,65 +43,75 @@ public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate { if (monitor == null) { monitor = new NullProgressMonitor(); } - - monitor.beginTask(LaunchUIPlugin.getResourceString("CoreFileLaunchDelegate.Launching_postmortem_debugger"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$ + monitor.beginTask(LaunchMessages.getString("CoreFileLaunchDelegate.Launching_postmortem_debugger"), 10); //$NON-NLS-1$ // check for cancellation if (monitor.isCanceled()) { return; } - IFile exeFile = getProgramFile(config); + try { + monitor.worked(1); + IPath exePath = verifyProgramPath(config); + ICProject project = verifyCProject(config); + IBinaryExecutable exeFile = createBinary(project, exePath); - ICDebugConfiguration debugConfig = getDebugConfig(config); - ICDISession dsession = null; - ICProject cproject = getCProject(config); + ICDebugConfiguration debugConfig = getDebugConfig(config); + ICDISession dsession = null; + ICProject cproject = getCProject(config); - IPath corefile = getCoreFilePath((IProject) cproject.getResource()); - if (corefile == null) { - cancel(LaunchUIPlugin.getResourceString("CoreFileLaunchDelegate.No_Corefile_selected"), ICDTLaunchConfigurationConstants.ERR_NO_COREFILE); //$NON-NLS-1$ - } - Process debugger = null; - IProcess debuggerProcess = null; - try { - dsession = debugConfig.getDebugger().createCoreSession(config, exeFile, corefile); - debugger = dsession.getSessionProcess(); - } catch (CDIException e) { - if (dsession != null) { + String path = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, (String)null); + IPath corefile; + if (path == null) { + corefile = promptForCoreFilePath((IProject)cproject.getResource()); + if (corefile == null) { + cancel(LaunchMessages.getString("CoreFileLaunchDelegate.No_Corefile_selected"), //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_NO_COREFILE); + } + ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, corefile.toString()); + launch(wc, mode, launch, new SubProgressMonitor(monitor, 9)); + return; + } + corefile = new Path(path); + dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile, new SubProgressMonitor(monitor, 8)); + try { + // set the source locator + setDefaultSourceLocator(launch, config); + ICDITarget[] targets = dsession.getTargets(); + for (int i = 0; i < targets.length; i++) { + Process process = targets[i].getProcess(); + IProcess iprocess = null; + if (process != null) { + iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString())); + } + CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i], renderTargetLabel(debugConfig), iprocess, + exeFile, false, false, false); + } + } catch (CoreException e) { try { dsession.terminate(); - } catch (CDIException ex) { - // ignore + } catch (CDIException cdi) { } + throw e; } - abort(LaunchUIPlugin.getResourceString("CoreFileLaunchDelegate.Failed_Launching_CDI_Debugger"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$ - } - if ( debugger != null ) { - debuggerProcess = DebugPlugin.newProcess(launch, debugger, renderDebuggerProcessLabel()); - } - // set the source locator - setSourceLocator(launch, config); - ICDITarget[] dTargets = dsession.getTargets(); - for (int i = 0; i < dTargets.length; ++i) { - CDIDebugModel.newCoreFileDebugTarget( - launch, - dTargets[i], - renderTargetLabel(debugConfig), - debuggerProcess, - exeFile); + } finally { + monitor.done(); } - monitor.done(); + } - protected IPath getCoreFilePath(final IProject project) throws CoreException { + protected IPath promptForCoreFilePath(final IProject project) throws CoreException { final Shell shell = LaunchUIPlugin.getShell(); - final String res[] = { null }; + final String res[] = {null}; if (shell == null) { - abort(LaunchUIPlugin.getResourceString("CoreFileLaunchDelegate.No_Shell_available_in_Launch"), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$ + abort(LaunchMessages.getString("CoreFileLaunchDelegate.No_Shell_available_in_Launch"), null, //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); } Display display = shell.getDisplay(); display.syncExec(new Runnable() { + public void run() { FileDialog dialog = new FileDialog(shell); - dialog.setText(LaunchUIPlugin.getResourceString("CoreFileLaunchDelegate.Select_Corefile")); //$NON-NLS-1$ + dialog.setText(LaunchMessages.getString("CoreFileLaunchDelegate.Select_Corefile")); //$NON-NLS-1$ String initPath = null; try { @@ -123,4 +134,14 @@ public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate { public String getPluginID() { return LaunchUIPlugin.getUniqueIdentifier(); } -} + + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.launch.AbstractCLaunchConfigurationDelegate#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 { + return true; // no pre launch check for core file + } +}
\ No newline at end of file diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java new file mode 100644 index 00000000000..c3f2fd2620e --- /dev/null +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java @@ -0,0 +1,197 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Common Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: QNX Software Systems - initial API and implementation + ******************************************************************************/ +package org.eclipse.cdt.launch.internal; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.IProcessInfo; +import org.eclipse.cdt.core.IProcessList; +import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.debug.core.CDIDebugModel; +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.debug.core.ICDebugConfiguration; +import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.ICDISession; +import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; +import org.eclipse.cdt.launch.AbstractCLaunchDelegate; +import org.eclipse.cdt.launch.internal.ui.LaunchImages; +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; +import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.dialogs.TwoPaneElementSelector; + +public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate { + + /* + * (non-Javadoc) + * + * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, + * java.lang.String, org.eclipse.debug.core.ILaunch, + * org.eclipse.core.runtime.IProgressMonitor) + */ + public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { + if (monitor == null) { + monitor = new NullProgressMonitor(); + } + + monitor.beginTask(LaunchMessages.getString("LocalAttachLaunchDelegate.Attaching_to_Local_C_Application"), 10); //$NON-NLS-1$ + // check for cancellation + if (monitor.isCanceled()) { + return; + } + try { + monitor.worked(1); + IPath exePath = verifyProgramPath(config); + ICProject project = verifyCProject(config); + IBinaryExecutable exeFile = createBinary(project, exePath); + + if (mode.equals(ILaunchManager.DEBUG_MODE)) { + ICDebugConfiguration debugConfig = getDebugConfig(config); + ICDISession dsession = null; + String debugMode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, + ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); + if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) { + //It may be that we have already been provided with a + // process id + if (config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID, -1) == -1) { + int pid = promptForProcessID(config); + if (pid == -1) { + cancel(LaunchMessages.getString("LocalAttachLaunchDelegate.No_Process_ID_selected"), //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID); + } + ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID, pid); + wc.launch(mode, new SubProgressMonitor(monitor, 9)); + } else { + dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile, + new SubProgressMonitor(monitor, 8)); + try { + // set the default source locator if required + setDefaultSourceLocator(launch, config); + ICDITarget[] targets = dsession.getTargets(); + for (int i = 0; i < targets.length; i++) { + CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i], + renderTargetLabel(debugConfig), null, exeFile, true, true); + } + } catch (CoreException e) { + try { + dsession.terminate(); + } catch (CDIException ex) { + // ignore + } + throw e; + } + } + } + } + } finally { + monitor.done(); + } + } + + protected int promptForProcessID(ILaunchConfiguration config) throws CoreException { + final Shell shell = LaunchUIPlugin.getShell(); + final int pidResult[] = {-1}; + if (shell == null) { + abort(LaunchMessages.getString("LocalAttachLaunchDelegate.No_Shell_available_in_Launch"), null, //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); + } + Display display = shell.getDisplay(); + display.syncExec(new Runnable() { + + public void run() { + ILabelProvider provider = new LabelProvider() { + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) + */ + public String getText(Object element) { + IProcessInfo info = (IProcessInfo)element; + IPath path = new Path(info.getName()); + return path.lastSegment() + " - " + info.getPid(); //$NON-NLS-1$ + } + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) + */ + public Image getImage(Object element) { + return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC); + } + }; + ILabelProvider qprovider = new LabelProvider() { + + public String getText(Object element) { + IProcessInfo info = (IProcessInfo)element; + return info.getName(); + } + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) + */ + public Image getImage(Object element) { + return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC); + } + }; + TwoPaneElementSelector dialog = new TwoPaneElementSelector(shell, provider, qprovider); + dialog.setTitle(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process")); //$NON-NLS-1$ + dialog.setMessage(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$ + IProcessList plist = null; + try { + plist = CCorePlugin.getDefault().getProcessList(); + } catch (CoreException e) { + LaunchUIPlugin.errorDialog( + LaunchMessages.getString("LocalAttachLaunchDelegate.CDT_Launch_Error"), e.getStatus()); //$NON-NLS-1$ + } + if (plist == null) { + MessageDialog.openError( + shell, + LaunchMessages.getString("LocalAttachLaunchDelegate.CDT_Launch_Error"), LaunchMessages.getString("LocalAttachLaunchDelegate.Platform_cannot_list_processes")); //$NON-NLS-1$ //$NON-NLS-2$ + return; + } + dialog.setElements(plist.getProcessList()); + if (dialog.open() == Window.OK) { + IProcessInfo info = (IProcessInfo)dialog.getFirstResult(); + if (info != null) { + pidResult[0] = info.getPid(); + } + } + } + }); + return pidResult[0]; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.launch.AbstractCLaunchConfigurationDelegate#getPluginID() + */ + protected String getPluginID() { + return LaunchUIPlugin.getUniqueIdentifier(); + } +}
\ No newline at end of file diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java deleted file mode 100644 index ca54c5eca5e..00000000000 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalCLaunchConfigurationDelegate.java +++ /dev/null @@ -1,291 +0,0 @@ -/********************************************************************** - * Copyright (c) 2002 - 2004 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation -***********************************************************************/ -package org.eclipse.cdt.launch.internal; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.Properties; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.IProcessInfo; -import org.eclipse.cdt.core.IProcessList; -import org.eclipse.cdt.debug.core.CDIDebugModel; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.cdt.debug.core.ICDebugConfiguration; -import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions; -import org.eclipse.cdt.debug.core.cdi.ICDISession; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; -import org.eclipse.cdt.launch.AbstractCLaunchDelegate; -import org.eclipse.cdt.launch.internal.ui.LaunchImages; -import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; -import org.eclipse.cdt.utils.spawner.ProcessFactory; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.debug.core.IStatusHandler; -import org.eclipse.debug.core.model.IProcess; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.TwoPaneElementSelector; - -public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate { - - public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { - if (monitor == null) { - monitor = new NullProgressMonitor(); - } - - monitor.beginTask(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Launching_Local_C_Application"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$ - // check for cancellation - if (monitor.isCanceled()) { - return; - } - IFile exeFile = getProgramFile(config); - String arguments[] = getProgramArgumentsArray(config); - ArrayList command = new ArrayList(1 + arguments.length); - command.add(exeFile.getLocation().toOSString()); - command.addAll(Arrays.asList(arguments)); - String[] commandArray = (String[]) command.toArray(new String[command.size()]); - - // set the default source locator if required - setSourceLocator(launch, config); - - if (mode.equals(ILaunchManager.DEBUG_MODE)) { - IProcess debuggerProcess = null; - Process debugger; - ICDebugConfiguration debugConfig = getDebugConfig(config); - ICDISession dsession = null; - try { - String debugMode = - config.getAttribute( - ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, - ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); - if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) { - dsession = debugConfig.getDebugger().createLaunchSession(config, exeFile); - ICDIRuntimeOptions opt = dsession.getRuntimeOptions(); - opt.setArguments(getProgramArgumentsArray(config)); - File wd = getWorkingDirectory(config); - if (wd != null) { - opt.setWorkingDirectory(wd.getAbsolutePath()); - } - opt.setEnvironment(expandEnvironment(config)); - debugger = dsession.getSessionProcess(); - if ( debugger != null ) { - debuggerProcess = DebugPlugin.newProcess(launch, debugger, renderDebuggerProcessLabel()); - } - ICDITarget[] dtargets = dsession.getTargets(); - for (int i = 0; i < dtargets.length; ++i) { - ICDITarget dtarget = dtargets[i]; - Process process = dtarget.getProcess(); - IProcess iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(commandArray[0])); - boolean stopInMain = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false); - CDIDebugModel.newDebugTarget( - launch, - dtarget, - renderTargetLabel(debugConfig), - iprocess, - debuggerProcess, - exeFile, - true, - false, - stopInMain); - } - - } else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) { - int pid = getProcessID(); - if (pid == -1) { - cancel(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.No_Process_ID_selected"), ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID); //$NON-NLS-1$ - } - dsession = debugConfig.getDebugger().createAttachSession(config, exeFile, pid); - debugger = dsession.getSessionProcess(); - if ( debugger != null ) { - debuggerProcess = DebugPlugin.newProcess(launch, debugger, renderDebuggerProcessLabel()); - launch.removeProcess(debuggerProcess); - } - ICDITarget[] dTargets = dsession.getTargets(); - for (int i = 0; i < dTargets.length; ++i) { - CDIDebugModel.newAttachDebugTarget( - launch, - dTargets[i], - renderTargetLabel(debugConfig), - debuggerProcess, - exeFile); - } - } - } catch (CDIException e) { - if (dsession != null) { - try { - dsession.terminate(); - } catch (CDIException ex) { - // ignore - } - } - abort(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Failed_Launching_CDI_Debugger"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$ - } - } else { - File wd = getWorkingDirectory(config); - if (wd == null) { - wd = new File(System.getProperty("user.home", ".")); //NON-NLS-1; //$NON-NLS-1$//$NON-NLS-2$ - } - Process process = exec(commandArray, getEnvironmentProperty(config), wd); - DebugPlugin.newProcess(launch, process, renderProcessLabel(commandArray[0])); - } - - monitor.done(); - - } - - private int getProcessID() throws CoreException { - final Shell shell = LaunchUIPlugin.getShell(); - final int pid[] = { -1 }; - if (shell == null) { - abort(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.No_Shell_available_in_Launch"), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$ - } - Display display = shell.getDisplay(); - display.syncExec(new Runnable() { - public void run() { - ILabelProvider provider = new LabelProvider() { - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) - */ - public String getText(Object element) { - IProcessInfo info = (IProcessInfo)element; - IPath path = new Path(info.getName()); - return path.lastSegment() + " - " + info.getPid(); //$NON-NLS-1$ - } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) - */ - public Image getImage(Object element) { - return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC); - } - }; - ILabelProvider qprovider = new LabelProvider() { - public String getText(Object element) { - IProcessInfo info = (IProcessInfo) element; - return info.getName(); - } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) - */ - public Image getImage(Object element) { - return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC); - } - }; - TwoPaneElementSelector dialog = new TwoPaneElementSelector(shell, provider, qprovider); - dialog.setTitle(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Select_Process")); //$NON-NLS-1$ - dialog.setMessage(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$ - IProcessList plist = null; - try { - plist = CCorePlugin.getDefault().getProcessList(); - } catch (CoreException e) { - LaunchUIPlugin.errorDialog(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.CDT_Launch_Error"), e.getStatus()); //$NON-NLS-1$ - } - if (plist == null) { - MessageDialog.openError(shell, LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.CDT_Launch_Error"), LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Platform_cannot_list_processes")); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - dialog.setElements(plist.getProcessList()); - if (dialog.open() == Window.OK) { - IProcessInfo info = (IProcessInfo) dialog.getFirstResult(); - if ( info != null ) { - pid[0] = info.getPid(); - } - } - } - }); - return pid[0]; - } - - /** - * Performs a runtime exec on the given command line in the context - * of the specified working directory, and returns - * the resulting process. If the current runtime does not support the - * specification of a working directory, the status handler for error code - * <code>ERR_WORKING_DIRECTORY_NOT_SUPPORTED</code> is queried to see if the - * exec should be re-executed without specifying a working directory. - * - * @param cmdLine the command line - * @param workingDirectory the working directory, or <code>null</code> - * @return the resulting process or <code>null</code> if the exec is - * cancelled - * @see Runtime - */ - protected Process exec(String[] cmdLine, Properties environ, File workingDirectory) throws CoreException { - Process p = null; - Properties props = getDefaultEnvironment(); - props.putAll(expandEnvironment(environ)); - String[] envp = null; - ArrayList envList = new ArrayList(); - Enumeration names = props.propertyNames(); - if (names != null) { - while (names.hasMoreElements()) { - String key = (String) names.nextElement(); - envList.add(key + "=" + props.getProperty(key)); //$NON-NLS-1$ - } - envp = (String[]) envList.toArray(new String[envList.size()]); - } - try { - - if (workingDirectory == null) { - p = ProcessFactory.getFactory().exec(cmdLine, envp); - } else { - p = ProcessFactory.getFactory().exec(cmdLine, envp, workingDirectory); - } - } catch (IOException e) { - if (p != null) { - p.destroy(); - } - abort(LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Error_starting_process"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); //$NON-NLS-1$ - } catch (NoSuchMethodError e) { - //attempting launches on 1.2.* - no ability to set working directory - - IStatus status = - new Status( - IStatus.ERROR, - LaunchUIPlugin.getUniqueIdentifier(), - ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_NOT_SUPPORTED, - LaunchUIPlugin.getResourceString("LocalCLaunchConfigurationDelegate.Does_not_support_working_dir"), //$NON-NLS-1$ - e); - IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status); - - if (handler != null) { - Object result = handler.handleStatus(status, this); - if (result instanceof Boolean && ((Boolean) result).booleanValue()) { - p = exec(cmdLine, environ, null); - } - } - } - return p; - } - - protected String getPluginID() { - return LaunchUIPlugin.getUniqueIdentifier(); - } - -} diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java new file mode 100644 index 00000000000..4c48ba7516d --- /dev/null +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java @@ -0,0 +1,198 @@ +/******************************************************************************* + * Copyright (c) 2002 - 2004 QNX Software Systems and others. All rights + * reserved. This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 which accompanies this + * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: QNX Software Systems - Initial API and implementation + ******************************************************************************/ +package org.eclipse.cdt.launch.internal; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.Properties; + +import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.debug.core.CDIDebugModel; +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.debug.core.ICDebugConfiguration; +import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions; +import org.eclipse.cdt.debug.core.cdi.ICDISession; +import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; +import org.eclipse.cdt.launch.AbstractCLaunchDelegate; +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; +import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.cdt.utils.spawner.ProcessFactory; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.core.IStatusHandler; +import org.eclipse.debug.core.model.IProcess; + +public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate { + + public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { + if (monitor == null) { + monitor = new NullProgressMonitor(); + } + monitor.beginTask(LaunchMessages.getString("LocalRunLaunchDelegate.Launching_Local_C_Application"), 10); //$NON-NLS-1$ + // check for cancellation + if (monitor.isCanceled()) { + return; + } + try { + monitor.worked(1); + IPath exePath = verifyProgramPath(config); + ICProject project = verifyCProject(config); + IBinaryExecutable exeFile = createBinary(project, exePath); + String arguments[] = getProgramArgumentsArray(config); + + // set the default source locator if required + setDefaultSourceLocator(launch, config); + + if (mode.equals(ILaunchManager.DEBUG_MODE)) { + ICDebugConfiguration debugConfig = getDebugConfig(config); + ICDISession dsession = null; + String debugMode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, + ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); + if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) { + dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile, new SubProgressMonitor(monitor, 8)); + try { + ICDIRuntimeOptions opt = dsession.getRuntimeOptions(); + opt.setArguments(arguments); + File wd = getWorkingDirectory(config); + if (wd != null) { + opt.setWorkingDirectory(wd.getAbsolutePath()); + } + opt.setEnvironment(expandEnvironment(config)); + } catch (CDIException e) { + try { + dsession.terminate(); + } catch (CDIException ex) { + // ignore + } + abort(LaunchMessages.getString("LocalRunLaunchDelegate.Failed_setting_runtime_option_though_debugger"), e, //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); + } + monitor.worked(1); + try { + boolean stopInMain = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false); + + ICDITarget[] targets = dsession.getTargets(); + for (int i = 0; i < targets.length; i++) { + Process process = targets[i].getProcess(); + IProcess iprocess = null; + if (process != null) { + iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString())); + } + CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i], renderTargetLabel(debugConfig), + iprocess, exeFile, true, false, stopInMain); + } + } catch (CoreException e) { + try { + dsession.terminate(); + } catch (CDIException e1) { + // ignore + } + throw e; + } + } + } else { + File wd = getWorkingDirectory(config); + if (wd == null) { + wd = new File(System.getProperty("user.home", ".")); //$NON-NLS-1$ //$NON-NLS-2$ + } + ArrayList command = new ArrayList(1 + arguments.length); + command.add(exePath.toOSString()); + command.addAll(Arrays.asList(arguments)); + String[] commandArray = (String[])command.toArray(new String[command.size()]); + monitor.worked(5); + Process process = exec(commandArray, getEnvironmentProperty(config), wd); + monitor.worked(3); + DebugPlugin.newProcess(launch, process, renderProcessLabel(commandArray[0])); + } + } finally { + monitor.done(); + } + } + + /** + * Performs a runtime exec on the given command line in the context of the + * specified working directory, and returns the resulting process. If the + * current runtime does not support the specification of a working + * directory, the status handler for error code + * <code>ERR_WORKING_DIRECTORY_NOT_SUPPORTED</code> is queried to see if + * the exec should be re-executed without specifying a working directory. + * + * @param cmdLine + * the command line + * @param workingDirectory + * the working directory, or <code>null</code> + * @return the resulting process or <code>null</code> if the exec is + * cancelled + * @see Runtime + */ + protected Process exec(String[] cmdLine, Properties environ, File workingDirectory) throws CoreException { + Process p = null; + Properties props = getDefaultEnvironment(); + props.putAll(expandEnvironment(environ)); + String[] envp = null; + ArrayList envList = new ArrayList(); + Enumeration names = props.propertyNames(); + if (names != null) { + while (names.hasMoreElements()) { + String key = (String)names.nextElement(); + envList.add(key + "=" + props.getProperty(key)); //$NON-NLS-1$ + } + envp = (String[])envList.toArray(new String[envList.size()]); + } + try { + + if (workingDirectory == null) { + p = ProcessFactory.getFactory().exec(cmdLine, envp); + } else { + p = ProcessFactory.getFactory().exec(cmdLine, envp, workingDirectory); + } + } catch (IOException e) { + if (p != null) { + p.destroy(); + } + abort(LaunchMessages.getString("LocalRunLaunchDelegate.Error_starting_process"), e, //$NON-NLS-1$ + ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); + } catch (NoSuchMethodError e) { + //attempting launches on 1.2.* - no ability to set working + // directory + + IStatus status = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), + ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_NOT_SUPPORTED, + LaunchMessages.getString("LocalRunLaunchDelegate.Does_not_support_working_dir"), //$NON-NLS-1$ + e); + IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status); + + if (handler != null) { + Object result = handler.handleStatus(status, this); + if (result instanceof Boolean && ((Boolean)result).booleanValue()) { + p = exec(cmdLine, environ, null); + } + } + } + return p; + } + + protected String getPluginID() { + return LaunchUIPlugin.getUniqueIdentifier(); + } +}
\ No newline at end of file diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/AbstractCDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/AbstractCDebuggerTab.java index 655d191fbb7..004275d5927 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/AbstractCDebuggerTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/AbstractCDebuggerTab.java @@ -1,13 +1,11 @@ -/********************************************************************** - * Copyright (c) 2002 - 2004 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html +/******************************************************************************* + * Copyright (c) 2002 - 2004 QNX Software Systems and others. All rights + * reserved. This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 which accompanies this + * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html * - * Contributors: - * QNX Software Systems - Initial API and implementation -***********************************************************************/ + * Contributors: QNX Software Systems - Initial API and implementation + ******************************************************************************/ package org.eclipse.cdt.launch.internal.ui; import java.util.Map; @@ -20,9 +18,17 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.ILaunchConfigurationTab; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab { @@ -34,6 +40,9 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab { protected ILaunchConfigurationTab fDynamicTab; protected Composite fDynamicTabHolder; private boolean fInitDefaults; + private Combo fDCombo; + private boolean fIsInitializing = false; + private boolean fPageUpdated; protected void setDebugConfig(ICDebugConfiguration config) { fCurrentDebugConfig = config; @@ -65,7 +74,7 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab { protected void setLaunchConfiguration(ILaunchConfiguration launchConfiguration) { fLaunchConfiguration = launchConfiguration; - setLaunchConfigurationWorkingCopy( null ); + setLaunchConfigurationWorkingCopy(null); } protected ILaunchConfiguration getLaunchConfiguration() { @@ -77,13 +86,14 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab { } /** - * Overridden here so that any error message in the dynamic UI gets returned. + * Overridden here so that any error message in the dynamic UI gets + * returned. * * @see ILaunchConfigurationTab#getErrorMessage() */ public String getErrorMessage() { ILaunchConfigurationTab tab = getDynamicTab(); - if ((super.getErrorMessage() != null) || (tab == null)) { + if ( (super.getErrorMessage() != null) || (tab == null)) { return super.getErrorMessage(); } return tab.getErrorMessage(); @@ -101,11 +111,11 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab { // remove any debug specfic args from the config if (wc == null) { if (getLaunchConfiguration().isWorkingCopy()) { - wc = (ILaunchConfigurationWorkingCopy) getLaunchConfiguration(); + wc = (ILaunchConfigurationWorkingCopy)getLaunchConfiguration(); } } if (wc != null) { - wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map) null); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null); } } else { if (wc == null) { @@ -150,7 +160,7 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab { try { tab = CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID()); } catch (CoreException e) { - LaunchUIPlugin.errorDialog(LaunchUIPlugin.getResourceString("AbstractCDebuggerTab.ErrorLoadingDebuggerPage"), e.getStatus()); //$NON-NLS-1$ + LaunchUIPlugin.errorDialog(LaunchMessages.getString("AbstractCDebuggerTab.ErrorLoadingDebuggerPage"), e.getStatus()); //$NON-NLS-1$ } setDynamicTab(tab); } @@ -165,17 +175,15 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab { getDynamicTabHolder().layout(true); } - abstract protected ICDebugConfiguration getConfigForCurrentDebugger(); 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) { setLaunchConfiguration(config); ILaunchConfigurationTab dynamicTab = getDynamicTab(); @@ -189,7 +197,7 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebugConfig().getID()); ILaunchConfigurationTab dynamicTab = getDynamicTab(); if (dynamicTab == null) { - config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map) null); + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null); } else { dynamicTab.performApply(config); } @@ -209,7 +217,7 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab { setErrorMessage(null); setMessage(null); if (getDebugConfig() == null) { - setErrorMessage(LaunchUIPlugin.getResourceString("AbstractCDebuggerTab.No_debugger_available")); //$NON-NLS-1$ + setErrorMessage(LaunchMessages.getString("AbstractCDebuggerTab.No_debugger_available")); //$NON-NLS-1$ return false; } @@ -233,7 +241,88 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab { } public String getName() { - return LaunchUIPlugin.getResourceString("AbstractCDebuggerTab.Debugger"); //$NON-NLS-1$ + return LaunchMessages.getString("AbstractCDebuggerTab.Debugger"); //$NON-NLS-1$ + } + + protected void createDebuggerCombo(Composite parent, int colspan) { + Composite comboComp = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(2, false); + comboComp.setLayout(layout); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = colspan; + comboComp.setLayoutData(gd); + Label dlabel = new Label(comboComp, SWT.NONE); + dlabel.setText(LaunchMessages.getString("Launch.common.DebuggerColon")); //$NON-NLS-1$ + fDCombo = new Combo(comboComp, SWT.READ_ONLY | SWT.DROP_DOWN); + fDCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + fDCombo.addModifyListener(new ModifyListener() { + + public void modifyText(ModifyEvent e) { + if (!isInitializing()) { + setInitializeDefault(true); + updateComboFromSelection(); + } + } + }); + } + + protected void loadDebuggerCombo(ICDebugConfiguration[] debugConfigs, String current) { + fDCombo.removeAll(); + + for (int i = 0; i < debugConfigs.length; i++) { + fDCombo.add(debugConfigs[i].getName()); + fDCombo.setData(Integer.toString(i), debugConfigs[i]); + } + + fPageUpdated = false; + fDCombo.setText(current); + //The behaviour is undefined for if the callbacks should be triggered + // for this, + //so force page update if needed. + if (!fPageUpdated) { + updateComboFromSelection(); + } + fPageUpdated = false; + getControl().getParent().layout(true); + + } + + protected void createDebuggerGroup(Composite parent, int colspan) { + Group debuggerGroup = new Group(parent, SWT.SHADOW_ETCHED_IN); + debuggerGroup.setText(LaunchMessages.getString("CDebuggerTab.Debugger_Options")); //$NON-NLS-1$ + setDynamicTabHolder(debuggerGroup); + GridLayout tabHolderLayout = new GridLayout(); + tabHolderLayout.marginHeight = 0; + tabHolderLayout.marginWidth = 0; + tabHolderLayout.numColumns = 1; + getDynamicTabHolder().setLayout(tabHolderLayout); + GridData gd = new GridData(GridData.FILL_BOTH); + gd.horizontalSpan = colspan; + getDynamicTabHolder().setLayoutData(gd); + } + + protected void updateComboFromSelection() { + fPageUpdated = true; + handleDebuggerChanged(); + updateLaunchConfigurationDialog(); + } + + protected boolean isInitializing() { + return fIsInitializing; + } + + protected void setInitializing(boolean isInitializing) { + fIsInitializing = isInitializing; + } + + /** + * Return the class that implements <code>ILaunchConfigurationTab</code> + * that is registered against the debugger id of the currently selected + * debugger. + */ + protected ICDebugConfiguration getConfigForCurrentDebugger() { + int selectedIndex = fDCombo.getSelectionIndex(); + return (ICDebugConfiguration)fDCombo.getData(Integer.toString(selectedIndex)); } -} +}
\ No newline at end of file diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileLaunchConfigurationTabGroup.java index 90f44e3bfca..f0c6759c0af 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileLaunchConfigurationTabGroup.java @@ -20,7 +20,7 @@ import org.eclipse.debug.ui.CommonTab; import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationTab; -public class CoreFileCLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup { +public class CoreFileLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup { /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String) diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.java new file mode 100644 index 00000000000..3e095289b81 --- /dev/null +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Common Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: QNX Software Systems - initial API and implementation + ******************************************************************************/ +package org.eclipse.cdt.launch.internal.ui; + +import java.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class LaunchMessages { + + private static final String BUNDLE_NAME = "org.eclipse.cdt.launch.internal.ui.LaunchMessages";//$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + + private LaunchMessages() { + } + + public static String getFormattedString(String key, String arg) { + return MessageFormat.format(getString(key), new String[]{arg}); + } + + public static String getFormattedString(String key, String[] args) { + return MessageFormat.format(getString(key), args); + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +}
\ No newline at end of file diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPluginResources.properties b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties index fad346d7564..ee804842102 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPluginResources.properties +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties @@ -20,25 +20,27 @@ AbstractCLaunchDelegate.Project_NAME_is_closed=Project {0} is closed AbstractCLaunchDelegate.PROGRAM_PATH_not_found={0} not found AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist={0} Does not exist. AbstractCLaunchDelegate.Debugger_Process=Debugger Process -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 +AbstractCLaunchDelegate.building_projects=Building prerequisite project list +AbstractCLaunchDelegate.building=Building +AbstractCLaunchDelegate.searching_for_errors=Searching for compile errors +AbstractCLaunchDelegate.searching_for_errors_in=Searching for compile errors in +AbstractCLaunchDelegate.20=Building prerequisite project list -LocalCLaunchConfigurationDelegate.Launching_Local_C_Application=Launching Local C Application -LocalCLaunchConfigurationDelegate.No_Process_ID_selected=No Process ID selected -LocalCLaunchConfigurationDelegate.Failed_Launching_CDI_Debugger=Failed Launching CDI Debugger -LocalCLaunchConfigurationDelegate.No_Shell_available_in_Launch=No Shell available in Launch -LocalCLaunchConfigurationDelegate.Select_Process=Select Process -LocalCLaunchConfigurationDelegate.CDT_Launch_Error=CDT Launch Error -LocalCLaunchConfigurationDelegate.Platform_cannot_list_processes=Current platform does not support listing processes -LocalCLaunchConfigurationDelegate.Error_starting_process=Error starting process -LocalCLaunchConfigurationDelegate.Does_not_support_working_dir=Eclipse runtime does not support working directory -LocalCLaunchConfigurationDelegate.Select_Process_to_attach_debugger_to=Select a Process to attach debugger to: +LocalRunLaunchDelegate.Launching_Local_C_Application=Launching Local C/C++ Application +LocalRunLaunchDelegate.Failed_setting_runtime_option_though_debugger=Failed to set program arguments, environemt or working directory. +LocalRunLaunchDelegate.Error_starting_process=Error starting process +LocalRunLaunchDelegate.Does_not_support_working_dir=Eclipse runtime does not support working directory + +LocalAttachLaunchDelegate.Attaching_to_Local_C_Application=Attaching to Local C/C++ Application +LocalAttachLaunchDelegate.No_Process_ID_selected=No Process ID selected +LocalAttachLaunchDelegate.No_Shell_available_in_Launch=No Shell available in Launch +LocalAttachLaunchDelegate.Select_Process=Select Process +LocalAttachLaunchDelegate.Platform_cannot_list_processes=Current platform does not support listing processes +LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to=Select a Process to attach debugger to: +LocalAttachLaunchDelegate.CDT_Launch_Error=CDT Launch Error CoreFileLaunchDelegate.Launching_postmortem_debugger=Launching postmortem debugger CoreFileLaunchDelegate.No_Corefile_selected=No Corefile selected -CoreFileLaunchDelegate.Failed_Launching_CDI_Debugger=Failed Launching CDI Debugger CoreFileLaunchDelegate.No_Shell_available_in_Launch=No Shell available in Launch CoreFileLaunchDelegate.Select_Corefile=Select Corefile @@ -67,9 +69,6 @@ LaunchUIPlugin.Error=Error CSourceLookupTab.Source=Source -CorefileDebuggerTab.Debugger_Options=Debugger Options -CorefileDebuggerTab.No_debugger_available=No debugger available - CMainTab.Project_required=Project required CMainTab.Enter_project_before_searching_for_program=Project must first be entered before searching for a program CMainTab.Program_Selection=Program Selection @@ -90,7 +89,6 @@ CMainTab.Search...=Searc&h... CMainTab.Choose_program_to_run=Choose a &program to run: CMainTab.Choose_program_to_run_from_NAME=Choose a program to run from {0}: -CDebuggerTab.Attach_to_running_process=Attach to running process CDebuggerTab.Advanced_Options_Dialog_Title=Advanced Options CDebuggerTab.Stop_at_main_on_startup=Stop at main() on startup CDebuggerTab.Automatically_track_values_of=Automatically track the values of @@ -101,6 +99,10 @@ CDebuggerTab.Variables=Variables CDebuggerTab.Registers=Registers CDebuggerTab.No_debugger_available=No debugger available CDebuggerTab.CPU_is_not_supported=The CPU is not supported by selected debugger. +CDebuggerTab.Platform_is_not_supported=The project platform is not supported by the selected debugger. + +CoreFileDebuggerTab.No_debugger_available=No debugger available +CoreFileDebuggerTab.platform_is_not_supported=The project platform is not supported by the selected debugger. CEnvironmentTab.Edit_Variable=Edit Variable CEnvironmentTab.New_Variable=New Variable @@ -136,4 +138,4 @@ Launch.common.BinariesColon=Binaries: Launch.common.QualifierColon=Qualifier: Launch.common.Browse_1=&Browse Launch.common.Browse_2=B&rowse -Launch.common.Project_does_not_exist=Project does not exist
\ No newline at end of file +Launch.common.Project_does_not_exist=Project does not exist diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPlugin.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPlugin.java index 297a7ae6b9b..d78abc000d4 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPlugin.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchUIPlugin.java @@ -1,19 +1,13 @@ -/********************************************************************** - * Copyright (c) 2002 - 2004 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html +/******************************************************************************* + * Copyright (c) 2002 - 2004 QNX Software Systems and others. All rights + * reserved. This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 which accompanies this + * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html * - * Contributors: - * QNX Software Systems - Initial API and implementation -***********************************************************************/ + * Contributors: QNX Software Systems - Initial API and implementation + ******************************************************************************/ 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.launch.AbstractCLaunchDelegate; import org.eclipse.core.resources.IResource; @@ -31,27 +25,12 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -public class LaunchUIPlugin extends AbstractUIPlugin - implements - IDebugEventSetListener { - public static final String PLUGIN_ID = "org.eclipse.cdt.launch"; //$NON-NLS-1$ +public class LaunchUIPlugin extends AbstractUIPlugin implements IDebugEventSetListener { - private static final String BUNDLE_NAME = "org.eclipse.cdt.launch.internal.ui.LaunchUIPluginResources";//$NON-NLS-1$ - private static ResourceBundle resourceBundle = null; + public static final String PLUGIN_ID = "org.eclipse.cdt.launch"; //$NON-NLS-1$ // -------- static methods -------- - static { - if (resourceBundle == null) { - // Acquire a reference to the .properties file for this plug-in - try { - resourceBundle = ResourceBundle.getBundle(BUNDLE_NAME); - } catch (MissingResourceException e) { - resourceBundle = null; - } - } - } - /** * Launch UI plug-in instance */ @@ -133,8 +112,7 @@ public class LaunchUIPlugin extends AbstractUIPlugin * the error message to log */ 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)); } /** @@ -144,8 +122,7 @@ public class LaunchUIPlugin extends AbstractUIPlugin * the exception to be logged */ 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$ } /** @@ -182,11 +159,7 @@ public class LaunchUIPlugin extends AbstractUIPlugin log(status); Shell shell = getActiveWorkbenchShell(); if (shell != null) { - ErrorDialog - .openError( - shell, - LaunchUIPlugin - .getResourceString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$ + ErrorDialog.openError(shell, LaunchMessages.getString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$ } } @@ -194,13 +167,8 @@ public class LaunchUIPlugin extends AbstractUIPlugin log(t); Shell shell = getActiveWorkbenchShell(); if (shell != null) { - IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(), - 1, t.getMessage(), null); //$NON-NLS-1$ - ErrorDialog - .openError( - shell, - LaunchUIPlugin - .getResourceString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$ + IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(), 1, t.getMessage(), null); //$NON-NLS-1$ + ErrorDialog.openError(shell, LaunchMessages.getString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$ } } @@ -237,17 +205,15 @@ public class LaunchUIPlugin extends AbstractUIPlugin if (events[i].getKind() == DebugEvent.TERMINATE) { Object o = events[i].getSource(); if (o instanceof IProcess) { - IProcess proc = (IProcess) o; + IProcess proc = (IProcess)o; ICProject cproject = null; try { - cproject = AbstractCLaunchDelegate.getCProject(proc - .getLaunch().getLaunchConfiguration()); + cproject = AbstractCLaunchDelegate.getCProject(proc.getLaunch().getLaunchConfiguration()); } catch (CoreException e) { } if (cproject != null) { try { - cproject.getProject().refreshLocal( - IResource.DEPTH_INFINITE, null); + cproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { } } @@ -255,38 +221,4 @@ public class LaunchUIPlugin extends AbstractUIPlugin } } } - - /** - * Returns the plugin's resource bundle, - */ - public ResourceBundle getResourceBundle() { - return resourceBundle; - } - - public static String getResourceString(String key) { - ResourceBundle bundle = LaunchUIPlugin.getDefault().getResourceBundle(); - - // No point trying if bundle is null as exceptions are costly - if (bundle != null) { - try { - return bundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ - } catch (NullPointerException e) { - return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - // If we get here, then bundle is null. - return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$ - } - - public static String getFormattedResourceString(String key, String arg) { - return MessageFormat.format(getResourceString(key), new String[]{arg}); - } - - public static String getFormattedResourceString(String key, String[] args) { - return MessageFormat.format(getResourceString(key), args); - } - }
\ No newline at end of file diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalAttachLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalAttachLaunchConfigurationTabGroup.java new file mode 100644 index 00000000000..ec8b9d75ebd --- /dev/null +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalAttachLaunchConfigurationTabGroup.java @@ -0,0 +1,35 @@ +/********************************************************************** + * Copyright (c) 2002 - 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.launch.internal.ui; + +import org.eclipse.cdt.launch.ui.CDebuggerTab; +import org.eclipse.cdt.launch.ui.CMainTab; +import org.eclipse.cdt.launch.ui.CSourceLookupTab; +import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; +import org.eclipse.debug.ui.CommonTab; +import org.eclipse.debug.ui.ILaunchConfigurationDialog; +import org.eclipse.debug.ui.ILaunchConfigurationTab; + +public class LocalAttachLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup { + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String) + */ + public void createTabs(ILaunchConfigurationDialog dialog, String mode) { + ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { + new CMainTab(), + new CDebuggerTab(true), + new CSourceLookupTab(), + new CommonTab() + }; + setTabs(tabs); + } +} diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalRunLaunchConfigurationTabGroup.java index a70f4d18d0d..154aa25287d 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalRunLaunchConfigurationTabGroup.java @@ -20,7 +20,7 @@ import org.eclipse.debug.ui.CommonTab; import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationTab; -public class LocalCLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup { +public class LocalRunLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup { /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String) @@ -30,7 +30,7 @@ public class LocalCLaunchConfigurationTabGroup extends AbstractLaunchConfigurati new CMainTab(), new CArgumentsTab(), new CEnvironmentTab(), - new CDebuggerTab(), + new CDebuggerTab(false), new CSourceLookupTab(), new CommonTab() }; diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/WorkingDirectoryBlock.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/WorkingDirectoryBlock.java index 3e038fe8cad..3eaf00c44ff 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/WorkingDirectoryBlock.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/WorkingDirectoryBlock.java @@ -24,6 +24,7 @@ import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; +import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -85,13 +86,13 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab { setControl(workingDirComp); fWorkingDirLabel = new Label(workingDirComp, SWT.NONE); - fWorkingDirLabel.setText(LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Wor&king_directory")); //$NON-NLS-1$ + fWorkingDirLabel.setText(LaunchMessages.getString("WorkingDirectoryBlock.Wor&king_directory")); //$NON-NLS-1$ gd = new GridData(); gd.horizontalSpan = 3; fWorkingDirLabel.setLayoutData(gd); fUseDefaultWorkingDirButton = new Button(workingDirComp,SWT.CHECK); - fUseDefaultWorkingDirButton.setText(LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Use_de&fault_working_directory")); //$NON-NLS-1$ + fUseDefaultWorkingDirButton.setText(LaunchMessages.getString("WorkingDirectoryBlock.Use_de&fault_working_directory")); //$NON-NLS-1$ gd = new GridData(); gd.horizontalSpan = 3; fUseDefaultWorkingDirButton.setLayoutData(gd); @@ -101,7 +102,7 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab { } }); - fLocalDirButton = createRadioButton(workingDirComp, LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.&Local_directory")); //$NON-NLS-1$ + fLocalDirButton = createRadioButton(workingDirComp, LaunchMessages.getString("WorkingDirectoryBlock.&Local_directory")); //$NON-NLS-1$ fLocalDirButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { handleLocationButtonSelected(); @@ -117,14 +118,14 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab { } }); - fWorkingDirBrowseButton = createPushButton(workingDirComp, LaunchUIPlugin.getResourceString("Launch.common.Browse_1"), null); //$NON-NLS-1$ + fWorkingDirBrowseButton = createPushButton(workingDirComp, LaunchMessages.getString("Launch.common.Browse_1"), null); //$NON-NLS-1$ fWorkingDirBrowseButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { handleWorkingDirBrowseButtonSelected(); } }); - fWorkspaceDirButton = createRadioButton(workingDirComp, LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Works&pace")); //$NON-NLS-1$ + fWorkspaceDirButton = createRadioButton(workingDirComp, LaunchMessages.getString("WorkingDirectoryBlock.Works&pace")); //$NON-NLS-1$ fWorkspaceDirButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { handleLocationButtonSelected(); @@ -140,7 +141,7 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab { } }); - fWorkspaceDirBrowseButton = createPushButton(workingDirComp, LaunchUIPlugin.getResourceString("Launch.common.Browse_2"), null); //$NON-NLS-1$ + fWorkspaceDirBrowseButton = createPushButton(workingDirComp, LaunchMessages.getString("Launch.common.Browse_2"), null); //$NON-NLS-1$ fWorkspaceDirBrowseButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { handleWorkspaceDirBrowseButtonSelected(); @@ -160,7 +161,7 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab { */ protected void handleWorkingDirBrowseButtonSelected() { DirectoryDialog dialog = new DirectoryDialog(getShell()); - dialog.setMessage(LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Select_&working_directory_for_launch_configuration")); //$NON-NLS-1$ + dialog.setMessage(LaunchMessages.getString("WorkingDirectoryBlock.Select_&working_directory_for_launch_configuration")); //$NON-NLS-1$ String currentWorkingDir = fWorkingDirText.getText(); if (!currentWorkingDir.trim().equals(EMPTY_STRING)) { File path = new File(currentWorkingDir); @@ -183,7 +184,7 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab { ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), false, - LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Select_&workspace_relative_working_directory")); //$NON-NLS-1$ + LaunchMessages.getString("WorkingDirectoryBlock.Select_&workspace_relative_working_directory")); //$NON-NLS-1$ IContainer currentContainer = getContainer(); if (currentContainer != null) { @@ -291,17 +292,17 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab { if (workingDirPath.length() > 0) { File dir = new File(workingDirPath); if (!dir.exists()) { - setErrorMessage(LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Working_directory_does_not_exist")); //$NON-NLS-1$ + setErrorMessage(LaunchMessages.getString("WorkingDirectoryBlock.Working_directory_does_not_exist")); //$NON-NLS-1$ return false; } if (!dir.isDirectory()) { - setErrorMessage(LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Working_directory_is_not_a_directory")); //$NON-NLS-1$ + setErrorMessage(LaunchMessages.getString("WorkingDirectoryBlock.Working_directory_is_not_a_directory")); //$NON-NLS-1$ return false; } } } else { if (getContainer() == null) { - setErrorMessage(LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Project_or_folder_does_not_exist")); //$NON-NLS-1$ + setErrorMessage(LaunchMessages.getString("WorkingDirectoryBlock.Project_or_folder_does_not_exist")); //$NON-NLS-1$ return false; } } @@ -345,7 +346,7 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab { } handleUseDefaultWorkingDirButtonSelected(); } catch (CoreException e) { - setErrorMessage(LaunchUIPlugin.getFormattedResourceString("Launch.common.Exception_occurred_reading_configuration_EXCEPTION", e.getStatus().getMessage())); //$NON-NLS-1$ + setErrorMessage(LaunchMessages.getFormattedString("Launch.common.Exception_occurred_reading_configuration_EXCEPTION", e.getStatus().getMessage())); //$NON-NLS-1$ LaunchUIPlugin.log(e); } } @@ -384,7 +385,7 @@ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab { * @see ILaunchConfigurationTab#getName() */ public String getName() { - return LaunchUIPlugin.getResourceString("WorkingDirectoryBlock.Working_Directory"); //$NON-NLS-1$ + return LaunchMessages.getString("WorkingDirectoryBlock.Working_Directory"); //$NON-NLS-1$ } /** diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CArgumentsTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CArgumentsTab.java index 484f7f4adfb..c489ed2dd7d 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CArgumentsTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CArgumentsTab.java @@ -12,12 +12,14 @@ package org.eclipse.cdt.launch.ui; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.launch.internal.ui.LaunchImages; +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.internal.ui.WorkingDirectoryBlock; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.ILaunchConfigurationDialog; +import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -63,7 +65,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab { createVerticalSpacer(comp, 1); fPrgmArgumentsLabel = new Label(comp, SWT.NONE); - fPrgmArgumentsLabel.setText(LaunchUIPlugin.getResourceString("CArgumentsTab.C/C++_Program_Arguments")); //$NON-NLS-1$ + fPrgmArgumentsLabel.setText(LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments")); //$NON-NLS-1$ fPrgmArgumentsText = new Text(comp, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = 40; @@ -111,7 +113,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab { fWorkingDirectoryBlock.initializeFrom(configuration); } catch (CoreException e) { - setErrorMessage(LaunchUIPlugin.getFormattedResourceString("Launch.common.Exception_occurred_reading_configuration_EXCEPTION", e.getStatus().getMessage())); //$NON-NLS-1$ + setErrorMessage(LaunchMessages.getFormattedString("Launch.common.Exception_occurred_reading_configuration_EXCEPTION", e.getStatus().getMessage())); //$NON-NLS-1$ LaunchUIPlugin.log(e); } } @@ -143,7 +145,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab { * @see ILaunchConfigurationTab#getName() */ public String getName() { - return LaunchUIPlugin.getResourceString("CArgumentsTab.Arguments"); //$NON-NLS-1$ + return LaunchMessages.getString("CArgumentsTab.Arguments"); //$NON-NLS-1$ } /** diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java index 2e05eedd040..43ecf617cfc 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java @@ -11,10 +11,13 @@ package org.eclipse.cdt.launch.ui; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; +import java.util.List; import java.util.Map; + import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.debug.core.CDebugCorePlugin; @@ -22,25 +25,21 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.internal.ui.PixelConverter; import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab; -import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.help.WorkbenchHelp; @@ -65,14 +64,14 @@ public class CDebuggerTab extends AbstractCDebuggerTab { protected Control createDialogArea( Composite parent ) { Composite composite = (Composite)super.createDialogArea( parent ); Group group = new Group( composite, SWT.NONE ); - group.setText( LaunchUIPlugin.getResourceString( "CDebuggerTab.Automatically_track_values_of" ) ); //$NON-NLS-1$ + group.setText( LaunchMessages.getString( "CDebuggerTab.Automatically_track_values_of" ) ); //$NON-NLS-1$ GridLayout layout = new GridLayout(); group.setLayout( layout ); group.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); fVarBookKeeping = new Button( group, SWT.CHECK ); - fVarBookKeeping.setText( LaunchUIPlugin.getResourceString( "CDebuggerTab.Variables" ) ); //$NON-NLS-1$ + fVarBookKeeping.setText( LaunchMessages.getString( "CDebuggerTab.Variables" ) ); //$NON-NLS-1$ fRegBookKeeping = new Button( group, SWT.CHECK ); - fRegBookKeeping.setText( LaunchUIPlugin.getResourceString( "CDebuggerTab.Registers" ) ); //$NON-NLS-1$ + fRegBookKeeping.setText( LaunchMessages.getString( "CDebuggerTab.Registers" ) ); //$NON-NLS-1$ initialize(); return composite; } @@ -104,21 +103,23 @@ public class CDebuggerTab extends AbstractCDebuggerTab { */ protected void configureShell( Shell newShell ) { super.configureShell( newShell ); - newShell.setText( LaunchUIPlugin.getResourceString( "CDebuggerTab.Advanced_Options_Dialog_Title" ) ); //$NON-NLS-1$ + newShell.setText( LaunchMessages.getString( "CDebuggerTab.Advanced_Options_Dialog_Title" ) ); //$NON-NLS-1$ } } - protected Combo fDCombo; + final protected boolean fAttachMode; + protected Button fAdvancedButton; protected Button fStopInMain; protected Button fAttachButton; private Map fAdvancedAttributes = new HashMap( 5 ); - private boolean fPageUpdated; - - private boolean fIsInitializing = false; - + public CDebuggerTab(boolean attachMode) { + fAttachMode = attachMode; + } + + public void createControl( Composite parent ) { Composite comp = new Composite( parent, SWT.NONE ); setControl( comp ); @@ -130,16 +131,14 @@ public class CDebuggerTab extends AbstractCDebuggerTab { gd.grabExcessHorizontalSpace = true; comp.setLayoutData( gd ); - createDebuggerCombo( comp ); - createAttachButton( comp ); + createDebuggerCombo( comp, 1 ); createOptionsComposite( comp ); - createDebuggerGroup( comp ); + createDebuggerGroup( comp, 2 ); } protected void loadDebuggerComboBox( ILaunchConfiguration config, String selection ) { ICDebugConfiguration[] debugConfigs; String configPlatform = getPlatform( config ); - fDCombo.removeAll(); debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations(); Arrays.sort( debugConfigs, new Comparator() { @@ -149,48 +148,46 @@ public class CDebuggerTab extends AbstractCDebuggerTab { return ic1.getName().compareTo( ic2.getName() ); } } ); - int selndx = -1; - int x = 0; + List list = new ArrayList(); + String mode; + if (fAttachMode) { + mode = ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH; + } else { + mode = ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN; + } + String defaultSelection = selection; for( int i = 0; i < debugConfigs.length; i++ ) { - if ( debugConfigs[i].supportsMode( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN ) || debugConfigs[i].supportsMode( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH ) ) { + if ( debugConfigs[i].supportsMode( mode )) { String debuggerPlatform = debugConfigs[i].getPlatform(); if ( validatePlatform( config, debugConfigs[i] ) ) { - fDCombo.add( debugConfigs[i].getName() ); - fDCombo.setData( Integer.toString( x ), debugConfigs[i] ); + list.add( debugConfigs[i] ); // select first exact matching debugger for platform or requested selection - if ( (selndx == -1 && debuggerPlatform.equalsIgnoreCase( configPlatform )) || selection.equals( debugConfigs[i].getID() ) ) { - selndx = x; + if ( (defaultSelection.equals("") && debuggerPlatform.equalsIgnoreCase( configPlatform ))) { //$NON-NLS-1$ + defaultSelection = debugConfigs[i].getName(); } - x++; } } } // if no selection meaning nothing in config the force initdefault on tab setInitializeDefault( selection.equals( "" ) ? true : false ); //$NON-NLS-1$ - fPageUpdated = false; - fDCombo.select( selndx == -1 ? 0 : selndx ); - //The behaviour is undefined for if the callbacks should be triggered for this, - //so force page update if needed. - if ( !fPageUpdated ) { - updateComboFromSelection(); - } - fPageUpdated = false; - getControl().getParent().layout( true ); + loadDebuggerCombo((ICDebugConfiguration[])list.toArray(new ICDebugConfiguration[list.size()]), defaultSelection); } protected void updateComboFromSelection() { - fPageUpdated = true; - handleDebuggerChanged(); - initializeCommonControls( getLaunchConfigurationWorkingCopy() ); - updateLaunchConfigurationDialog(); + super.updateComboFromSelection(); + initializeCommonControls( getLaunchConfiguration() ); } public void setDefaults( ILaunchConfigurationWorkingCopy config ) { super.setDefaults( config ); - config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT ); + if (fAttachMode) { + config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH ); + } else { + config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN ); + config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT ); + } config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false ); config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false ); - config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN ); } public void initializeFrom( ILaunchConfiguration config ) { @@ -208,7 +205,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab { public void performApply( ILaunchConfigurationWorkingCopy config ) { super.performApply( config ); - if ( fAttachButton.getSelection() ) { + if ( fAttachMode ) { config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH ); } else { @@ -223,23 +220,17 @@ public class CDebuggerTab extends AbstractCDebuggerTab { return false; } ICDebugConfiguration debugConfig = getDebugConfig(); - if ( debugConfig == null ) { - setErrorMessage( LaunchUIPlugin.getResourceString( "CDebuggerTab.No_debugger_available" ) ); //$NON-NLS-1$ + String mode = fAttachMode ? ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH : ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN; + if ( !debugConfig.supportsMode( mode ) ) { + setErrorMessage( MessageFormat.format( LaunchMessages.getString( "CDebuggerTab.Mode_not_supported" ), new String[] { mode } ) ); //$NON-NLS-1$ return false; } - if ( fAttachButton != null ) { - String mode = ( fAttachButton.getSelection() ) ? ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH : ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN; - if ( !debugConfig.supportsMode( mode ) ) { - setErrorMessage( MessageFormat.format( LaunchUIPlugin.getResourceString( "CDebuggerTab.Mode_not_supported" ), new String[] { mode } ) ); //$NON-NLS-1$ - return false; - } - } if ( super.isValid( config ) == false ) { return false; } return true; } - + protected boolean validatePlatform( ILaunchConfiguration config, ICDebugConfiguration debugConfig ) { String configPlatform = getPlatform( config ); String debuggerPlatform = debugConfig.getPlatform(); @@ -261,85 +252,47 @@ public class CDebuggerTab extends AbstractCDebuggerTab { protected boolean validateDebuggerConfig( ILaunchConfiguration config ) { ICDebugConfiguration debugConfig = getDebugConfig(); if ( debugConfig == null ) { - setErrorMessage( LaunchUIPlugin.getResourceString( "CDebuggerTab.No_debugger_available" ) ); //$NON-NLS-1$ + setErrorMessage( LaunchMessages.getString( "CDebuggerTab.No_debugger_available" ) ); //$NON-NLS-1$ + return false; + } + if ( !validatePlatform( config, debugConfig ) ) { + setErrorMessage( LaunchMessages.getString( "CDebuggerTab.Platform_is_not_supported" ) ); //$NON-NLS-1$ return false; } - if ( !validatePlatform( config, debugConfig ) || !validateCPU( config, debugConfig ) ) { - setErrorMessage( LaunchUIPlugin.getResourceString( "CDebuggerTab.CPU_is_not_supported" ) ); //$NON-NLS-1$ + if (!validateCPU( config, debugConfig ) ) { + setErrorMessage( LaunchMessages.getString( "CDebuggerTab.CPU_is_not_supported" ) ); //$NON-NLS-1$ return false; } return true; } /** - * Return the class that implements <code>ILaunchConfigurationTab</code> that is registered against the debugger id of the currently selected debugger. - */ - protected ICDebugConfiguration getConfigForCurrentDebugger() { - int selectedIndex = fDCombo.getSelectionIndex(); - return (ICDebugConfiguration)fDCombo.getData( Integer.toString( selectedIndex ) ); - } - - /** * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog() */ protected void updateLaunchConfigurationDialog() { super.updateLaunchConfigurationDialog(); } - protected void createDebuggerCombo( Composite parent ) { - Composite comboComp = new Composite( parent, SWT.NONE ); - GridLayout layout = new GridLayout( 2, false ); - comboComp.setLayout( layout ); - Label dlabel = new Label( comboComp, SWT.NONE ); - dlabel.setText( LaunchUIPlugin.getResourceString( "Launch.common.DebuggerColon" ) ); //$NON-NLS-1$ - fDCombo = new Combo( comboComp, SWT.DROP_DOWN | SWT.READ_ONLY ); - fDCombo.addModifyListener( new ModifyListener() { - - public void modifyText( ModifyEvent e ) { - if ( !isInitializing() ) { - setInitializeDefault( true ); - updateComboFromSelection(); - } - } - } ); - } - - protected void createAttachButton( Composite parent ) { - Composite attachComp = new Composite( parent, SWT.NONE ); - GridLayout attachLayout = new GridLayout(); - attachLayout.marginHeight = 0; - attachLayout.marginWidth = 0; - attachComp.setLayout( attachLayout ); - fAttachButton = createCheckButton( attachComp, LaunchUIPlugin.getResourceString( "CDebuggerTab.Attach_to_running_process" ) ); //$NON-NLS-1$ - fAttachButton.addSelectionListener( new SelectionAdapter() { - - public void widgetSelected( SelectionEvent e ) { - if ( !isInitializing() ) { - fStopInMain.setSelection( !fAttachButton.getSelection() ); - fStopInMain.setEnabled( !fAttachButton.getSelection() ); - updateLaunchConfigurationDialog(); - } - } - } ); - } - protected void createOptionsComposite( Composite parent ) { Composite optionsComp = new Composite( parent, SWT.NONE ); GridLayout layout = new GridLayout( 2, true ); optionsComp.setLayout( layout ); - optionsComp.setLayoutData( new GridData( GridData.FILL, GridData.CENTER, true, false, 2, 1 ) ); - - fStopInMain = createCheckButton( optionsComp, LaunchUIPlugin.getResourceString( "CDebuggerTab.Stop_at_main_on_startup" ) ); //$NON-NLS-1$ - fStopInMain.addSelectionListener( new SelectionAdapter() { - - public void widgetSelected( SelectionEvent e ) { - if ( !isInitializing() ) { - updateLaunchConfigurationDialog(); + optionsComp.setLayoutData( new GridData( GridData.FILL, GridData.CENTER, true, false, 1, 1 ) ); + + if (fAttachMode == true) { + createVerticalSpacer(optionsComp, 1); + } else { + fStopInMain = createCheckButton( optionsComp, LaunchMessages.getString( "CDebuggerTab.Stop_at_main_on_startup" ) ); //$NON-NLS-1$ + fStopInMain.addSelectionListener( new SelectionAdapter() { + + public void widgetSelected( SelectionEvent e ) { + if ( !isInitializing() ) { + updateLaunchConfigurationDialog(); + } } - } - } ); - - fAdvancedButton = createPushButton( optionsComp, LaunchUIPlugin.getResourceString( "CDebuggerTab.Advanced" ), null ); //$NON-NLS-1$ + } ); + } + fAdvancedButton = createPushButton( optionsComp, LaunchMessages.getString( "CDebuggerTab.Advanced" ), null ); //$NON-NLS-1$ GridData data = new GridData(); data.horizontalAlignment = GridData.END; PixelConverter pc = new PixelConverter( parent ); @@ -354,20 +307,6 @@ public class CDebuggerTab extends AbstractCDebuggerTab { } ); } - protected void createDebuggerGroup( Composite parent ) { - Group debuggerGroup = new Group( parent, SWT.SHADOW_ETCHED_IN ); - debuggerGroup.setText( LaunchUIPlugin.getResourceString( "CDebuggerTab.Debugger_Options" ) ); //$NON-NLS-1$ - setDynamicTabHolder( debuggerGroup ); - GridLayout tabHolderLayout = new GridLayout(); - tabHolderLayout.marginHeight = 0; - tabHolderLayout.marginWidth = 0; - tabHolderLayout.numColumns = 1; - getDynamicTabHolder().setLayout( tabHolderLayout ); - GridData gd = new GridData( GridData.FILL_BOTH ); - gd.horizontalSpan = 2; - getDynamicTabHolder().setLayoutData( gd ); - } - protected Map getAdvancedAttributes() { return fAdvancedAttributes; } @@ -411,29 +350,16 @@ public class CDebuggerTab extends AbstractCDebuggerTab { } protected void initializeCommonControls( ILaunchConfiguration config ) { - ICDebugConfiguration debugConfig = getConfigForCurrentDebugger(); try { - String mode = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN ); - fAttachButton.setEnabled( debugConfig != null && debugConfig.supportsMode( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH ) ); - if ( fAttachButton.isEnabled() ) - fAttachButton.setSelection( mode.equals( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH ) ); - fStopInMain.setEnabled( debugConfig != null && !fAttachButton.getSelection() ); - if ( fStopInMain.isEnabled() ) - fStopInMain.setSelection( ( fAttachButton.getSelection() ) ? false : config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT ) ); + if (!fAttachMode) { + fStopInMain.setSelection( config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT ) ); + } initializeAdvancedAttributes( config ); } catch( CoreException e ) { } } - - protected boolean isInitializing() { - return fIsInitializing; - } - - private void setInitializing( boolean isInitializing ) { - fIsInitializing = isInitializing; - } - + /* (non-Javadoc) * @see org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab#setInitializeDefault(boolean) */ diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CEnvironmentTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CEnvironmentTab.java index 9a983cf41c4..2407b786909 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CEnvironmentTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CEnvironmentTab.java @@ -20,10 +20,11 @@ import java.util.Properties; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.launch.internal.ui.LaunchImages; -import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; @@ -131,7 +132,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab { protected void configureShell(Shell shell) { super.configureShell(shell); - String title = (fEdit) ? LaunchUIPlugin.getResourceString("CEnvironmentTab.Edit_Variable") : LaunchUIPlugin.getResourceString("CEnvironmentTab.New_Variable"); //$NON-NLS-1$ //$NON-NLS-2$ + String title = (fEdit) ? LaunchMessages.getString("CEnvironmentTab.Edit_Variable") : LaunchMessages.getString("CEnvironmentTab.New_Variable"); //$NON-NLS-1$ //$NON-NLS-2$ shell.setText(title); } @@ -149,14 +150,14 @@ public class CEnvironmentTab extends CLaunchConfigurationTab { int fieldWidthHint = convertWidthInCharsToPixels(metrics, 50); Label label = new Label(composite, SWT.NONE); - label.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.NameColon")); //$NON-NLS-1$ + label.setText(LaunchMessages.getString("CEnvironmentTab.NameColon")); //$NON-NLS-1$ fTextName = new Text(composite, SWT.SINGLE | SWT.BORDER); GridData gd = new GridData(GridData.FILL_BOTH); gd.grabExcessHorizontalSpace = true; gd.widthHint = fieldWidthHint; fTextName.setLayoutData(gd); label = new Label(composite, SWT.NONE); - label.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.ValueColon")); //$NON-NLS-1$ + label.setText(LaunchMessages.getString("CEnvironmentTab.ValueColon")); //$NON-NLS-1$ fTextValue = new Text(composite, SWT.SINGLE | SWT.BORDER); gd = new GridData(GridData.FILL_BOTH); gd.grabExcessHorizontalSpace = true; @@ -272,11 +273,11 @@ public class CEnvironmentTab extends CLaunchConfigurationTab { table.setLinesVisible(true); TableColumn column1 = new TableColumn(table, SWT.NULL); - column1.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.Name")); //$NON-NLS-1$ + column1.setText(LaunchMessages.getString("CEnvironmentTab.Name")); //$NON-NLS-1$ tableLayout.addColumnData(new ColumnWeightData(30)); TableColumn column2 = new TableColumn(table, SWT.NULL); - column2.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.Value")); //$NON-NLS-1$ + column2.setText(LaunchMessages.getString("CEnvironmentTab.Value")); //$NON-NLS-1$ tableLayout.addColumnData(new ColumnWeightData(30)); fVariableList.addDoubleClickListener(new IDoubleClickListener() { @@ -296,7 +297,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab { composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); composite.setLayout(new GridLayout(1, true)); fBtnNew = new Button(composite, SWT.NONE); - fBtnNew.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.New...")); //$NON-NLS-1$ + fBtnNew.setText(LaunchMessages.getString("CEnvironmentTab.New...")); //$NON-NLS-1$ fBtnNew.setLayoutData(new GridData(GridData.FILL_BOTH)); fBtnNew.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { @@ -304,7 +305,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab { } }); fBtnImport = new Button(composite, SWT.NONE); - fBtnImport.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.Import...")); //$NON-NLS-1$ + fBtnImport.setText(LaunchMessages.getString("CEnvironmentTab.Import...")); //$NON-NLS-1$ fBtnImport.setLayoutData(new GridData(GridData.FILL_BOTH)); fBtnImport.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { @@ -312,7 +313,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab { } }); fBtnEdit = new Button(composite, SWT.NONE); - fBtnEdit.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.Edit...")); //$NON-NLS-1$ + fBtnEdit.setText(LaunchMessages.getString("CEnvironmentTab.Edit...")); //$NON-NLS-1$ fBtnEdit.setLayoutData(new GridData(GridData.FILL_BOTH)); fBtnEdit.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { @@ -320,7 +321,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab { } }); fBtnRemove = new Button(composite, SWT.NONE); - fBtnRemove.setText(LaunchUIPlugin.getResourceString("CEnvironmentTab.Remove")); //$NON-NLS-1$ + fBtnRemove.setText(LaunchMessages.getString("CEnvironmentTab.Remove")); //$NON-NLS-1$ fBtnRemove.setLayoutData(new GridData(GridData.FILL_BOTH)); fBtnRemove.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { @@ -392,7 +393,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab { if(fElements.getProperty(key) != null) { boolean overwrite; - overwrite = MessageDialog.openQuestion(getShell(), LaunchUIPlugin.getResourceString("CEnvironmentTab.Existing_Environment_Variable"), LaunchUIPlugin.getFormattedResourceString("CEnvironmentTab.Environment_variable_NAME_exists", key)); //$NON-NLS-1$ //$NON-NLS-2$ + overwrite = MessageDialog.openQuestion(getShell(), LaunchMessages.getString("CEnvironmentTab.Existing_Environment_Variable"), LaunchMessages.getFormattedString("CEnvironmentTab.Environment_variable_NAME_exists", key)); //$NON-NLS-1$ //$NON-NLS-2$ if(!overwrite) { continue; } @@ -461,7 +462,7 @@ public class CEnvironmentTab extends CLaunchConfigurationTab { * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() */ public String getName() { - return LaunchUIPlugin.getResourceString("CEnvironmentTab.Environment"); //$NON-NLS-1$ + return LaunchMessages.getString("CEnvironmentTab.Environment"); //$NON-NLS-1$ } /** diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java index 6f88d06182f..c23af760e14 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java @@ -23,6 +23,7 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.internal.ui.CPluginImages; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; import org.eclipse.cdt.launch.internal.ui.LaunchImages; +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.ui.CElementImageDescriptor; import org.eclipse.cdt.ui.CElementLabelProvider; @@ -113,7 +114,7 @@ public class CMainTab extends CLaunchConfigurationTab { projComp.setLayoutData(gd); fProjLabel = new Label(projComp, SWT.NONE); - fProjLabel.setText(LaunchUIPlugin.getResourceString("CMainTab.&ProjectColon")); //$NON-NLS-1$ + fProjLabel.setText(LaunchMessages.getString("CMainTab.&ProjectColon")); //$NON-NLS-1$ gd = new GridData(); gd.horizontalSpan = 2; fProjLabel.setLayoutData(gd); @@ -128,7 +129,7 @@ public class CMainTab extends CLaunchConfigurationTab { } }); - fProjButton = createPushButton(projComp, LaunchUIPlugin.getResourceString("Launch.common.Browse_1"), null); //$NON-NLS-1$ + fProjButton = createPushButton(projComp, LaunchMessages.getString("Launch.common.Browse_1"), null); //$NON-NLS-1$ fProjButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { @@ -148,7 +149,7 @@ public class CMainTab extends CLaunchConfigurationTab { gd = new GridData(GridData.FILL_HORIZONTAL); mainComp.setLayoutData(gd); fProgLabel = new Label(mainComp, SWT.NONE); - fProgLabel.setText(LaunchUIPlugin.getResourceString("CMainTab.C/C++_Application")); //$NON-NLS-1$ + fProgLabel.setText(LaunchMessages.getString("CMainTab.C/C++_Application")); //$NON-NLS-1$ gd = new GridData(); gd.horizontalSpan = 3; fProgLabel.setLayoutData(gd); @@ -162,7 +163,7 @@ public class CMainTab extends CLaunchConfigurationTab { } }); - fSearchButton = createPushButton(mainComp, LaunchUIPlugin.getResourceString("CMainTab.Search..."), null); //$NON-NLS-1$ + fSearchButton = createPushButton(mainComp, LaunchMessages.getString("CMainTab.Search..."), null); //$NON-NLS-1$ fSearchButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { @@ -172,7 +173,7 @@ public class CMainTab extends CLaunchConfigurationTab { }); Button fBrowseForBinaryButton; - fBrowseForBinaryButton = createPushButton(mainComp, LaunchUIPlugin.getResourceString("Launch.common.Browse_2"), null); //$NON-NLS-1$ + fBrowseForBinaryButton = createPushButton(mainComp, LaunchMessages.getString("Launch.common.Browse_2"), null); //$NON-NLS-1$ fBrowseForBinaryButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { @@ -228,8 +229,8 @@ public class CMainTab extends CLaunchConfigurationTab { protected void handleSearchButtonSelected() { if (getCProject() == null) { - MessageDialog.openInformation(getShell(), LaunchUIPlugin.getResourceString("CMainTab.Project_required"), //$NON-NLS-1$ - LaunchUIPlugin.getResourceString("CMainTab.Enter_project_before_searching_for_program")); //$NON-NLS-1$ + MessageDialog.openInformation(getShell(), LaunchMessages.getString("CMainTab.Project_required"), //$NON-NLS-1$ + LaunchMessages.getString("CMainTab.Enter_project_before_searching_for_program")); //$NON-NLS-1$ return; } @@ -284,10 +285,10 @@ public class CMainTab extends CLaunchConfigurationTab { TwoPaneElementSelector dialog = new TwoPaneElementSelector(getShell(), programLabelProvider, qualifierLabelProvider); dialog.setElements(getBinaryFiles(getCProject())); - dialog.setMessage(LaunchUIPlugin.getResourceString("CMainTab.Choose_program_to_run")); //$NON-NLS-1$ - dialog.setTitle(LaunchUIPlugin.getResourceString("CMainTab.Program_Selection")); //$NON-NLS-1$ - dialog.setUpperListLabel(LaunchUIPlugin.getResourceString("Launch.common.BinariesColon")); //$NON-NLS-1$ - dialog.setLowerListLabel(LaunchUIPlugin.getResourceString("Launch.common.QualifierColon")); //$NON-NLS-1$ + dialog.setMessage(LaunchMessages.getString("CMainTab.Choose_program_to_run")); //$NON-NLS-1$ + dialog.setTitle(LaunchMessages.getString("CMainTab.Program_Selection")); //$NON-NLS-1$ + dialog.setUpperListLabel(LaunchMessages.getString("Launch.common.BinariesColon")); //$NON-NLS-1$ + dialog.setLowerListLabel(LaunchMessages.getString("Launch.common.QualifierColon")); //$NON-NLS-1$ dialog.setMultipleSelection(false); //dialog.set if (dialog.open() == Window.OK) { @@ -305,8 +306,8 @@ public class CMainTab extends CLaunchConfigurationTab { protected void handleBinaryBrowseButtonSelected() { final ICProject cproject = getCProject(); if (cproject == null) { - MessageDialog.openInformation(getShell(), LaunchUIPlugin.getResourceString("CMainTab.Project_required"), //$NON-NLS-1$ - LaunchUIPlugin.getResourceString("CMainTab.Enter_project_before_browsing_for_program")); //$NON-NLS-1$ + MessageDialog.openInformation(getShell(), LaunchMessages.getString("CMainTab.Project_required"), //$NON-NLS-1$ + LaunchMessages.getString("CMainTab.Enter_project_before_browsing_for_program")); //$NON-NLS-1$ return; } @@ -314,8 +315,8 @@ public class CMainTab extends CLaunchConfigurationTab { WorkbenchLabelProvider labelProvider = new WorkbenchLabelProvider(); WorkbenchContentProvider contentProvider = new WorkbenchContentProvider(); dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider); - dialog.setTitle(LaunchUIPlugin.getResourceString("CMainTab.Program_selection")); //$NON-NLS-1$ - dialog.setMessage(LaunchUIPlugin.getFormattedResourceString( + dialog.setTitle(LaunchMessages.getString("CMainTab.Program_selection")); //$NON-NLS-1$ + dialog.setMessage(LaunchMessages.getFormattedString( "CMainTab.Choose_program_to_run_from_NAME", cproject.getResource().getName())); //$NON-NLS-1$ dialog.setBlockOnOpen(true); dialog.setAllowMultiple(false); @@ -325,21 +326,21 @@ public class CMainTab extends CLaunchConfigurationTab { public IStatus validate(Object[] selection) { if (selection.length == 0 || ! (selection[0] instanceof IFile)) { return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, - LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_file"), null); //$NON-NLS-1$ + LaunchMessages.getString("CMainTab.Selection_must_be_file"), null); //$NON-NLS-1$ } try { ICElement celement = cproject.findElement( ((IFile)selection[0]).getProjectRelativePath()); if (celement == null || (celement.getElementType() != ICElement.C_BINARY && celement.getElementType() != ICElement.C_ARCHIVE)) { return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, - LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$ + LaunchMessages.getString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$ } return new Status(IStatus.OK, LaunchUIPlugin.getUniqueIdentifier(), IStatus.OK, celement.getResource().getName(), null); } catch (Exception ex) { return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, - LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$ + LaunchMessages.getString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$ } } }); @@ -411,8 +412,8 @@ public class CMainTab extends CLaunchConfigurationTab { ILabelProvider labelProvider = new CElementLabelProvider(); ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider); - dialog.setTitle(LaunchUIPlugin.getResourceString("CMainTab.Project_Selection")); //$NON-NLS-1$ - dialog.setMessage(LaunchUIPlugin.getResourceString("CMainTab.Choose_project_to_constrain_search_for_program")); //$NON-NLS-1$ + dialog.setTitle(LaunchMessages.getString("CMainTab.Project_Selection")); //$NON-NLS-1$ + dialog.setMessage(LaunchMessages.getString("CMainTab.Choose_project_to_constrain_search_for_program")); //$NON-NLS-1$ dialog.setElements(projects); ICProject cProject = getCProject(); @@ -478,30 +479,30 @@ public class CMainTab extends CLaunchConfigurationTab { String name = fProjText.getText().trim(); if (name.length() == 0) { - setErrorMessage(LaunchUIPlugin.getResourceString("CMainTab.Project_not_specified")); //$NON-NLS-1$ + setErrorMessage(LaunchMessages.getString("CMainTab.Project_not_specified")); //$NON-NLS-1$ return false; } if (!ResourcesPlugin.getWorkspace().getRoot().getProject(name).exists()) { - setErrorMessage(LaunchUIPlugin.getResourceString("Launch.common.Project_does_not_exist")); //$NON-NLS-1$ + setErrorMessage(LaunchMessages.getString("Launch.common.Project_does_not_exist")); //$NON-NLS-1$ return false; } IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); name = fProgText.getText().trim(); if (name.length() == 0) { - setErrorMessage(LaunchUIPlugin.getResourceString("CMainTab.Program_not_specified")); //$NON-NLS-1$ + setErrorMessage(LaunchMessages.getString("CMainTab.Program_not_specified")); //$NON-NLS-1$ return false; } if (name.equals(".") || name.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$ - setErrorMessage(LaunchUIPlugin.getResourceString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$ + setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$ return false; } if (!project.isOpen()) { - setErrorMessage(LaunchUIPlugin.getResourceString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$ + setErrorMessage(LaunchMessages.getString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$ return false; } if (!project.getFile(name).exists()) { - setErrorMessage(LaunchUIPlugin.getResourceString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$ + setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$ return false; } return true; @@ -563,7 +564,7 @@ public class CMainTab extends CLaunchConfigurationTab { * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() */ public String getName() { - return LaunchUIPlugin.getResourceString("CMainTab.Main"); //$NON-NLS-1$ + return LaunchMessages.getString("CMainTab.Main"); //$NON-NLS-1$ } /* (non-Javadoc) diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java index 05f377dff7f..cc376005347 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java @@ -14,7 +14,7 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.sourcelookup.SourceLookupBlock; import org.eclipse.cdt.launch.internal.ui.LaunchImages; -import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -83,7 +83,7 @@ public class CSourceLookupTab extends CLaunchConfigurationTab */ public String getName() { - return LaunchUIPlugin.getResourceString("CSourceLookupTab.Source"); //$NON-NLS-1$ + return LaunchMessages.getString("CSourceLookupTab.Source"); //$NON-NLS-1$ } /* (non-Javadoc) diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CoreFileDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CoreFileDebuggerTab.java index 0a0028e115a..b5b3509c093 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CoreFileDebuggerTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CoreFileDebuggerTab.java @@ -1,22 +1,26 @@ -/********************************************************************** - * Copyright (c) 2004 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - ***********************************************************************/ -package org.eclipse.cdt.launch.ui; +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Common Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: QNX Software Systems - Initial API and implementation + ******************************************************************************/ +package org.eclipse.cdt.launch.ui; +import java.util.ArrayList; +import java.util.List; import java.util.Map; + import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICDescriptor; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDebugConfiguration; +import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab; +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; +import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.ILaunchConfigurationTab; @@ -25,100 +29,128 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.help.WorkbenchHelp; -public class CoreFileDebuggerTab extends CDebuggerTab { +public class CoreFileDebuggerTab extends AbstractCDebuggerTab { - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) */ - public void createControl( Composite parent ) { - Composite comp = new Composite( parent, SWT.NONE ); - setControl( comp ); - WorkbenchHelp.setHelp( getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB ); - GridLayout topLayout = new GridLayout( 2, false ); - comp.setLayout( topLayout ); - createDebuggerCombo( comp ); - createDebuggerGroup( comp ); + public void createControl(Composite parent) { + Composite comp = new Composite(parent, SWT.NONE); + setControl(comp); + WorkbenchHelp.setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB); + GridLayout topLayout = new GridLayout(1, false); + comp.setLayout(topLayout); + createDebuggerCombo(comp, 1); + createDebuggerGroup(comp, 1); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ - public void setDefaults( ILaunchConfigurationWorkingCopy config ) { - super.setDefaults( config ); - config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE ); + public void setDefaults(ILaunchConfigurationWorkingCopy config) { + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, + ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE); } - /* (non-Javadoc) - * @see org.eclipse.cdt.launch.ui.CDebuggerTab#initializeCommonControls(org.eclipse.debug.core.ILaunchConfiguration) - */ - protected void initializeCommonControls( ILaunchConfiguration config ) { - // no common controls for this tab - } - - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ - public void performApply( ILaunchConfigurationWorkingCopy config ) { - if ( getDebugConfig() != null ) { - config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebugConfig().getID() ); + public void performApply(ILaunchConfigurationWorkingCopy config) { + if (getDebugConfig() != null) { + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebugConfig().getID()); ILaunchConfigurationTab dynamicTab = getDynamicTab(); - if ( dynamicTab == null ) { - config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null ); - } - else { - dynamicTab.performApply( config ); + if (dynamicTab == null) { + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null); + } else { + dynamicTab.performApply(config); } } } - protected void loadDebuggerComboBox( ILaunchConfiguration config, String selection ) { - fDCombo.removeAll(); + public void initializeFrom(ILaunchConfiguration config) { + setInitializing(true); + super.initializeFrom(config); + try { + String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$ + loadDebuggerComboBox(config, id); + } catch (CoreException e) { + } + setInitializing(false); + } + + public boolean isValid(ILaunchConfiguration config) { + if (!validateDebuggerConfig(config)) { + return false; + } + if (super.isValid(config) == false) { + return false; + } + return true; + } + + protected boolean validateDebuggerConfig(ILaunchConfiguration config) { + ICDebugConfiguration debugConfig = getDebugConfig(); + if (debugConfig == null) { + setErrorMessage(LaunchMessages.getString("CoreFileDebuggerTab.No_debugger_available")); //$NON-NLS-1$ + return false; + } + if (!validatePlatform(config, debugConfig)) { + setErrorMessage(LaunchMessages.getString("CoreFileDebuggerTab.platform_is_not_supported")); //$NON-NLS-1$ + return false; + } + return true; + } + protected void loadDebuggerComboBox(ILaunchConfiguration config, String selection) { ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations(); - String projectPlatform = getProjectPlatform( config ); - int x = 0; - int selndx = -1; - for( int i = 0; i < debugConfigs.length; i++ ) { - if ( debugConfigs[i].supportsMode( ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE ) ) { - if ( validatePlatform( config, debugConfigs[i] ) ) { - fDCombo.add( debugConfigs[i].getName() ); - fDCombo.setData( Integer.toString( x ), debugConfigs[i] ); - // select first exact matching debugger for platform or requested selection + String projectPlatform = getProjectPlatform(config); + String defaultSelection = null; + List list = new ArrayList(); + for (int i = 0; i < debugConfigs.length; i++) { + if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) { + if (validatePlatform(config, debugConfigs[i])) { + list.add(debugConfigs[i]); + // select first exact matching debugger for platform or + // requested selection String debuggerPlatform = debugConfigs[i].getPlatform(); - if ( (selndx == -1 && debuggerPlatform.equalsIgnoreCase( projectPlatform )) || selection.equals( debugConfigs[i].getID() ) ) { - selndx = x; + if (defaultSelection == null && debuggerPlatform.equalsIgnoreCase(projectPlatform)) { //$NON-NLS-1$ + defaultSelection = debugConfigs[i].getName(); } - x++; + } + if (selection.equals(debugConfigs[i].getID())) { + defaultSelection = debugConfigs[i].getName(); } } } - // if no selection meaning nothing in config the force initdefault on tab - setInitializeDefault( selection.equals( "" ) ? true : false ); //$NON-NLS-1$ - fDCombo.select( selndx == -1 ? 0 : selndx ); - //The behaviour is undefined for if the callbacks should be triggered for this, - //so to avoid unnecessary confusion, we force an update. - handleDebuggerChanged(); - getControl().getParent().layout( true ); + // if no selection meaning nothing in config the force initdefault on + // tab + setInitializeDefault(selection.equals("") ? true : false); //$NON-NLS-1$ + loadDebuggerCombo((ICDebugConfiguration[])list.toArray(new ICDebugConfiguration[list.size()]), defaultSelection); } - protected boolean validatePlatform( ILaunchConfiguration config, ICDebugConfiguration debugConfig ) { - String projectPlatform = getProjectPlatform( config ); + protected boolean validatePlatform(ILaunchConfiguration config, ICDebugConfiguration debugConfig) { + String projectPlatform = getProjectPlatform(config); String debuggerPlatform = debugConfig.getPlatform(); - return ( debuggerPlatform.equals( "*" ) || debuggerPlatform.equalsIgnoreCase( projectPlatform ) ); //$NON-NLS-1$ + return (projectPlatform.equals("*") || debuggerPlatform.equals("*") || debuggerPlatform.equalsIgnoreCase(projectPlatform)); //$NON-NLS-1$ //$NON-NLS-2$ } - private String getProjectPlatform( ILaunchConfiguration config ) { - ICElement ce = getContext( config, null ); + private String getProjectPlatform(ILaunchConfiguration config) { + ICElement ce = getContext(config, null); String projectPlatform = "*"; //$NON-NLS-1$ - if ( ce != null ) { + if (ce != null) { try { - ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription( ce.getCProject().getProject(), false ); - if ( descriptor != null ) { + ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(ce.getCProject().getProject(), false); + if (descriptor != null) { projectPlatform = descriptor.getPlatform(); } - } - catch( Exception e ) { + } catch (Exception e) { } } return projectPlatform; } -} +}
\ No newline at end of file |