public static String abbreviatePath(String path, int limitLength)
  {
    if (path.length() <= limitLength)
      return path;
    int k = path.indexOf("/", 1);
    if (k < 0)
      return "..." + path.substring(path.length() - limitLength + 3);
    k = path.indexOf("/", k + 1);
    if (k < 0)
      return "..." + path.substring(path.length() - limitLength + 3);
    String prefix = path.substring(0, k + 1);
    String suffix = path.substring(k + 1);
    k = suffix.indexOf('/', 1);
    if (k < 0)
      return "..." + path.substring(path.length() - limitLength + 3);
    int limit = MAX_LABEL_LENGTH - prefix.length() - 3;
    while (k >= 0 && suffix.length() > limit)
    {
      suffix = suffix.substring(k);
      k = suffix.indexOf('/', 1);
    }
    if (suffix.length() <= limit)
      return prefix + "..." + suffix;
    else
      return "..." + path.substring(path.length() - limitLength + 3);
  }