Reputation: 41
I want enable my 2nd and 7th menu if the process for first menu is complete. I want to enable my 3rd and 7th menu if process for 2nd menu is complete and so on. I have seven menu. At very first only first menu should be active and remaining should be disable and at second time if 1st process is complete then only 1st menu, 2nd menu and 7th menu should be enabled.
I am not getting how should I make changes in my plugin.xml
in order to work as I am expecting. Here is my plugin.xml
code. Please help me and thank you in advance.
<?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>
Upvotes: 1
Views: 1324
Reputation: 111142
You would do this with an enabledWhen
expression on the handler
for each command. It sounds like you will probably have to use a property tester to define a custom test for the enabled when expression.
Use the org.eclipse.core.expressions.propertyTesters
to define a property tester, something like:
<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>
You then code a documention.PropertyTester
class to do the property tests.
You can then use it in your enabled when expression like this:
<handler
class="documentation.handlers.SampleHandler5"
commandId="documentation.handlers.SampleHandler5">
<enabledWhen>
<test
property="namespace.handler5enabled">
</test>
</enabledWhen>
</handler>
Upvotes: 2