diff options
author | James Blackburn | 2009-06-28 15:58:15 +0000 |
---|---|---|
committer | James Blackburn | 2009-06-28 15:58:15 +0000 |
commit | 559235c5d90d80d1746d9c2b3bc6e2b05f886357 (patch) | |
tree | 0a94b248fb9efee67528370754287b812fea8fb0 /core | |
parent | c8d7d6591c3270e4971e2fba2c7a9cf4e3826365 (diff) | |
download | org.eclipse.cdt-559235c5d90d80d1746d9c2b3bc6e2b05f886357.tar.gz org.eclipse.cdt-559235c5d90d80d1746d9c2b3bc6e2b05f886357.tar.xz org.eclipse.cdt-559235c5d90d80d1746d9c2b3bc6e2b05f886357.zip |
Bug 279607 Code Formatter should treat DefaultScope formatter profiles as built-in
Diffstat (limited to 'core')
2 files changed, 21 insertions, 9 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java index 99d3297ee31..d3c3de31060 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java @@ -13,9 +13,11 @@ package org.eclipse.cdt.internal.ui.preferences.formatter; import java.util.ArrayList; import java.util.Collections; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.preferences.DefaultScope; import org.eclipse.core.runtime.preferences.IScopeContext; @@ -58,6 +60,25 @@ public class FormatterProfileManager extends ProfileManager { profiles.add(gnuProfile); final Profile whitesmithsProfile= new BuiltInProfile(WHITESMITHS_PROFILE, FormatterMessages.ProfileManager_whitesmiths_profile_name, getWhitesmithsSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); profiles.add(whitesmithsProfile); + + // Add the Profiles which are at default scope and hence are contributed by a product. + try { + List<Profile> defaultProfiles= new FormatterProfileStore(profileVersioner).readProfiles(new DefaultScope()); + if (defaultProfiles != null) { + Map<String, Profile> profMap= new LinkedHashMap<String, Profile>(); + // Add the already loaded / created profiles to a map + for (Profile p : profiles) + profMap.put(p.getID(), p); + + // Default profiles override any colliding profiles already in the list + for (Profile p : defaultProfiles) + profMap.put(p.getID(), new BuiltInProfile(p.getName(), p.getName(), p.getSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind())); + profiles= new ArrayList<Profile>(profMap.values()); + } + } catch (CoreException e) { + CUIPlugin.log(e); + } + return profiles; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java index 0d0e2d952c3..8e5560f5700 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java @@ -21,7 +21,6 @@ import java.util.Observer; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ProjectScope; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.preferences.DefaultScope; import org.eclipse.core.runtime.preferences.IScopeContext; import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; @@ -281,14 +280,6 @@ public abstract class ProfileConfigurationBlock { } catch (CoreException e) { CUIPlugin.log(e); } - if (profiles == null) { - try { - // bug 129427 - profiles= fProfileStore.readProfiles(new DefaultScope()); - } catch (CoreException e) { - CUIPlugin.log(e); - } - } if (profiles == null) profiles= new ArrayList<Profile>(); |