Hi Rahul,

Am Sonntag, den 14.02.2021, 09:34 +0530 schrieb Rahul Khandelwal:
> 
> How can I get the path of selected project (which has its file currently
> open and focused).
> I also want to capture workspace path.
> 
> I would like to access above two details in an action.

Not sure what you mean by workspace path, but for the currently
selected project, you can use the global lookup for this:

First get a LookupResult for Project.class:

private Result<Project> lookupResult = 
Utilities.actionsGlobalContext().lookupResult(Project.class);

Then attach a listener to it to check when a project is added to the global 
lookup:

lookupResult.addLookupListener(this);

Now everytime the contents of the result changes (Project changes or
availability changes), #resultChanged method will be invoked and you
can react.

Have a look here:

http://netbeans.apache.org/wiki/DevFaqTrackGlobalSelection.asciidoc

HTH

Matthias


---------------------------------------------------------------------
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