コード例 #1
0
 public Map<String, String> retrievePreferences(PreferencesLookupDelegate delegate) {
   ProfileManager profileManager = ProfileManager.getInstance();
   final PreferenceKey activeProfileKey = profileManager.getActiveProfileKey();
   if (activeProfileKey != null) {
     final String profileId =
         delegate.getString(activeProfileKey.getQualifier(), activeProfileKey.getName());
     if (profileId != null && profileId.length() != 0) {
       for (IProfile profile : profileManager.getBuiltInProfiles()) {
         if (profileId.equals(profile.getID())) {
           return profile.getSettings();
         }
       }
       for (IProfile profile : profileManager.getCustomProfiles()) {
         if (profileId.equals(profile.getID())) {
           return profile.getSettings();
         }
       }
     } else {
       List<IProfile> builtInProfiles = profileManager.getBuiltInProfiles();
       if (builtInProfiles != null && !builtInProfiles.isEmpty()) {
         return builtInProfiles.get(0).getSettings();
       }
     }
   }
   // Last resort - Collect only this formatters' preferences.
   final Map<String, String> result = new HashMap<String, String>();
   final PreferenceKey[] keys = getPreferenceKeys();
   if (keys != null) {
     for (PreferenceKey prefKey : keys) {
       final String key = prefKey.getName();
       result.put(key, delegate.getString(prefKey.getQualifier(), key));
     }
   }
   return result;
 }
コード例 #2
0
 public void savePreferences(Map<String, String> preferences, IPreferencesSaveDelegate delegate) {
   final PreferenceKey[] keys = getPreferenceKeys();
   if (keys != null) {
     for (PreferenceKey prefKey : keys) {
       final String key = prefKey.getName();
       if (preferences.containsKey(key)) {
         final String value = preferences.get(key);
         delegate.setString(prefKey.getQualifier(), key, value);
       }
     }
   }
 }