Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 14:10 Go to next message
Michelle Davidson is currently offline Michelle DavidsonFriend
Messages: 41
Registered: August 2009
Member
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 04:48 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
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 16:09 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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 Apr 26 13:39:29 GMT 2024

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

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

Back to the top