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 - Supply a utility method to extract a FileObject from Document
Summary: Supply a utility method to extract a FileObject from Document
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 3.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@editor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-09 09:59 UTC by Petr Jiricka
Modified: 2007-11-05 13:44 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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