eclipse插件开发 -右键菜单 - popup menu

右键时,想只对java文件显示插件,可以这样设置
在Extensions - (objectContribution) - 左边的objectClass中设置:

org.eclipse.jdt.core.IJavaElement

再在plugin.xml中设置 nameFilter=”*.java”(就是添加这句代码而已)

<plugin>

   <extension
         point="org.eclipse.ui.popupMenus">
      <objectContribution
            objectClass="org.eclipse.jdt.core.IJavaElement"
            id="com.popmenu.extend.contribution1"
            nameFilter="*.java">
         <menu
               label="API注册"
               path="additions"
               id="com.popmenu.extend.menu1">
            <separator
                  name="group1">
            separator>
         menu>
         <action
               label="API注册模板"
               class="com.popmenu.extend.popup.actions.TemplateAddAction"
               menubarPath="com.popmenu.extend.menu1/group1"
               enablesFor="1"
               id="com.popmenu.extend.newAction">
         action>
      objectContribution>
   extension>

plugin>

你可能感兴趣的:(Java,eclipse)