Exemple #1
0
  private void updateTitleFromFileTable() {
    // User edited the title field. We have no business here
    if (userEditedTitle) {
      return;
    }
    List<String> names = files.getFileNames();
    if (names.size() == 0) {
      setTitleText("");
    } else {
      Iterator<String> iterator = names.iterator();
      String longestPrefix = iterator.next();
      while (iterator.hasNext()) {
        String next = iterator.next();
        for (int i = 0; i < Math.min(longestPrefix.length(), next.length()); i++) {
          if (next.charAt(i) != longestPrefix.charAt(i)) {
            longestPrefix = longestPrefix.substring(0, i);
            break;
          }
        }
      }
      // The users like to name files with underscores separating different fields.
      // If we detect more than 1 underscore, we will try to remove everything beyond the last
      // underscore
      // That takes care of test_S1, test_S2, test_S3 or test_Inj1, test_Inj2 type of repeats,
      // resulting
      // with just "test".

      // If there is just one underscore, we remove it if it is the last one.
      int numUnderscores = longestPrefix.length() - longestPrefix.replaceAll("_", "").length();
      if (numUnderscores <= 1) {
        longestPrefix = longestPrefix.replaceAll("_$", "");
      } else {
        longestPrefix = longestPrefix.replaceAll("_[^_]*$", "");
      }
      setTitleText(longestPrefix + paramsEditor.getTitleSuffix());
    }
    updateOutputLocation();
  }