public void profileChanged(CustomProfile profile) {
    if (!profile.isSharedProfile()) {
      updateProfilesWithName(profile.getID(), profile, true);
    }

    notifyObservers(SETTINGS_CHANGED_EVENT);
  }
  public void profileRenamed(CustomProfile profile, String oldID) {
    fProfiles.remove(oldID);
    fProfiles.put(profile.getID(), profile);

    if (!profile.isSharedProfile()) {
      updateProfilesWithName(oldID, profile, false);
    }

    Collections.sort(fProfilesByName);
    notifyObservers(PROFILE_RENAMED_EVENT);
  }
  @Override
  protected void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) {
    super.updateProfilesWithName(oldName, newProfile, applySettings);

    IEclipsePreferences node = fPreferencesAccess.getInstanceScope().getNode(JavaUI.ID_PLUGIN);
    String name = node.get(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE, null);
    if (name != null && name.equals(oldName)) {
      if (newProfile == null) {
        node.remove(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE);
      } else {
        node.put(CleanUpConstants.CLEANUP_ON_SAVE_PROFILE, newProfile.getID());
      }
    }
  }
  public void profileReplaced(CustomProfile oldProfile, CustomProfile newProfile) {
    fProfiles.remove(oldProfile.getID());
    fProfiles.put(newProfile.getID(), newProfile);
    fProfilesByName.remove(oldProfile);
    fProfilesByName.add(newProfile);
    Collections.sort(fProfilesByName);

    if (!oldProfile.isSharedProfile()) {
      updateProfilesWithName(oldProfile.getID(), null, false);
    }

    setSelected(newProfile);
    notifyObservers(PROFILE_CREATED_EVENT);
    notifyObservers(SELECTION_CHANGED_EVENT);
  }
  public boolean deleteProfile(CustomProfile profile) {
    int index = fProfilesByName.indexOf(profile);

    fProfiles.remove(profile.getID());
    fProfilesByName.remove(profile);

    profile.setManager(null);

    if (index >= fProfilesByName.size()) index--;
    fSelected = fProfilesByName.get(index);

    if (!profile.isSharedProfile()) {
      updateProfilesWithName(profile.getID(), null, false);
    }

    notifyObservers(PROFILE_DELETED_EVENT);
    return true;
  }