Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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: Sun Mar 16 06:29:08 EDT 2025

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

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

Back to the top