diff options
author | Michael Rennie | 2007-07-30 18:57:46 +0000 |
---|---|---|
committer | Michael Rennie | 2007-07-30 18:57:46 +0000 |
commit | fe7a7a06ad6027c408352f65c1ab371178afa158 (patch) | |
tree | f4cc2e4d107018f6e43a9d9d4ec7371b58a86079 /org.eclipse.debug.core | |
parent | 4187589aa0293ff8ee67adc9e13cbc9c809ebf78 (diff) | |
download | eclipse.platform.debug-fe7a7a06ad6027c408352f65c1ab371178afa158.tar.gz eclipse.platform.debug-fe7a7a06ad6027c408352f65c1ab371178afa158.tar.xz eclipse.platform.debug-fe7a7a06ad6027c408352f65c1ab371178afa158.zip |
Bug 191379 Console encoding does not match workspace encoding
Diffstat (limited to 'org.eclipse.debug.core')
5 files changed, 52 insertions, 8 deletions
diff --git a/org.eclipse.debug.core/buildnotes_platform-debug.html b/org.eclipse.debug.core/buildnotes_platform-debug.html index 86af06b30..0b2c7ecc8 100644 --- a/org.eclipse.debug.core/buildnotes_platform-debug.html +++ b/org.eclipse.debug.core/buildnotes_platform-debug.html @@ -11,6 +11,13 @@ <h2>Summary of API changes in 3.4</h2> +<h3>July 31, 2007</h3> +<ul> +<li>A new method <code>ILaunchManager#getEncoding(ILaunchConfiguration)</code> was added to allow consumers of +the <code>DebugPlugin#ATTR_CONSOLE_ENCODING</code> preference to get the encoding to use when launching the +configuration specified in as the parameter to getEncoding(..)</li> +</ul> + <h2>July 31, 2007</h2> <h3>Problem Reports Fixed</h3> <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=198248">198248</a>: NPE at org.eclipse.debug.ui.CommonTab.getDefaultSharedConfigLocation<br> diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java index 224a9285f..08eb4a46c 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java @@ -749,7 +749,7 @@ public class DebugPlugin extends Plugin { * @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 + * canceled * @exception CoreException if the exec fails * @see Runtime * diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java index 606338fa2..15337bc05 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java @@ -140,7 +140,25 @@ public interface ILaunchManager { * unable to resolve a variable in an environment variable's value * @since 3.0 */ - public String[] getEnvironment(ILaunchConfiguration configuration) throws CoreException; + public String[] getEnvironment(ILaunchConfiguration configuration) throws CoreException; + /** + * This method returns the character encoding to use when launching the specified <code>ILaunchConfiguration</code>. + * The returned encoding can be derived from one of three places in the following order: + * <ol> + * <li>An attribute saved on the configuration itself (where no attribute means use the default encoding).</li> + * <li>The mapped resources for the configuration, in the event one of them has a specific encoding that + * is not the workspace default. If there are more than one mapped resource we optimistically ask only the first resource + * for its encoding.</li> + * <li>We ask the <code>ResourcesPlugin</code> for the workspace preference (which resolves back to the system + * property <code>file.encoding</code> if the user has made no changes to the workspace encoding preference).</li> + * </ol> + * @param configuration the <code>ILaunchConfiguration</code> to get the encoding for + * @return the encoding to use when launching the specified <code>ILaunchConfiguration</code> + * @throws CoreException + * + * @since 3.4 + */ + public String getEncoding(ILaunchConfiguration configuration) throws CoreException; /** * Returns a handle to the launch configuration contained * in the specified file. The file is not verified to exist diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java index 646f933b3..cfa91171b 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java @@ -707,11 +707,7 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig } else { launch.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, null); } - String attribute = getAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, (String)null); - if(attribute == null) { - attribute = ResourcesPlugin.getEncoding(); - } - launch.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, attribute); + launch.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, getLaunchManager().getEncoding(this)); // perform initial pre-launch sanity checks monitor.subTask(DebugCoreMessages.LaunchConfiguration_8); diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java index 9818763a8..160d7d4c4 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java @@ -865,7 +865,30 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe fLaunchConfigurationIndex.clear(); } } - + + /* (non-Javadoc) + * @see org.eclipse.debug.core.ILaunchManager#getEncoding(org.eclipse.debug.core.ILaunchConfiguration) + */ + public String getEncoding(ILaunchConfiguration configuration) throws CoreException { + String encoding = configuration.getAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, (String)null); + if(encoding == null) { + IResource[] resources = configuration.getMappedResources(); + if(resources != null && resources.length > 0) { + IResource res = resources[0]; + if(res instanceof IFile) { + return ((IFile)res).getCharset(); + } + else if(res instanceof IContainer) { + return ((IContainer)res).getDefaultCharset(); + } + } + else { + return ResourcesPlugin.getEncoding(); + } + } + return encoding; + } + /** * The launch config name cache is cleared when a config is added, deleted or changed. */ |