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