Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » limiting command visibility depending on view selecction(how to intercept the selection of a view instead of the whole page?)
limiting command visibility depending on view selecction [message #513786] Thu, 11 February 2010 04:58 Go to next message
Luca Ferrari is currently offline Luca Ferrari
Messages: 159
Registered: November 2009
Senior Member
Hi,
I'm composing a set of menus and toolbar buttons for a set of master/slave views. Each view must have the same set of commands, that must be active when the view has a selection in it. So I've tried the following in the plugin.xml:

 <command
               commandId="hrpm.rcp.commands.EditTableElement"
               icon="img/edit.png"
               id="hrpm.rcp.gui.view.UserView.edit"
               label="Modifica"
               style="push"
               tooltip="Modifica l&apos;elemento selezionato">
            <visibleWhen
                  checkEnabled="true">
               <with
                     variable="selection">
                  <iterate
                        ifEmpty="false"
                        operator="or">
                  </iterate>
               </with>
            </visibleWhen>
         </command>


the problem is that this activates the command (makes it visible) as first as a selection is activated within the active page, that is among all the perspective views. I want a restricted scope so to force the command to be activated only when the selection on the view it is contributing (e.g., UserView) has a selection. Is it possilbe?
Re: limiting command visibility depending on view selecction [message #513796 is a reply to message #513786] Thu, 11 February 2010 05:58 Go to previous message
Luca Ferrari is currently offline Luca Ferrari
Messages: 159
Registered: November 2009
Senior Member
I've fixed the problem setting another test on the activeId property, as follows:

<command
               commandId="hrpm.rcp.commands.EditTableElement"
               icon="img/edit.png"
               id="hrpm.rcp.gui.view.UserView.edit"
               label="Modifica"
               style="push"
               tooltip="Modifica l&apos;elemento selezionato">
            <visibleWhen
                  checkEnabled="true">
               <with
                     variable="selection">
                  <iterate
                        ifEmpty="false"
                        operator="or">
                  </iterate>
                  <and>
                     <with
                           variable="activePartId">
                        <equals
                              value="hrpm.rcp.gui.view.UserView">
                        </equals>
                     </with>
                  </and>
               </with>
            </visibleWhen>
         </command>


Is this the right way to proceed?
Re: limiting command visibility depending on view selecction [message #513837 is a reply to message #513796] Thu, 11 February 2010 03:24 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Luca Ferrari wrote:
> I've fixed the problem setting another test on the activeId property, as
> follows:

> <with
> variable="activePartId">
> <equals
> value="hrpm.rcp.gui.view.UserView">
> </equals>
> </with>

Using this will work if hrpm.rcp.gui.view.UserView is not a
multi-instance view.


Just a general comment, you would probably want your expression to look
like:
<visibleWhen>
<and>
<with variable="activePartId">...</with>
<with variable="selection">...</with>
</and>
</visibleWhen>


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:Problem creating a product
Next Topic:How to create a pop-up menu
Goto Forum:
  


Current Time: Wed Jul 23 16:07:26 EDT 2014

Powered by FUDForum. Page generated in 0.03245 seconds