eclipse visiblewhen
时间: 2023-06-28 10:13:07 浏览: 34
在Eclipse中,visiblewhen元素用于在特定条件下控制菜单、工具栏、视图等的可见性。该元素定义了一个表达式,当该表达式返回true时,相应的菜单、工具栏或视图将显示在Eclipse UI中。
例如,以下代码片段定义了一个在特定条件下显示的菜单项:
```
<menuContribution
locationURI="menu:org.eclipse.ui.file.menu?after=additions">
<menu
label="My Menu"
id="com.example.myMenu"
visibleWhen="com.example.myCondition">
<command
commandId="com.example.myCommand"
label="My Command"
style="push"
tooltip="My Command ToolTip"/>
</menu>
</menuContribution>
```
在这个例子中,visibleWhen属性的值是一个表达式"com.example.myCondition",该表达式定义了一个条件,当满足该条件时,"My Menu"菜单项将在文件菜单下显示。要使该表达式返回true,需要实现一个扩展org.eclipse.core.expressions.definitions扩展点,该扩展点定义了一个名称为"com.example.myCondition"的表达式。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)