/**
   * return document object for this file
   *
   * @throws CollabException
   * @return document
   */
  public StyledDocument getDocument() throws CollabException {
    try {
      FileObject file = getFileObject();

      // Get the DataObject
      DataObject dataObject = DataObject.find(file);

      if (dataObject == null) {
        throw new IllegalArgumentException("No DataObject found for file \"" + getName() + "\"");
      }

      // Get the Swing document for the file
      EditorCookie cookie = (EditorCookie) dataObject.getCookie(EditorCookie.class);

      StyledDocument document = cookie.openDocument();

      return document;
    } catch (org.openide.loaders.DataObjectNotFoundException notFound) {
      throw new CollabException(notFound);
    } catch (java.io.IOException io) {
      throw new CollabException(io);
    }
  }