Dne 30.7.2018 v 22:53 [email protected] napsal(a):

  I'm a little bit new to some of the NetBeans terminologies (i.e. Nodes etc), but I can try my best to 
explain. I'm thinking in terms of how the "Run Project" button works in the main toolbar, and how 
that must determine which project to run somehow. That project that it "chooses to run" is what I 
mean by the "current" project.

I hope that is more specific :) Thanks for your reply

OK. Given your action is in the main toolbar, you could do something like:

Lookup lkp = Utilities.actionsGlobalContext();
// there may be more projects; you can do lkp.lookupAll() and
// iterate through them somehow
Project prj = lkp.lookup(Project.class);
if (prj == null) {
        // fallback, no project present explicitly, let's lookup a file
        // and its owning project:
        FileObject f = lkp.lookup(FileObject.class);
        prj = FileOwnerQuery.getOwner(f);
}
if (prj != null) {
        // do with prj whatever you want
}

-S.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Reply via email to