Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Programmatically update all tooltips when context changes?(How to update all command's tooltips when context changes?)
Programmatically update all tooltips when context changes? [message #1792722] Mon, 23 July 2018 08:49 Go to next message
Sascha Becher is currently offline Sascha BecherFriend
Messages: 17
Registered: December 2009
Junior Member
I'm using the compatiblity layer under e4.

When switching contexts, the keybindings in tooltips of commands are not updated.

For example:
Two different editors with the same command are side-by-side.
The command has two keybindings for different contexts.
A part listener switches context when the editor is activated.

Although the keybindings are changed correctly, they are not displayed in the tooltips of the command.

MLocalizable#updateLocalization only updates the localization but not the keybinding.

HandledContributionItem#updateMenuItem seems to update a tooltip with the keybinding,
but I have no idea how to obtain all these items using the ModelService#findElements to call this method.

Could you please hint me at what to update when switching the context?

[Updated on: Mon, 23 July 2018 08:52]

Report message to a moderator

Re: Programmatically update all tooltips when context changes? [message #1792731 is a reply to message #1792722] Mon, 23 July 2018 09:54 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Normally, there is no need to sync the context manually on part change.
Did you try EContextService#activateContext(contextId) when creating the part?
In E4 with compat layer you would use org.eclipse.ui.contexts.IContextService.activateContext(String)
Re: Programmatically update all tooltips when context changes? [message #1792735 is a reply to message #1792731] Mon, 23 July 2018 10:41 Go to previous messageGo to next message
Sascha Becher is currently offline Sascha BecherFriend
Messages: 17
Registered: December 2009
Junior Member
As written before, the keybindings are working correctly. This is how the context is switched:

final IContextService contextService = PlatformUI.getWorkbench().getService(IContextService.class);
contextService.activateContext(contextId);


The problem is that the keybindings in the tooltip are not updated. It shows the old keybinding although the new one is active already.
I want to trigger the update of all tooltips programmatically. How can this be achieved?
Re: Programmatically update all tooltips when context changes? [message #1792737 is a reply to message #1792735] Mon, 23 July 2018 10:55 Go to previous message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
In your part's init() method you should be using:

cs = site.getService(IContextService.class);
cs.activateContext(...);


This will return the part's context service instead of the global workbench window context service.
Previous Topic:NullPointerException in themes.ColorAndFontProviderImpl
Next Topic:Custom control on main toolbar (RCP with compatibility layer)
Goto Forum:
  


Current Time: Fri Apr 19 03:39:28 GMT 2024

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

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

Back to the top