问题描述
我想编写一个Eclipse插件,它使用所选项目执行一个Action。我使用插件模板与子菜单。我的plugin.xml如下所示: < extension
point =org.eclipse.ui.popupMenus >
< objectContribution
objectClass =org.eclipse.core.internal.resources.Project
id =testplugin2.contribution1>
< menu
label =Propertie Manager
path =additionions
id =testplugin2.menu1>
< separator
name =group1>
< / separator>
< / menu>
< action
label =list all * .properties
class =testplugin2.popup.actions.ListPropertiesAction
menubarPath =testplugin2.menu1 / group1
enableFor =1
id =testplugin2.projectAction>
< / action>
< / objectContribution>
< / extension>
这个工作适用于除javaProject之外的所有内容。事实证明,javaProjects不是项目。当我选择了一个javaProjects或者一个正常的项目时,我想要这个Action显示出来。
如果一个javaProject或选择一个项目?
我没有测试,但也许这样做:
< objectcontribution ...>
< visibility>
< objectClass
name =org.eclipse.jdt.core.IJavaProject/>
< / visibility>
< / objectContribution>
您还可以尝试启用而不是可见性。
I want to write an Eclipse-plugin that performs an Action with a selected Project. I used the plugin Template with submenu. My plugin.xml looks like this :
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.core.internal.resources.Project"
id="testplugin2.contribution1">
<menu
label="Propertie Manager"
path="additions"
id="testplugin2.menu1">
<separator
name="group1">
</separator>
</menu>
<action
label="list all *.properties"
class="testplugin2.popup.actions.ListPropertiesAction"
menubarPath="testplugin2.menu1/group1"
enablesFor="1"
id="testplugin2.projectAction">
</action>
</objectContribution>
</extension>
this works fine for everything but javaProjects. It turns out that javaProjects are not Projects. I want this Action to appear when a javaProjects or a normal Projects is selected and not if something else is selected.
How can I make the submenu appeare exactly if a javaProject or a Project is selected?
I didn't test it, but maybe this works:
<objectcontribution ...>
<visibility>
<objectClass
name="org.eclipse.jdt.core.IJavaProject" />
</visibility>
</objectContribution>
You can also try "enablement" instead of "visibility".
eclipse help pages on popup menus
这篇关于具有子菜单的Eclipse插件。如何处理JavaProjects和Projects?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!