Eclipse plugin 扩展eclipse插件:如何启用和禁用菜单?
如果第一个菜单的过程完成,我想启用第二个和第七个菜单。我想启用我的第三个和第七个菜单,如果第二个菜单的过程完成,依此类推。我有七份菜单。首先,只有第一个菜单应处于激活状态,其余菜单应处于禁用状态;第二次,如果第一个过程完成,则只有第一个菜单、第二个菜单和第七个菜单应处于启用状态 我不知道我应该如何在Eclipse plugin 扩展eclipse插件:如何启用和禁用菜单?,eclipse-plugin,Eclipse Plugin,如果第一个菜单的过程完成,我想启用第二个和第七个菜单。我想启用我的第三个和第七个菜单,如果第二个菜单的过程完成,依此类推。我有七份菜单。首先,只有第一个菜单应处于激活状态,其余菜单应处于禁用状态;第二次,如果第一个过程完成,则只有第一个菜单、第二个菜单和第七个菜单应处于启用状态 我不知道我应该如何在plugin.xml中进行更改,以便按照我的期望工作。这是我的plugin.xml代码。请帮助我,提前谢谢你 <?xml version="1.0" encoding="UTF-8"?>
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>
您可以在
处理程序上为每个命令启用表达式。听起来您可能需要使用属性测试仪为enabled when表达式定义自定义测试
使用org.eclipse.core.expressions.propertyTesters
定义属性测试程序,类似于:
然后编写一个documentation.PropertyTester
类来进行属性测试
然后,您可以在“启用时”表达式中使用它,如下所示:
您所说的“第一个菜单的过程已经完成”是什么意思?您的意思是菜单项已被单击,或者Comamnd的处理程序已完成,还是后面有一个长时间运行的流程必须首先完成?第一个完成的流程表示在第一个表单上我正在接受用户的信息。一旦用户填写信息,我将生成ProjectDecription.xml文件,其中包含用户接受的数据。一旦文件生成,意味着第一个处理程序的处理过程就完成了。在第二个处理程序中,我再次接受来自用户的信息,并将其合并到ProjectDescription.xml中,类似地,用于其他处理程序。所以我想在第一次只有第一个菜单应该是启用和所有其他禁用。等等。谢谢你的回复。你能写下我需要在哪个扩展点添加这个代码的示例代码吗?这样我会更方便。因为我不知道如何在plugin.xml中添加此代码,请您发布代码。提前感谢处理程序是您已经拥有的org.eclipse.ui.handlers,您只需添加enabledWhen部分即可。@user3497146 greg提供了您可能需要的所有内容。如果您仍然不确定如何使用PropertyTests,请尝试此详细教程:感谢您提供gerg-449和Calon。你的帮助对我真的很有用。非常感谢。:)嘿,greg-449我按照你的指示做了,但是当我只在我的处理器里放了隐藏菜单的时候。但问题是现在我想启用它们,如果根据条件意味着如果handler1的过程完成,我想启用第二个处理程序。我不知道如何写这个条件。你能帮我吗??