Skip to main content


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 09:58 Go to next message
Luca Ferrari is currently offline Luca FerrariFriend
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 10:58 Go to previous message
Luca Ferrari is currently offline Luca FerrariFriend
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 08:24 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
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: Tue Mar 19 09:05:15 GMT 2024

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

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

Back to the top