Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 14:41 Go to next message
Ricky de Klerck is currently offline Ricky de KlerckFriend
Messages: 295
Registered: January 2011
Senior Member
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 14:55 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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 19:49 Go to previous messageGo to next message
Ricky de Klerck is currently offline Ricky de KlerckFriend
Messages: 295
Registered: January 2011
Senior Member
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 18:41 Go to previous messageGo to next message
Johan Schulz is currently offline Johan SchulzFriend
Messages: 20
Registered: November 2010
Junior Member
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 18:47]

Report message to a moderator

Re: Toolbar Change Image Command When Pressed [message #666734 is a reply to message #663539] Fri, 22 April 2011 02:19 Go to previous messageGo to next message
jim liu is currently offline jim liuFriend
Messages: 37
Registered: February 2011
Location: shanghai
Member
as javadoc said IElementUpdater
Everybody should go through the
ICommandService refreshElements(*) method.
but how can i get ICommandService,and then invoke IElementUpdater


java eclipse Search
http://javafind.appspot.com/
Re: Toolbar Change Image Command When Pressed [message #666807 is a reply to message #666734] Fri, 22 April 2011 17:21 Go to previous message
Johan Schulz is currently offline Johan SchulzFriend
Messages: 20
Registered: November 2010
Junior Member
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: Sun Dec 21 06:23:47 GMT 2014

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

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