Beispiel #1
0
  /**
   * Create an in-memory document for the given file and user iff one does not exist.
   *
   * @param file file to edit
   */
  public synchronized PadDocument create(IFile file) throws IOException, JavaModelException {
    String path = file.getFullPath().toString();
    if (documents.containsKey(path)) {
      return get(path);
    }

    if (JavaCore.isJavaLikeFileName(file.getName())) {
      JavaCore.createCompilationUnitFrom(file).getWorkingCopy(this, null);
      // now that the Java model is settled, install the highlighter, which causes reconciliation
      new PadSemanticHighlighter(get(path, JavaPadDocument.class));
    } else {
      documents.put(path, new PadDocument(this, collaboration.get(file)));
    }

    return get(path);
  }
Beispiel #2
0
  @Override
  public synchronized IBuffer createBuffer(final ICompilationUnit workingCopy) {
    String path = workingCopy.getPath().toString();
    if (documents.containsKey(path)) {
      return get(path, JavaPadDocument.class);
    }

    JavaPadDocument doc;
    IFile file =
        workingCopy.getResource() instanceof IFile ? (IFile) workingCopy.getResource() : null;
    try {
      documents.put(
          workingCopy.getPath().toString(),
          doc = new JavaPadDocument(this, collaboration.get(file), workingCopy));
    } catch (IOException ioe) {
      ioe.printStackTrace(); // XXX
      throw new Error(ioe); // XXX
    }
    return doc;
  }
Beispiel #3
0
 private PadDocumentOwner(String username) {
   this.username = username;
   this.collaboration = Collab.of(username);
 }