/**
   * return editor cookie for this filehandler
   *
   * @throws CollabException
   * @return cookie
   */
  public EditorCookie getEditorCookie() throws CollabException {
    Debug.log(
        this,
        "CollabJavaHandler, "
            + // NoI18n
            "geteditorCookie for file: "
            + getName()); // NoI18n

    try {
      if (editorCookie == null) {
        FileObject file = getFileObject();

        // Get the FileObject
        if (file == null) {
          return null;
        }

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

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

        // Get the editor cookie for the file
        editorCookie = (EditorCookie) dataObject.getCookie(EditorCookie.class);

        // add reset Document Reference Listener
        addResetDocumentRefListener(editorCookie, getEditorObservableCookie());
      }

      return editorCookie;
    } catch (org.openide.loaders.DataObjectNotFoundException notFound) {
      throw new CollabException(notFound);
    } catch (java.io.IOException io) {
      throw new CollabException(io);
    }
  }
  /**
   * 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);
    }
  }