Eclipse RCP: How to add my view to a context

。_饼干妹妹 提交于 2019-12-11 07:40:42

问题


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.


回答1:


In your createPartControl for the view part activate the context:

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

contextService.activateContext("context id");


来源:https://stackoverflow.com/questions/20950537/eclipse-rcp-how-to-add-my-view-to-a-context

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!