This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 34815

Summary: Supply a utility method to extract a FileObject from Document
Product: editor Reporter: Petr Jiricka <pjiricka>
Component: -- Other --Assignee: issues@editor <issues>
Status: VERIFIED FIXED    
Severity: blocker    
Priority: P3    
Version: 3.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description Petr Jiricka 2003-07-09 09:59:27 UTC
Currently, class
org.netbeans.modules.editor.NbEditorUtilities
contains method

public static DataObject getDataObject(Document
doc) {...}

Since DataObject will be deprecated, it would be
useful to provide an additional method which
returns a fileobject. That way, modules which use
this utility class (e.g. JSP coloring module) do
not need to depend on the DataObjects API.

This is also related to issue 34541 (editor
support without DataObjects): this editor will not
put the DataObject as the property to the
document; instead, it will probably put a
FileObject there. So I suggest the new method is
as follows:

/** Get the fileobject from the document's   
 *  StreamDescriptionProperty property. 
 */
public static FileObject getFileObject(Document doc) {
    Object sdp = doc.getProperty(
                 Document.StreamDescriptionProperty);
    if (sdp instanceof FileObject) {
        return (FileObject)sdp;
    }
    if (sdp instanceof DataObject) {
        return ((DataObject)sdp).getPrimaryFile();
    }
    return null;
}

Also related to issue 34814 - project should be
available in the document.
Comment 1 Martin Roskanin 2003-11-24 09:33:24 UTC
fixed in [maintrunk]
Thank you Petr.

/cvs/editor/src/org/netbeans/modules/editor/NbEditorUtilities.java,v 
<--  NbEditorUtilities.java
new revision: 1.14; previous revision: 1.13
Comment 2 Jiri Prox 2006-04-07 09:07:08 UTC
Verified