예제 #1
0
  /**
   * Accomodates the paths opened in editor to the given new path. This should be used only to open
   * existing directories.
   *
   * @param newPath
   * @param openLast
   * @param lastRevision
   * @throws SVNException
   */
  public void accomodate(String newPath, boolean openLast, long lastRevision) throws SVNException {
    // If there's a file opened, always closing it.
    if (fileOnTop) {
      // Checking if we don't want to have the same file opened.
      if (newPath.equals(pathsStack.peek())) return;

      editor.closeFile(pathsStack.pop(), null);
      fileOnTop = false;
    }

    // Poping and closing all opened directories which
    // don't fit into the new path.
    while ((!pathsStack.empty()) && (!newPath.startsWith(pathsStack.peek()))) {
      pathsStack.pop();
      editor.closeDir();
    }

    // Opening directories from the new path and putting their paths on the
    // stack.
    String currentPath = pathsStack.empty() ? "/" : pathsStack.peek();
    String[] parts = newPath.substring(currentPath.length()).split("[/]");
    for (int i = 0; i < (openLast ? parts.length : parts.length - 1); i++) {
      /*
       * A path part may be empty in two cases:
       * 1. pathStack.peek() is equal to newPath
       * 2. newPath = properPath + "/"
       * In both cases we don't want to open the "empty" directory.
       */
      if (!"".equals(parts[i])) {
        currentPath += Tools.addPaths(parts[i], "");
        editor.openDir(currentPath, lastRevision);
        pathsStack.push(currentPath);
      }
    }
  }
예제 #2
0
 public void addPath(String path, boolean file) {
   pathsStack.push(file ? path : Tools.addPaths(path, ""));
   fileOnTop = file;
 }