On 2018/07/30 21:06:12, Jan Lahoda <[email protected]> wrote:
> There is
> org.netbeans.spi.project.ui.support.ProjectSensitiveActions.projectSensitiveAction
> in module projectuiapi, which may be useful (a custom performer is called
> with the current project when the action is invoked).
>
> Alternatively, you could look into the Lookup returned from
> org.openide.util.Utilities.actionsGlobalContext to see if there's a
> FileObject/DataObject inside, and then use FileOwnerQuery.getOwner.
>
> Jan
>
>
> On Mon, Jul 30, 2018 at 10:53 PM, [email protected] <
> [email protected]> wrote:
>
> >
> >
> > On 2018/07/30 19:42:59, Svata Dedic <[email protected]> wrote:
> > > Dne 30.7.2018 v 21:05 [email protected] napsal(a):
> > > > Hi, I'm developing a module for Netbeans, and it needs to have
> > "project-specific" functionality i.e. similar to how the "Run Application"
> > button in the toolbar compiles and runs only the current project.
> > > >
> > >
> > > Define what is "current" :) Is it "the project, which owns the active
> > > editor" ? Or "the project which owns the active node's file" (which may
> > > change as e.g. file explorer or various supplemental windows are
> > > activated) ... Or has the user to specifically open a project explorer
> > > and select project's node before your action ? Please be more specific
> > > what "current" means in your scenarios.
> > >
> > > -Svata
> > >
> > > ---------------------------------------------------------------------
> > > 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
> > >
> > >
> > >
> > 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
> >
> > ---------------------------------------------------------------------
> > 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
> >
> >
> >
> >
>
I got it to work! Thanks to everyone for your feedback/help. I familiarized
myself with the Lookup API and Nodes (both concepts I didn't know about).
I utilized the actionsGlobalContext() to get the global lookup, and used it to
lookup for FileObjects (doing a Lookup on Nodes didn't help for some reason).
There was always at most FileObject returned, which nicely corresponded to my
"current project" as I had defined it in my mind.
>From there I was easily able to trace the FileObject to its owning Project
>with a FileOwnerQuery. Thanks again everyone :)
---------------------------------------------------------------------
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