Exemplo n.º 1
0
 /** Removes save cookie from the DO. */
 final void removeSaveCookie() {
   DataObject dataObj = getDataObject();
   // add Save cookie to the data object
   if (dataObj instanceof MultiDataObject) {
     if (dataObj.getCookie(SaveCookie.class) == this) {
       getCookieSet((MultiDataObject) dataObj).remove(this);
     }
   }
 }
  /**
   * 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);
    }
  }
Exemplo n.º 4
0
 /**
  * Constructor
  *
  * @param obj data object we belong to. The appropriate editor support is acquired as the
  *     DataObject's EditorSupport.class cookie.
  */
 public Editor(DataObject obj) {
   this(obj, (EditorSupport) obj.getCookie(EditorSupport.class));
 }