[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Get Active Project

Hi Jason

How are you triggering/running kconfig? Are you using some kind of actionSet or popupMenu? If yes you implement some interface like IWorkbenchWindowActionDelegate or IObjectActionDelegate in one of your classes. Both have a selectionChanged(IAction action, ISelection selection) method you have to override (which will be called when triggered). The passed selection is, depending on what is currently selected an instance of either IStructuredSelection ( -> selection in "Project Explorer" or "C++ Projects" view on project/folder/file/etc) or ITextSelection ( -> selection in editor).
In the first case you can use the structuredSelection.getFirstElement() to get some resource (ITranslationUnit/IProject/IContainer/IFile). In the second case use "PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput()" to get the editor reference. It normally hase the type FileEditorInput which provides a getFile() method.

Hope this helps!
Lukas


On 13.11.2012 20:46, Jason Litton wrote:
I'm building a plugin that will parse and generate KConfig menus inside Eclipse. Sadly, I won't be able to push this to CDT, since it requires the Antlr runtime library (BSD license). I'm going to try, however, to make it an open plugin for the community. However, I'm stuck on one final request that's been given me. My C developers want kconfig to load automatically from the selected project. "Hey, no problem, that's easy," I thought to myself. Now I'm running down a rabbit hole. I have no idea where I pick up the location of the selected project. I've tried looking at the BuildAction to get an idea, since that is linked to the active project, but that chooses which projects have build configurations, and sorts from there, which doesn't help me. I've googled around and seen to use the selection service, but that always comes back null. So, since I know CDT is, at times, liking to the project selected in the project explorer window, can you tell me where I can pull that information, or point me somewhere in the CDT code where that information is being pulled?
Thanks,
Jason


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev