简体   繁体   English

根据Eclipse RCP中选择的视图激活上下文

[英]Activate context based on the view selected in Eclipse RCP

I want to activate a context based on the view selected to add shortcut to a specific view. 我想根据所选视图激活上下文,以将快捷方式添加到特定视图。 I did the following. 我做了以下。

  • Created Keybinding 创建的键绑定
  • Added Command Handler 添加了命令处理程序
  • Created Context 创建的上下文

But I am not sure how to activate the contact using plugin configuration. 但是我不确定如何使用插件配置激活联系人。

To have a different command 'handler' active for different views use the 'activeWhen' element in the `org.eclipse.ui.handlers' definition. 要为不同的视图激活不同的命令“处理程序”,请使用“ org.eclipse.ui.handlers”定义中的“ activeWhen”元素。

Something like: 就像是:

<extension
     point="org.eclipse.ui.handlers">
  <handler
        class="view1.View1Handler"
        commandId="command.id">
     <activeWhen>
       <with
           variable="activePartId">
          <equals
              value="view1.id">
          </equals>
       </with>
     </activeWhen>
  </handler>

define a different handler for the command for each view. 为每个视图的命令定义不同的处理程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM