如果第一个菜单的过程完成,我想启用第二个和第七个菜单。如果第二个菜单的处理完成,我想启用第3和第7个菜单,依此类推。我有七个菜单。首先,只有第一个菜单应该是活动的,剩下的应该是禁用的,如果第一个过程完成,则第二个菜单应该只启用第一个菜单,第二个菜单和第7个菜单。
我没有得到如何在我的plugin.xml
中进行更改以便按照我的预期工作。这是我的plugin.xml
代码。请帮助我,并提前感谢你。
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu id = "documentation.handlers.Documentation"
label = "Documentation">
<command id="documentation.handlers.SampleHandler"
commandId="documentation.handlers.SampleHandler">
</command>
<command id="documentation.handlers.SampleHandler1"
commandId="documentation.handlers.SampleHandler1">
</command>
<command id="documentation.handlers.SampleHandler2"
commandId="documentation.handlers.SampleHandler2">
</command>
<command id="documentation.handlers.SampleHandler3"
commandId="documentation.handlers.SampleHandler3">
</command>
<command id="documentation.handlers.SampleHandler4"
commandId="documentation.handlers.SampleHandler4">
</command>
<command id="documentation.handlers.SampleHandler4"
commandId="documentation.handlers.SampleHandler5">
</command>
<command id="documentation.handlers.SampleHandler4"
commandId="documentation.handlers.SampleHandler6">
</command>
</menu>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar id="documentation.handlers.sampleToolbar">
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler">
</command>
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler1">
</command>
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler2">
</command>
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler3">
</command>
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler4">
</command>
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler5">
</command>
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler6">
</command>
</toolbar>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler"
name="Project Descritpion">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler"
commandId="documentation.handlers.SampleHandler">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler1"
name="Fact Finding Techniques">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler1"
commandId="documentation.handlers.SampleHandler1">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler2"
name="Feasibility Study">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler2"
commandId="documentation.handlers.SampleHandler2">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler3"
name="Technical Requirement">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler3"
commandId="documentation.handlers.SampleHandler3">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler4"
name="Open Documentation">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler4"
commandId="documentation.handlers.SampleHandler4">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler5"
name="UML Diagrams">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler5"
commandId="documentation.handlers.SampleHandler5">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler6"
name="Database Development">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler6"
commandId="documentation.handlers.SampleHandler6">
</handler>
</extension>
</plugin>
答案 0 :(得分:2)
对于每个命令,您可以在enabledWhen
上使用handler
表达式执行此操作。听起来你可能不得不使用属性测试器来定义表达时启用的自定义测试。
使用org.eclipse.core.expressions.propertyTesters
定义属性测试器,例如:
<extension point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
id="documentation.propertytester"
type="java.lang.Object"
namespace="documentation"
properties="handler1enabled,handler2enabled,handler3enabled.. and so on ..."
class="documentation.PropertyTester">
</propertyTester>
</extension>
然后编写一个documention.PropertyTester
类来进行属性测试。
然后您可以在启用时使用它,如下所示:
<handler
class="documentation.handlers.SampleHandler5"
commandId="documentation.handlers.SampleHandler5">
<enabledWhen>
<test
property="namespace.handler5enabled">
</test>
</enabledWhen>
</handler>