Re: unable to look up current project
Benno Markiewicz <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.devel |
|---|---|
| Message-ID | <CAA_aP4jBs6dFOhTv7SGstUFZe1YJyUj6z=_R-8PhLkd3evhwtw@mail.gmail.com> |
Hej mcheung, don't lookup a Project. Lookup a FileObject/DataObject and then use the FileOwnerQuery-API to get a project for it! Almost every node has a FileObject in its lookup. This is the way I get the current project in my plugin https://github.com/markiewb/show-path-in-title-netbeans-module More resources http://wiki.netbeans.org/NetBeansDeveloperFAQ#Project_Handling http://wiki.netbeans.org/DevFaqGetProjectForFileInEditor BTW: Use a lookup inspector like http://plugins.netbeans.org/plugin/44971/nb-lookupinspector to see what's inside the current lookup. With kind regards, markiewb 2016-04-06 10:07 GMT+02:00 mcheung63 <[email protected]>: > Hi All, i popup a JDialog, inside that i execute "Project project = > OpenProjects.getDefault().getMainProject();", it always null. If i do: > > Lookup lookup = Utilities.actionsGlobalContext(); > Project project = lookup.lookup(Project.class); > > I can get current project only i click on the project node in projects > window. If i click another node, such as any file within any project. The > above code return null. > > Please help > thanks > from Peter ([email protected]) > > > > >