eclipse core expression usage
http://codeandme.blogspot.com/2012/04/expression-examples.html
We need to set checkEnabled on the visibleWhen element to false, otherwise the expression will not be active. The withsection uses activePartId as source. It is a string containing the ID of the active view/editor (see description).
http://wiki.eclipse.org/Command_Core_Expressions#Variables_and_the_Command_Framework
Core expressions are declarative or programmatic expressions based on the org.eclipse.core.expressions plugin. 通过org.eclipse.core.expression 去实现
The Platform Command Framework uses core expressions for enabledWhen and activeWhen for handlers, programmatic activation of contexts, and for visibleWhen for menu contributions. The command framework provides the IEvaluationContext that command core expressions are evaluate against.
The IEvaluationContext provides a default variable for evaluations, and a number of named variables. In the command framework, we provide the global selection as ajava.util.Collection
as the default variable. It can either be empty, have one entry (if the ISelection was something like an ITextSelection), or have the contents of an IStructuredSelection.
The <with/> element can be used to change which variable the child expression elements are evaluating against.
eclipse plugin中的command引入了core expressions 去激活对应的command
enabledWhen,activeWhen是用于handler;
visibleWhen适用于menu菜单
Re-Usable expressions
Sometimes you will end up with having the same expression in many different places. When one of them changes, you have to change them all. Obviously, this is inefficient and not very handy - let alone error prone. You can get around this problem by using definitions and re-use expressions that are declared elsewhere.
The expression from the example above can be declared using the org.eclipse.core.expressions.definitions
extension point, and then re-used using the<reference>
element:
重用表达式
http://wiki.eclipse.org/Platform_Expression_Framework
- Should an context menu be enabled and/or visible in a context menu menu应该不应该显示或者是可用
- Which implementation for a command handler to use depending on the current context 在当前上下文哪个handler应该被用
- Which label provider to use for an object 哪个provider应该被用
- Which content provider can provide children for an object in a tree
<or>element 包含一个表达式块
表达式块:
instanceof:
adapt:
<reference
definitionId="org.acme.navigator.enablement">
</reference>
Usually, expressions check the default variable in the evaluation context. However, it is possible for an expression to select a specific variable from the context using the <with>
element (examples below).
通常是检查默认的变量,但是可以通过with来检查变量。
当处理一个collection的时候我们通常想要知道这个collection中的内容
这里用到了<iterate> <count>
They require an iterable object to work (otherwise they fail with an error message on the console)他们必须是一个可迭代的对象。
默认的变量时当前的选中的,但是可能是整个结构。
ITextSelection
), or contain the elements of an IStructuredSelection
.
adapt,and,or,not 可以包含内部元素。
count不能包含元素,他是计算collection中的元素数目。
它最好可以与<iterate>使用遍历里面的所有元素个数。
<count value=”2” />
<iterate ifempty=’’false”>
<instance of value=”” />
</iterate>
resolve将要不会再用。
As of eclipse 3.5, there is no implementation in either the command framework or the common navigator framework for IVariableResolver, so the <resolve>
operator is of no use for them.
systemTest
测试系统中的属性值
java.lang.System.getProperties
With
将要定义一个变量进行校验。必须要用子元素。可以使系统的变量。
例如当前激活的窗口等等。
最新文章
- 一步步学习javascript基础篇(8):细说事件
- 64位CentOS源码编译方式安装wine
- java复习基础知识——java保留字
- discuz 同步登录问题
- SQL 调试:无法启动 T-SQL 调试。未能附加到 SQL Server 进程
- HDU 4948
- 最短路径算法之三——Bellman-Ford算法
- Django学习(二) Django框架简单搭建
- 剑指Offer——京东实习笔试题汇总
- 关于读取mapper的两种方式
- JavaScript之能力与硬件检测[小结]
- Python中Queue模块及多线程使用
- SWIFT中切換UIContainerView內的Controller
- (转)Python 字符串
- 集合之asList的缺陷
- COM如何区分套间线程(apartment thread)和自由线程(free thread)
- eclipse集成testng插件(离线安装方式)
- mysql 从一个表中查询插入另一个表
- HTML和CSS的盒子模型(Box model)
- eclipse及tomcat web站點