コード例 #1
0
  /** isDocumentModified */
  public boolean isDocumentModified() throws CollabException {
    boolean isModified = false;
    EditorCookie cookie = getEditorCookie();

    if (cookie != null) {
      isModified = cookie.isModified();
    }

    Debug.log(
        this, "CollabJavaHandler, isModified: " + isModified + " for file " + getName()); // NoI18n

    return isModified;
  }
コード例 #2
0
  /** saveDocument */
  public boolean saveDocument() throws CollabException {
    Debug.log(
        this, // NoI18n
        "CollabJavaHandler, saving document: " + getName()); // NoI18n

    try {
      EditorCookie cookie = getEditorCookie();

      if (cookie != null) {
        cookie.saveDocument();
      }
    } catch (IOException iox) {
      Debug.log(
          this, // NoI18n
          "CollabJavaHandler, Exception occured while saving the document: " // NoI18n
              + getName()); // NoI18n

      return false;
    }

    return true;
  }
コード例 #3
0
  /**
   * 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);
    }
  }