Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Command Handler enablement
Command Handler enablement [message #1042135] Tue, 16 April 2013 03:02 Go to next message
Rashmy A is currently offline Rashmy AFriend
Messages: 149
Registered: July 2009
Senior Member
Hello,
I'm facing an issue with command handler enablement.

PluginA has the following
<command id="com.xyz.myCmd1" name="My Command"/>
<handler class="com.pluginA.MyHandler" commandId="com.xyz.myCmd1">
   <enabledWhen>
      <iterate ifEmpty="false">
         <test property="com.pluginA.root" value="com.pluginA.RootTypeA"/>
      </iterate>
   </enabledWhen>
</handler>


PluginB has the following
<handler class="com.pluginA.MyHandler" commandId="com.xyz.myCmd1">
   <enabledWhen>
      <iterate ifEmpty="false">
         <test property="com.pluginA.root" value="com.pluginB.RootTypeB"/>
      </iterate>
   </enabledWhen>
</handler>


Above you will see that the same handler is contributed in two different plug-ins so that the command 'myCmd1' is enabled for classes of type 'RootTypeA' and 'RootTypeB'

When the UI comes up, the command is shown but is not enabled. What am I missing?

The classes RootTypeA and RootTypeB belong to different plugins but needs to use the same handler. PluginB is dependent on PluginA.

Thanks,
Rashmy
Re: Command Handler enablement [message #1042262 is a reply to message #1042135] Tue, 16 April 2013 07:34 Go to previous messageGo to next message
Simon Scholz is currently offline Simon ScholzFriend
Messages: 73
Registered: April 2012
Location: Germany
Member
Hello Rashmy,

in your <enabledWhen> declaration you did not define over what should be iterated.
You just iterate over nothing and then try to test it.

Here are some pre defined variables you could use within a <with> declaration.
http://wiki.eclipse.org/Command_Core_Expressions

i.e. :

<command id="com.xyz.myCmd1" name="My Command"/>
<handler class="com.pluginA.MyHandler" commandId="com.xyz.myCmd1">
   <enabledWhen>
    <with variable="selection">
      <iterate ifEmpty="false">
         <test property="com.pluginA.root" value="com.pluginA.RootTypeA"/>
      </iterate>
    </with>
   </enabledWhen>
</handler>


Best regards,

Simon
Re: Command Handler enablement [message #1042497 is a reply to message #1042262] Tue, 16 April 2013 13:59 Go to previous message
Rashmy A is currently offline Rashmy AFriend
Messages: 149
Registered: July 2009
Senior Member
Thank you for the reply.

The commands are contributed in a View and the view provides IStructuredSelection. Hence there was no need to specify the <with> clause.

If I have the following in PluginA or PluginB, things work fine.
<handler class="com.pluginA.MyHandler" commandId="com.xyz.myCmd1">
   <enabledWhen>
      <iterate ifEmpty="false">
         <or>
             <test property="com.pluginA.root" value="com.pluginA.RootTypeA"/>
             <test property="com.pluginA.root" value="com.pluginB.RootTypeB"/>
         </or>
      </iterate>
   </enabledWhen>
</handler>

So the issue is when I put the same handler contribution in both pluginA and pluginB for different root types.

Thanks,
Rashmy
Previous Topic:What is the future of Common Navigator Framework?
Next Topic:Odd Behavior in Example RCP Projects
Goto Forum:
  


Current Time: Thu Mar 28 21:50:00 GMT 2024

Powered by FUDForum. Page generated in 0.02200 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top