在Eclipse中以透视方式创建菜单 [英] Create a menu in a perspective in Eclipse

查看:141
本文介绍了在Eclipse中以透视方式创建菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Eclipse插件,我想将一个新菜单(屏幕顶部以及文件,编辑等)与我创建的视角相关联。



我做了菜单,但即使在其他方面也正在显示。如何才能将其与我的观点联系起来?这是我在plugin.xml中使用的代码:

 < plugin> 
< extension point =org.eclipse.ui.perspectives>
< perspective
class =org.eclipse.ui.articles.perspective.API_Development
id =org.eclipse.ui.articles.perspective.API_Development
name =API开发>
< / perspective>
< / extension>

< extension
point =org.eclipse.ui.actionSets>
< actionSet
label =Sample Action Set
visible =true
id =API_Development_Menu.actionSet>
< menu
label =API开发
id =sampleMenu>
< separator
name =sampleGroup>
< / separator>
< / menu>
< / actionSet>
< / extension>
< / plugin>

感谢和问候,
Kurt

解决方案

wiki文章菜单贡献自Eclipse3.3M6元素

 < visibleWhen /> 




org.eclipse。 core.expressions.definitions 扩展点已添加。用于定义核心表达式,然后可以从其他位置引用该定义。




  ; extension point =org.eclipse.core.expressions.definitions> 
< definition id =com.example.context>
< with variable =activeContexts>
< iterate operator =或>
< equals value =org.eclipse.ui.contexts.actionSet/>
< / iterate>
< with>
< / definition>
< / extension>




这可以在一个核心表达式中调用,如activeWhen,enabledWhen,visibleWhen等等使用参考元素:




 < reference definitionId =com.example.context /> 

可能这样定义如下:







可用于您的菜单?


I am developing an Eclipse plug-in and I'd like to associate a new menu (at the top of the screen along with File, Edit etc) with a perspective I'm creating.

I did the menu ok but it is being displayed even in other perspectives. How can I associate it only with my perspective? This is the code I am using in plugin.xml:

<plugin>
<extension point="org.eclipse.ui.perspectives">
   <perspective
         class="org.eclipse.ui.articles.perspective.API_Development"
         id="org.eclipse.ui.articles.perspective.API_Development"
         name="API Development">
   </perspective>
</extension>

<extension
         point="org.eclipse.ui.actionSets">
      <actionSet
            label="Sample Action Set"
            visible="true"
            id="API_Development_Menu.actionSet">
         <menu
               label="API Development"
               id="sampleMenu">
            <separator
                  name="sampleGroup">
            </separator>
         </menu>
      </actionSet>
   </extension>
</plugin>

Thanks and regards, Kurt

解决方案

The wiki article "Menu Contribution" mentions since Eclipse3.3M6 the element

 <visibleWhen/>

An org.eclipse.core.expressions.definitions extension point was added. Used to define a core expression, the definition can then be referenced from other locations.

<extension point="org.eclipse.core.expressions.definitions">
  <definition id="com.example.context">
    <with variable="activeContexts">
       <iterate operator="or">
         <equals value="org.eclipse.ui.contexts.actionSet"/>
       </iterate>
    <with>
  </definition>
</extension>

This can be called in a core expression like activeWhen, enabledWhen, visibleWhen, etc using the reference element:

<reference definitionId="com.example.context"/>

Maybe then a definition like:

could be used for your menu?

这篇关于在Eclipse中以透视方式创建菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆