i wanna add context menu command when select java source files, context menu don't appear.
class type of java source files compilationunit eclipse plugin-in spy.
this plugin extension declaration(plugin.xml):
<extension point="org.eclipse.ui.menus"> <menucontribution locationuri="popup:org.eclipse.ui.popup.any?after=additions"> <command commandid="xml2javacode.commands.samplecommand" id="xml2javacode.menus.samplecommand" mnemonic="s"> <visiblewhen> <with variable="activemenuselection"> <iterate> <instanceof value="org.eclipse.jdt.core.dom.compilationunit"> </instanceof> </iterate> </with> </visiblewhen> </command> </menucontribution> </extension>
there several classes called compilationunit , have chosen wrong one.
<instanceof value="org.eclipse.jdt.internal.core.compilationunit"> </instanceof> works - but internal class should not reference it.
the usual way check java source file is:
<adapt type="org.eclipse.core.resources.iresource"> <test property="org.eclipse.core.resources.contenttypeid" value="org.eclipse.jdt.core.javasource" /> </adapt> which adapting selection iresource , checking content type id.
Comments
Post a Comment