/** Updates the folder path to reflect the given type */
  private void updateFolderPath(TypeInfo type) {
    String wsFolderPath = mValues.folderPath;
    String newPath = null;
    FolderConfiguration config = mValues.configuration;
    ResourceQualifier qual = config.getInvalidQualifier();
    if (qual == null) {
      // The configuration is valid. Reformat the folder path using the canonical
      // value from the configuration.
      newPath = RES_FOLDER_ABS + config.getFolderName(type.getResFolderType());
    } else {
      // The configuration is invalid. We still update the path but this time
      // do it manually on the string.
      if (wsFolderPath.startsWith(RES_FOLDER_ABS)) {
        wsFolderPath =
            wsFolderPath.replaceFirst(
                "^(" + RES_FOLDER_ABS + ")[^-]*(.*)", // $NON-NLS-1$ //$NON-NLS-2$
                "\\1" + type.getResFolderName() + "\\2"); // $NON-NLS-1$ //$NON-NLS-2$
      } else {
        newPath = RES_FOLDER_ABS + config.getFolderName(type.getResFolderType());
      }
    }

    if (newPath != null && !newPath.equals(wsFolderPath)) {
      mValues.folderPath = newPath;
    }
  }
  /** Given a folder name, such as "drawable", select the corresponding type in the dropdown. */
  void selectTypeFromFolder(String folderName) {
    List<TypeInfo> matches = new ArrayList<TypeInfo>();
    boolean selected = false;

    TypeInfo selectedType = getSelectedType();
    for (TypeInfo type : sTypes) {
      if (type.getResFolderName().equals(folderName)) {
        matches.add(type);
        selected |= type == selectedType;
      }
    }

    if (matches.size() == 1) {
      // If there's only one match, select it if it's not already selected
      if (!selected) {
        selectType(matches.get(0));
      }
    } else if (matches.size() > 1) {
      // There are multiple type candidates for this folder. This can happen
      // for /res/xml for example. Check to see if one of them is currently
      // selected. If yes, leave the selection unchanged. If not, deselect all type.
      if (!selected) {
        selectType(null);
      }
    } else {
      // Nothing valid was selected.
      selectType(null);
    }
  }