KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am writing an Eclipse plugin that will display a menu item in the context menu for a Java Project. I have written the plugin.xml as follows: <plugin> <extension point="org.eclipse.ui.menus"> <menuContribution locationURI="popup:org.eclipse.jdt.ui.PackageExplorer"> <dynamic class="uk.co.dajohnston.plugin.classpathswitcher.menu.MenuContribution" id="uk.co.dajohnston.plugin.classpathSwitcher.switchMenuContribution"> <visibleWhen> <with variable="activeMenuSelection"> <iterate> <adapt type="org.eclipse.jdt.core.IJavaProject"> </adapt> </iterate> <count value="1"> </count> </with> </visibleWhen> </dynamic> </menuContribution> </extension> </plugin> So I am now trying to write the MenuContribution class which extends CompoundContributionItem so that I can create a dynamic menu and the contents of this menu are going to be based on a set of files that exist in the Java Project's root directory. But I am stuck trying to get the path to the root directory from within the getContributionItems method. Based on the plugin.xml file I can be guarenteed that the method will only be called if a single Java Project is selected, so all I need to do is get the current selection and then get its absolute path. Any ideas? Or is there a better way to do this?
Tags (comma-separated)
Save Edits
Cancel