Apache NetBeans Wiki Index

Note: These pages are being reviewed.

How to get the project for the actual file in the editor?

  • get the project from the lookup of the active TopComponent AND/OR

  • get the project from the lookup of the active DataObject

Project p = TopComponent.getRegistry().getActivated().getLookup().lookup(Project.class);
if (p == null) {
    DataObject dob = TopComponent.getRegistry().getActivated().getLookup().lookup(DataObject.class);
    if (dob != null) {
       FileObject fo = dob.getPrimaryFile();
       p = FileOwnerQuery.getOwner(fo);
       ...

Taken from platform-dev mailing list / Tim Boudreau

Apache Migration Information

The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.

This page was exported from http://wiki.netbeans.org/DevFaqGetProjectForFileInEditor , that was last modified by NetBeans user Markiewb on 2012-12-27T10:47:54Z.

NOTE: This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.