Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Toolbar Change Image Command When Pressed
Toolbar Change Image Command When Pressed [message #663539] Tue, 05 April 2011 10:41 Go to next message
Eclipse UserFriend
Hi,

We're trying to achieve the following:

We have custom commands to change data in a view. These commands appear in the toolbar with an image. This works fine but when an image is clicked, a new image should appear (so the user knows which 'filter' is used). Allso just one image can appear 'pressed', because only one filter can be applied.

I hope it's clear, thanks in advance.
Re: Toolbar Change Image Command When Pressed [message #663547 is a reply to message #663539] Tue, 05 April 2011 10:55 Go to previous messageGo to next message
Eclipse UserFriend
On 04/05/2011 10:41 AM, Ricky de Klerck wrote:
> Hi,
>
> We're trying to achieve the following:
> We have custom commands to change data in a view. These commands appear
> in the toolbar with an image. This works fine but when an image is
> clicked, a new image should appear (so the user knows which 'filter' is
> used). Allso just one image can appear 'pressed', because only one
> filter can be applied.

You want to add org.eclipse.ui.commands.IElementUpdater to your handler.
When it's time to update the icon for your commands, you would call
org.eclipse.ui.commands.ICommandService.refreshElements(Stri ng, Map) to
notify the framework it's time to request a UI refresh.

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/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: Toolbar Change Image Command When Pressed [message #663605 is a reply to message #663547] Tue, 05 April 2011 15:49 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for the reply, I haven't tried it yet but it sounds like this is what I need.

So I should implement the interface for every handler and call this method? Before I call this method, I should change the images for every command?
Re: Toolbar Change Image Command When Pressed [message #665483 is a reply to message #663539] Thu, 14 April 2011 14:41 Go to previous messageGo to next message
Eclipse UserFriend
Quote:
So I should implement the interface for every handler and call this method? Before I call this method, I should change the images for every command?


You have to implement IElementUpdater for every handler. You can change the image, text, tooltip and dropMenuDownID (if its and toolbar button) in the implemented method from IElementUpdater.

afaik it is called automatically if the handler gets executed but you have to call refreshElements if you would like to change the appearance after some underlying condition has changed.


Johan

[Updated on: Thu, 14 April 2011 14:47] by Moderator

Re: Toolbar Change Image Command When Pressed [message #666734 is a reply to message #663539] Thu, 21 April 2011 22:19 Go to previous messageGo to next message
Eclipse UserFriend
as javadoc said IElementUpdater
Everybody should go through the
ICommandService refreshElements(*) method.
but how can i get ICommandService,and then invoke IElementUpdater
Re: Toolbar Change Image Command When Pressed [message #666807 is a reply to message #666734] Fri, 22 April 2011 13:21 Go to previous message
Eclipse UserFriend
You can get the service from the service registry. IServiceLocator

from ViewPart
getSite().getService( ICommandService.class )

from Handler impl.
PlatformUI.getWorkbench().getService( ICommandService.class )


Johan
Previous Topic:Re-Exporting external library best practice
Next Topic:Product does not work on Mac OSX, although it runs on Windows/Linux
Goto Forum:
  


Current Time: Wed Jul 23 15:16:31 EDT 2025

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

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

Back to the top