Example #1
0
  @Override
  public void addMatches(ArrayList<FindResult> findResults) {
    int matchesToAdd = Math.min(findResults.size(), MAX_COUNT - matchCount_);

    if (matchesToAdd > 0) {
      matchCount_ += matchesToAdd;
      table_.addItems(findResults.subList(0, matchesToAdd), false);
    }

    if (matchesToAdd != findResults.size()) showOverflow();
  }
Example #2
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();
  }
Example #3
0
 /** Limits value to [min, max], so that min <= value <= max. */
 private static int limit(int min, int value, int max) {
   return Math.min(Math.max(min, value), max);
 }