Project: JDT
Bug 129427 Default Preferences can't be used to set Java Formatter Profile
Reported: 2006-02-25 01:33:27 | Status: resolved fixed

I am attempting to use the default preferences mechanism (via the -pluginCustomization switch) to establish default values for the Java Code Formatter profile to be used (among a whole range of other preference defaults). This allows developers to create new workspaces without having to reimport/reselect the corporate standard - the defaults carry across to the new workspaces. Under 3.1.1, it half worked. I could define a default value for org.eclipse.jdt.ui/org.eclipse.jdt.ui.formatterprofiles and it would appear in the list of available profiles, but the selecting of this profile via org.eclipse.jdt.ui/formatter_profile did not work (I did add the underscore to indicate a custom profile). Looking at the code, org.eclipse.jdt.internal.ui.preferences.formatter.ProfileStore was fetching the custom profiles via PreferenceConstants.getPreferenceStore().getString() which eventually searched both the instance and default scopes. However, org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager, which establishes the active profile calls InstanceScope.getNode().get() which only checks the Instance scope and does not include the default scope. In 3.2M5, ProfileStore has now been altered to use InstanceScope.... The net effect is that now the profile doesn't even appear in the list. From my perspective, the default preference mechanism is very useful to establish a standard environment for all our developers, and having the ability to set all preference defaults this way is vital in doing this. At a minimum, I believe this case needs to be fixed so the default scope is checked as well for all the preferences associated with setting the formatter profile. More generally, default preferences need to work consistently across all preferences.

Files changed in fix:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileManager.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileStore.java