Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Dynamically change the menu label.
Dynamically change the menu label. [message #487478] Wed, 23 September 2009 11:30 Go to next message
Neha is currently offline NehaFriend
Messages: 52
Registered: July 2009
Member
Hi,
I need to dynamically change my menu label as per the instance of the
editor.for example for editor instance editorA i want the label to be "Paste
Below" if the focus goes to other editorB i want the same menu to have label
"Paste Left". And this menu to be invisible for the rest.
Is there a way to do so?

Thanks in advance!
Regards,
Neha.
Re: Dynamically change the menu label. [message #487502 is a reply to message #487478] Wed, 23 September 2009 13:14 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Create a command and then your handlers for each type of editor can implement org.eclipse.ui.commands.IElementUpdater

When a handler becomes active it is given the opportunity to update labels of any UIElements that refer to it.

Then use org.eclipse.ui.menus to add the menu item for that command. The visibleWhen clause is what matches it to editorA or editorB

PW


Re: Dynamically change the menu label. [message #487506 is a reply to message #487502] Wed, 23 September 2009 13:21 Go to previous messageGo to next message
encom79  is currently offline encom79 Friend
Messages: 12
Registered: July 2009
Junior Member
I did not understand Shocked
I have handlers to modify the text, but they are IAction. Is there a way to get an UIElement with IAction ?

[Updated on: Wed, 23 September 2009 13:23]

Report message to a moderator

Re: Dynamically change the menu label. [message #487512 is a reply to message #487506] Wed, 23 September 2009 13:34 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

If you are using IActionDelegate and extension points (the old action stuff) then in your selectionChanged(*) method or run(*) method you are handed the IAction. You can call setText(*) on it then.

Outside of those 2 times, you cannot change the label for your menu item (one of the limitations of the old system).

If you added an Action yourself to the menu, then you would have to update it yourself.

PW


Previous Topic:How to fix the size of action pulldown button
Next Topic:Is there a set of osgi.bundles ?
Goto Forum:
  


Current Time: Tue Sep 24 15:58:28 GMT 2024

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

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

Back to the top