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] Mon, 15 April 2013 23:02 Go to next message
Rashmy A is currently offline Rashmy A
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 03:34 Go to previous messageGo to next message
Simon Scholz is currently offline Simon Scholz
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 09:59 Go to previous message
Rashmy A is currently offline Rashmy A
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:How to override behaviour of "delete" in popup menu of project explorer?
Next Topic:Odd Behavior in Example RCP Projects
Goto Forum:
  


Current Time: Wed Jul 23 02:04:59 EDT 2014

Powered by FUDForum. Page generated in 0.04317 seconds