1 11 package org.eclipse.jdt.internal.ui.preferences.cleanup; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 import org.eclipse.core.runtime.preferences.IEclipsePreferences; 17 import org.eclipse.core.runtime.preferences.IScopeContext; 18 19 import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; 20 21 import org.eclipse.jdt.ui.JavaUI; 22 23 import org.eclipse.jdt.internal.ui.preferences.PreferencesAccess; 24 import org.eclipse.jdt.internal.ui.preferences.formatter.IProfileVersioner; 25 import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager; 26 27 public class CleanUpProfileManager extends ProfileManager { 28 29 public static KeySet[] KEY_SETS= { 30 new KeySet(JavaUI.ID_PLUGIN, new ArrayList (CleanUpConstants.getEclipseDefaultSettings().keySet())) 31 }; 32 33 private final PreferencesAccess fPreferencesAccess; 34 35 public CleanUpProfileManager(List profiles, IScopeContext context, PreferencesAccess preferencesAccess, IProfileVersioner profileVersioner) { 36 super(profiles, context, preferencesAccess, profileVersioner, KEY_SETS, CleanUpConstants.CLEANUP_PROFILE, CleanUpConstants.CLEANUP_SETTINGS_VERSION_KEY); 37 fPreferencesAccess= preferencesAccess; 38 } 39 40 43 public Profile getDefaultProfile() { 44 return getProfile(CleanUpConstants.DEFAULT_PROFILE); 45 } 46 47 50 protected void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) { 51 super.updateProfilesWithName(oldName, newProfile, applySettings); 52 53 IEclipsePreferences node= fPreferencesAccess.getInstanceScope().getNode(JavaUI.ID_PLUGIN); 54 String name= node.get(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE, null); 55 if (name != null && name.equals(oldName)) { 56 if (newProfile == null) { 57 node.remove(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE); 58 } else { 59 node.put(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE, newProfile.getID()); 60 } 61 } 62 } 63 64 } 65 | Popular Tags |