Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Command at the wrong view active.
Command at the wrong view active. [message #490816] Sun, 11 October 2009 10:10 Go to next message
Eclipse UserFriend
Hello,

I have a problem with a active Handler.

I have a perspective with 3 views. On one is a tree, on one a table ane on the third some text fields.

If the view with the tree is active then 3 commands should be active and enabled. If the view with the table is active then another command shold be enabled, and the tree-commands should be disabled. And if the third View is enabled all commands should be disabled.

<extension
         point="org.eclipse.ui.handlers">
      <handler
            class="de.rcp.command.AddPerson"
            commandId="de.rcp.addPerson">
         <activeWhen>
            <with
                  variable="activePartId">
               <equals
                     value="de.rcp.PersonTreeView">
               </equals>
            </with>
         </activeWhen>
         <enabledWhen>
            <with
                  variable="selection">
               <instanceof
                     value="de.rcp.model.Person">
               </instanceof>
            </with>
         </enabledWhen>
      </handler>

     <handler
            class="de.rcp.command.EditPersonProperties"
            commandId="de.rcp.editPersonProperties">
         <activeWhen>
            <with
                  variable="activePartId">
               <equals
                     value="de.rcp.PersonTableView">
               </equals>
            </with>
         </activeWhen>
         <enabledWhen>
            <with
                  variable="selection">
               <instanceof
                     value="de.rcp.model.Person">
               </instanceof>
            </with>
         </enabledWhen>
      </handler>


The problem is that the commands are active when the respective view isn´t active.

For example if PersonTreeView is active then the command EditPersonProperties is enabled. But this should be disabled for this view, And it is disabled if the PersonTableView is active.

What is my mistake and what must I change, that the commands are on the right view enabled

Re: Command at the wrong view active. [message #490864 is a reply to message #490816] Mon, 12 October 2009 00:48 Go to previous messageGo to next message
Eclipse UserFriend
Michelle Davidson wrote:

> The problem is that the commands are active when the respective view
> isn´t active.

Have you specified the defaultHandler for the commands? If so you have
to remove them.

- Prakash

Platform UI Team, IBM
http://blog.eclipse-tips.com
Re: Command at the wrong view active. [message #491212 is a reply to message #490816] Tue, 13 October 2009 12:09 Go to previous message
Eclipse UserFriend
You're activeWhen clauses look OK. Make sure (as Prakash suggested) that you have no defaultHandler set for your commands.

The enabledWhen won't do what you want, however:
<enabledWhen>
<with
variable="selection">
<instanceof
value="de.rcp.model.Person">
</instanceof>
</with>
</enabledWhen>

A selection is an ISelection which will probably be an IStructuredSelection for your views. You need to use <count/> and <iterate/> before you an use <instanceof/>

PW
Previous Topic:Command Parameters
Next Topic:How can I hide the icon on the view tab?
Goto Forum:
  


Current Time: Fri Jul 25 15:46:21 EDT 2025

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

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

Back to the top