Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Toolbar pulldown "toggles" contribution
Toolbar pulldown "toggles" contribution [message #526191] Fri, 09 April 2010 08:00 Go to next message
Christophe Fondacci is currently offline Christophe FondacciFriend
Messages: 95
Registered: July 2009
Location: Paris
Member
Hello,

I am trying to implement a toggle dropdown menu from a toolbar through menu contributions.

I managed to have my control, my pulldown and the menu items in it (thanks to Paul Webster's older posts!)

Now I am trying to implement 2 things :
- The main toolbar icon changes according to the selected menu item
- The corresponding menu item get checked, unselecting any previously checked item

I am trying to do this through IElementUpdater implementation but I cannot make it work.

Here is what I did :
* 1 command dedicated for the "root" toolbar command pulldown contribution
* This command has a dedicated handler implementing IElementUpdater which tries to update the icon to the currently selected element
* Contributed commands appended to URI "menu:rootCmdId" with specific handlers implementing IElementUpdater

Handlers' "updateElement" method for non-root command get called after the dropdown command is selected. Calling setChecked here does nothing.

Root command handler "updateElement" method is never called. I would have expected it to be called after child menu item selection. In the child's handlers I don't know how to get access to this "root" UIElement to update its icon.

So I cannot change the toolbar icon at all after a selection in the pulldown menu.

If anyone could tell me what I am doing wrong that would be nice...
Thank you.

Christophe.
http://www.nextep-softwares.com
Re: Toolbar pulldown "toggles" contribution [message #526247 is a reply to message #526191] Fri, 09 April 2010 11:13 Go to previous messageGo to next message
Catalin Gerea is currently offline Catalin GereaFriend
Messages: 89
Registered: July 2009
Location: Bucharest, Romania
Member

Hello Christophe

Look here http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle- radio-menu.html.

In order to change the main toolbar menu I think you have to have the toolbar contribution as a dynamic contribution in your plugin.xml. Thus in your class you can have access to the toolbar item and change it's image.
Look here for a toolbar contribution class http://eclipsesource.com/blogs/2009/03/31/replacing-the-pers pective-switcher-in-rcp-apps/.

In my case I have created a pull-down toolbar contribution that acts as a perspective switcher: the current perspective is checked in the pull-down menu and the toolbar image is changed to the image of the item selected in the pull-down menu. I have used the above two links to implement this.

If you need more help let me know.


Time is what you make of it.
Re: Toolbar pulldown "toggles" contribution [message #526270 is a reply to message #526191] Fri, 09 April 2010 12:27 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You can also open a bug at
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=UI
to make sure we don't have a path through our code that we shouldn't.

PW

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


Re: Toolbar pulldown "toggles" contribution [message #526287 is a reply to message #526270] Fri, 09 April 2010 13:58 Go to previous messageGo to next message
Christophe Fondacci is currently offline Christophe FondacciFriend
Messages: 95
Registered: July 2009
Location: Paris
Member
Thank you,

I am not a big fan of "dynamic" menu contributions as I am pretty sure there's everything available for this kind of behaviour. Moreover this would imply to create specific extension point for the elements I want to display as menu items (because I want them to be contributed through extensions), fetch the extensions, and transform them back into menu items...


About opening a bug, could you detail what makes you think it is a bug ?

Should the root-command "updateElement" handler method be called after selecting one of its "sub menu" command? If so, my setIcon would indeed work and it might be a bug.
Otherwise, I think I may only "need" to access the parent UI item in the "updateElement" method of my menu items...

Thanks a lot,
Christophe.
http://www.nextep-softwares.com

Re: Toolbar pulldown "toggles" contribution [message #526619 is a reply to message #526287] Mon, 12 April 2010 12:45 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Christophe Fondacci wrote:
>
> Should the root-command "updateElement" handler method be called after
> selecting one of its "sub menu" command? If so, my setIcon would indeed
> work and it might be a bug.

The only time the system will call updateElement is when handlers change
and the new handler is an IElementUpdater. If your command is called an
you know it's time to update icons, you are responsible for calling
org.eclipse.ui.commands.ICommandService.refreshElements(Stri ng, Map)

Later,
PW


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


Re: Toolbar pulldown "toggles" contribution [message #527447 is a reply to message #526619] Thu, 15 April 2010 10:12 Go to previous message
Christophe Fondacci is currently offline Christophe FondacciFriend
Messages: 95
Registered: July 2009
Location: Paris
Member
Thanks for this clarification.

Another thing related to this which seems weird :
- I force initialization of the view (mainly because this view register some listeners at creation time to show the view on specific events) containing the toggle through :
page.showView(DiffPreviewView.VIEW_ID, null, IWorkbenchPage.VIEW_CREATE);


- I trigger view creation (above code) in a PageListener.pageOpened(...) method

- The first time the workbench window page is opened, everything is fine

- If I close / open the perspective, the toggle button appears on another view icon and seems to be superposed with the view icon. This other view has nothing to do with this toggle / control / command definition.

- If I click on the view which should contain the toggle (which has been created but is not already shown), then the control goes to the right place and the superposed control disappears...


Is there something I am doing wrong or is this a bug ?
Thank you,
Christophe
http://www.nextep-softwares.com
Previous Topic:Define perspective from a saved perspective
Next Topic:Custom Project
Goto Forum:
  


Current Time: Sat Apr 20 05:39:48 GMT 2024

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

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

Back to the top