Esempio n. 1
0
  public static String treePathName(CTreeNode node) {
    if (IPreferences.getDefaultPath().length() + 1 + node.getProject().getName().length()
        > node.getLocalPath().length()) return "";

    return node.getLocalPath()
        .substring(
            IPreferences.getDefaultPath().length() + node.getProject().getName().length() + 1,
            node.getLocalPath().length());
  }
Esempio n. 2
0
  public static String relativePath(String apesFile, String pogFile) {

    if (!apesFile.startsWith(IPreferences.getDefaultPath())) return apesFile;

    if (!pogFile.startsWith(IPreferences.getDefaultPath())) return apesFile;
    apesFile = apesFile.replaceFirst(IPreferences.getDefaultPath(), "");
    pogFile = pogFile.replaceFirst(IPreferences.getDefaultPath(), "");
    String[] apesSlit = apesFile.split(File.separator);
    String[] pogSlit = pogFile.split(File.separator);
    String res = "";
    int tmp = 0;
    for (int i = Math.min(apesSlit.length, pogSlit.length); i > 0; i--) {
      if (apesSlit[i - 1].compareTo(pogSlit[i - 1]) != 0) tmp = i - 1;
    }
    for (int i = tmp + 1; i < pogSlit.length; i++) res = res.concat(".." + File.separator);
    for (int i = tmp; i < apesSlit.length; i++) res = res.concat(apesSlit[i] + File.separator);

    res = res.substring(0, res.length() - 1);
    return res;
  }