/**
   * Get a config based on a name.
   *
   * <p>The first item in the config list with a matching name is returned. in all other cases
   * returns null
   *
   * @return <code>ProgrammerConfig;</code>
   */
  public ProgrammerConfig getConfigByName(String ConfigName) {
    // Get all configs ids, then load all configs and
    // add their names to a Map
    Set<String> allids = getAllConfigIDs();

    for (String id : allids) {
      ProgrammerConfig cfg = getConfig(id);
      if (cfg.getName().equals(ConfigName)) return cfg;
    }
    return null;
  }
  /**
   * Get a list of all programmer configuration names currently in the preferences.
   *
   * <p>The list is returned as a mapping of id values to config names.
   *
   * @return <code>Map&lt;String id, String name&gt;</code>
   */
  public Map<String, String> getAllConfigNames() {
    // Get all configs ids, then load all configs and
    // add their names to a Map
    Set<String> allids = getAllConfigIDs();

    Map<String, String> idNameMap = new HashMap<String, String>(allids.size());

    for (String id : allids) {
      ProgrammerConfig cfg = getConfig(id);
      idNameMap.put(id, cfg.getName());
    }
    return idNameMap;
  }
  /**
   * Deletes the given configuration from the preference storage area.
   *
   * <p>Note: This Object is still valid and further calls to {@link #saveConfig(ProgrammerConfig)}
   * will add this configuration back to the preference storage.
   *
   * @throws BackingStoreException
   */
  public void deleteConfig(ProgrammerConfig config) throws BackingStoreException {

    String id = config.getId();

    // If the config is in the cache, remove it from the cache
    if (fConfigsCache.containsKey(id)) {
      fConfigsCache.remove(id);
    }

    // Remove the Preference node for the config and flush the preferences
    // If the node does not exist do nothing - no need to create the node
    // just to remove it again
    if (fPreferences.nodeExists(id)) {
      Preferences cfgnode = fPreferences.node(id);
      cfgnode.removeNode();
      fPreferences.flush();
    }
  }
  /**
   * Save the given Configuration to the persistent storage.
   *
   * <p>Only {@link ProgrammerConfig} objects obtained with the {@link #getConfigEditable(String)}
   * method should be passed to this method, however this is currently not enforced.
   *
   * @param config <code>ProgrammerConfig</code> to be saved.
   * @throws BackingStoreException If this configuration cannot be written to the preference storage
   *     area.
   */
  public void saveConfig(ProgrammerConfig config) throws BackingStoreException {

    // save the config
    config.save(getConfigPreferences(config));

    // If the config is already in the cache update the cached config to the
    // new values
    if (fConfigsCache.containsKey(config.getId())) {
      ProgrammerConfig oldconfig = fConfigsCache.get(config.getId());
      oldconfig.loadFromConfig(config);
    } else {
      // Add the new config to the cache
      fConfigsCache.put(config.getId(), config);
    }

    // Remove from the pending id list (if it is a newly created config)
    fPendingIds.remove(config.getId());
  }
 /**
  * Get the preference node for the given configuration
  *
  * @param config
  * @return
  */
 private Preferences getConfigPreferences(ProgrammerConfig config) {
   String id = config.getId();
   return fPreferences.node(id);
 }