Eclipse RCP: How to add my view to a context

2019-08-13 18:52发布

My question: How do I add my View to an Eclipse Context.

I have created a View for Eclipse and I would like to add the keybinding M1+F to it, since my view will have its own search-mechanism. In the Manifest I added the command and the keybinding with the help of:

org.eclipse.ui.commands
org.eclipse.ui.bindings

However, I'm having trouble with the eclipse Context. I would like to bind this key only to my view so that it won't clash with Eclipse's default Search mechanism for the editor. To do this I created my own context (org.eclipse.ui.contexts) and put my keybinding to that context.

However, how do I add my view to this context? So that the keybinding will only work for my view.

标签: eclipse-rcp
1条回答
SAY GOODBYE
2楼-- · 2019-08-13 19:28

In your createPartControl for the view part activate the context:

IContextService contextService = (IContextService)getSite().getService(IContextService.class);

contextService.activateContext("context id");
查看更多
登录 后发表回答