コード例 #1
0
ファイル: EditorSupport.java プロジェクト: kimtang/studio
 /** 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);
     }
   }
 }
コード例 #2
0
ファイル: EditorSupport.java プロジェクト: kimtang/studio
 public void propertyChange(java.beans.PropertyChangeEvent ev) {
   if (Node.PROP_DISPLAY_NAME.equals(ev.getPropertyName())) {
     updateTitles();
   }
   if (Node.PROP_ICON.equals(ev.getPropertyName())) {
     DataObject obj = getDataObject();
     if (obj.isValid()) {
       editor.setIcon(obj.getNodeDelegate().getIcon(java.beans.BeanInfo.ICON_COLOR_16x16));
     }
   }
 }
コード例 #3
0
ファイル: EditorSupport.java プロジェクト: kimtang/studio
 /** Overrides superclass method. Initializes editor component. */
 protected void initializeCloneableEditor(CloneableEditor editor) {
   DataObject obj = getDataObject();
   if (obj.isValid()) {
     org.openide.nodes.Node ourNode = obj.getNodeDelegate();
     editor.setActivatedNodes(new org.openide.nodes.Node[] {ourNode});
     editor.setIcon(ourNode.getIcon(java.beans.BeanInfo.ICON_COLOR_16x16));
     NodeListener nl = new DataNodeListener(editor);
     ourNode.addNodeListener(WeakListener.node(nl, ourNode));
     nodeL = nl;
   }
 }
コード例 #4
0
  /**
   * 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);
    }
  }
コード例 #5
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);
    }
  }
コード例 #6
0
ファイル: EditorSupport.java プロジェクト: kimtang/studio
 /**
  * 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));
 }