Eclipse RCP:如何将我的视图添加到上下文 [英] Eclipse RCP: How to add my view to a context
问题描述
我的问题:如何将视图添加到Eclipse上下文。
My question: How do I add my View to an Eclipse Context.
我已经创建了一个Eclipse视图,我想向其中添加键绑定M1 + F,因为我的视图将具有自己的搜索机制。在清单中,我借助以下命令添加了命令和键绑定:
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
但是,我在Eclipse上下文方面遇到了麻烦。我只想将此键绑定到我的视图,这样就不会与Eclipse的默认编辑器Search机制冲突。为此,我创建了自己的上下文(org.eclipse.ui.contexts),并将绑定设置到该上下文中。
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.
推荐答案
在您的 createPartControl
中,为视图部分激活上下文:
In your createPartControl
for the view part activate the context:
IContextService contextService = (IContextService)getSite().getService(IContextService.class);
contextService.activateContext("context id");
这篇关于Eclipse RCP:如何将我的视图添加到上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!