Exemplo n.º 1
0
 /**
  * Get the names of all profiles stored in this profile manager, sorted alphabetically. Unless the
  * set of profiles has been modified between the two calls, the sequence is guaranteed to
  * correspond to the one returned by <code>getSortedProfiles</code>.
  *
  * @return All names, sorted alphabetically
  * @see #getSortedProfiles()
  */
 public String[] getSortedDisplayNames() {
   final String[] sortedNames = new String[fProfilesByName.size()];
   int i = 0;
   for (IProfile curr : fProfilesByName) {
     sortedNames[i++] = curr.getName();
   }
   return sortedNames;
 }
Exemplo n.º 2
0
 public boolean containsName(String name) {
   for (IProfile curr : fProfilesByName) {
     if (name.equals(curr.getName())) {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 3
0
 /**
  * Create and initialize a new profile manager.
  *
  * @param profiles Initial custom profiles (List of type <code>CustomProfile</code>)
  * @param profileVersioner
  */
 public ProfileManager(List<IProfile> profiles) {
   fProfiles = new HashMap<String, IProfile>();
   fProfilesByName = new ArrayList<IProfile>();
   for (final IProfile profile : profiles) {
     fProfiles.put(profile.getID(), profile);
     fProfilesByName.add(profile);
   }
   Collections.sort(fProfilesByName);
   if (!fProfilesByName.isEmpty()) {
     fSelected = fProfilesByName.get(0);
   }
 }
Exemplo n.º 4
0
 public void addProfile(IProfile profile) {
   if (profile instanceof CustomProfile) {
     CustomProfile newProfile = (CustomProfile) profile;
     // newProfile.setManager(this);
     final CustomProfile oldProfile = (CustomProfile) fProfiles.get(profile.getID());
     if (oldProfile != null) {
       fProfiles.remove(oldProfile.getID());
       fProfilesByName.remove(oldProfile);
       // oldProfile.setManager(null);
     }
     fProfiles.put(profile.getID(), profile);
     fProfilesByName.add(profile);
     Collections.sort(fProfilesByName);
     fSelected = newProfile;
     fDirty = true;
   }
 }
Exemplo n.º 5
0
  public IProfile rename(IProfile profile, String newName) {
    final String trimmed = newName.trim();
    if (trimmed.equals(profile.getName())) return profile;
    if (profile.isBuiltInProfile()) {
      CustomProfile newProfile =
          new CustomProfile(
              trimmed, profile.getSettings(), profile.getFormatterId(), profile.getVersion());
      addProfile(newProfile);
      fDirty = true;
      return newProfile;
    } else {
      CustomProfile cProfile = (CustomProfile) profile;

      String oldID = profile.getID();
      cProfile.fName = trimmed;

      fProfiles.remove(oldID);
      fProfiles.put(profile.getID(), profile);

      Collections.sort(fProfilesByName);
      fDirty = true;
      return cProfile;
    }
  }
Exemplo n.º 6
0
 public void setSelected(IProfile profile) {
   final IProfile newSelected = fProfiles.get(profile.getID());
   if (newSelected != null && !newSelected.equals(fSelected)) {
     fSelected = newSelected;
   }
 }