Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » buttons hiding when the view looses focus(using visible-when on a table viewer selection causes the contributions to hide depending on the focus)
buttons hiding when the view looses focus [message #639934] Thu, 18 November 2010 13:16 Go to next message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
Hi all,
in my application I've got a view that contains a tableviewer that is the one that gets the focus on the view. In my plug.xml file I've got a contribution to the view toolbar like the following:

<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>


this makes the button visible on the toolbar only when there is a selected row in the view (or better, in the table viewer). Now, if the user gives the focus on another view, even if the row is still selected in the first table viewer, the contribution is no more visible and to make it visible again the user have to select the view to give it the focus. Is there a way to avoid this annoying contribution disappearing when the view looses the focus?

Thanks.
Re: buttons hiding when the view looses focus [message #639944 is a reply to message #639934] Thu, 18 November 2010 13:30 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Luca Ferrari wrote:
> focus. Is there a way to avoid this annoying contribution disappearing
> when the view looses the focus?

No. You've said your view is visible when the active part is your view
right in the visibleWhen definition.

But if you've put it in your view toolbar, why do you have activePartId
in your visibleWhen? As you've found out, all it will do is make your
button disappear when you activate another view.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
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


Re: buttons hiding when the view looses focus [message #641355 is a reply to message #639944] Thu, 25 November 2010 07:50 Go to previous messageGo to next message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
I have to make the buttons visible only when there is a selection on such view, and since I've got a lot of views defined like that, I don't want that a selection on a view can cause the buttons to appear also in another view (where the selection is not done). That's why I've get the activeID part, but maybe there is another smarter way to achieve this. Any hint?
Re: buttons hiding when the view looses focus [message #641436 is a reply to message #641355] Thu, 25 November 2010 13:16 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The view toolbar isn't really set up to have buttons appearing and
disappearing often, so you'll need to be careful about that.

The only way to control enabled state of a view toolitem in the
multi-instance view scenario is to make it an action and add it to the
IActionBars. The action is basically a trumped-up SWT.Selection
listener with access to local state.

As for visibility, you could create property tester and that would give
you flexibility to "check with code". This would work in the
one-view-case as your visibility could check the view selection directly
.... but it fails in the multi-instance view scenario, since you can't
tell which view your toolitem belongs to (at least, not really).

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
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:Text Editor Default Preference page
Next Topic:Re: Problem with Tabbed Properties View
Goto Forum:
  


Current Time: Thu Dec 18 11:46:17 GMT 2014

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

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