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 defaultProfiles= new FormatterProfileStore(profileVersioner).readProfiles(new DefaultScope()); + if (defaultProfiles != null) { + Map profMap= new LinkedHashMap(); + // 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(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();