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

将要定义一个变量进行校验。必须要用子元素。可以使系统的变量。

例如当前激活的窗口等等。

eclipse core expression usage的更多相关文章

  1. myeclipse 无法启动 java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).

    把myeclipse10 按照目录完整拷贝到了另外一台电脑, 另外的目录 原安装目录 D\:\soft\i\myeclipse10 新安装目录 E\:\soft\myeclipse10 双击启动失败, ...

  2. Eclipse无法启动错误之Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini)

    悲剧,在安装Android Build Tools时,提醒需要关闭Eclipse进行安装,于是我在Tools安装完成后重启了Eclipse.但是Eclipse却无法启动,在log中有如下提示: Una ...

  3. 【转】RCP中org.eclipse.core.runtime.CoreException

    org.eclipse.core.runtime.CoreException: Plug-in TRAIN was unable to load class train.Application. 利用 ...

  4. java.lang.NoClassDefFoundError: org/eclipse/core/resources/IContainer

    启动eclipse报错:java.lang.NoClassDefFoundError: org/eclipse/core/resources/IContainer 解决办法: 删除以下文件.metad ...

  5. Eclipse Groovy插件使用时出现的错误 org.eclipse.core.runtime.InvalidRegistryObjectException: Invalid registry object

    在eclipse marketplace中下载了groovy插件,发现使用的groovy版本跟项目中使用的groovy版本不一致. 于是在Preferences -> Groovy -> ...

  6. eclipse启动错误:java.lang.NoClassDefFoundError: org/eclipse/core/resources/IContainer

    转自:http://blog.csdn.net/niu_hao/article/details/9332521 eclipse启动时报错如下:java.lang.NoClassDefFoundErro ...

  7. SWT/JFace开发遇到org.eclipse.core.runtime.IProgressMonitor问题的解决办法(转载)

    今日正在使用SWT和JFace开发一个系统,在搭建JFace平台时遇到了一个问题,运行HelloWorld程序抛出org.eclipse.core.runtime.IProgressMonitor的n ...

  8. org.eclipse.core.resources.bak文件导致MyEclipse每次关闭时无法保存文件

    MyEclipse关闭时提示如下信息 Problems occurred while trying to save the state of the workbench. Internal Error ...

  9. org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start()

    http://freestyle21.cn 不知什么时候,启动eclipse的时候就一直不行,说是an error ..我查了下log 报错:org.osgi.framework.BundleExce ...

随机推荐

  1. linux上apache并发数与服务器内存关系计算!

    Linunx(本次为ubuntu) apache! 连接数理论上当然是支持越大越好,但要在服务器的能力范围内,这跟服务器的CPU.内存.带宽等都有关系. 查看当前的连接数可以用: ps aux | g ...

  2. 线程使用中常见的错误-“System.InvalidOperationException”线程间操作无效: 从不是创建控件“ ”的线程访问它。

    “System.InvalidOperationException”类型的未经处理的异常在 System.Windows.Forms.dll 中发生 其他信息: 线程间操作无效: 从不是创建控件“la ...

  3. ubuntu装软件包

    查找包 aptitude search pkgName pkgName可以有多个(空格分隔) ffmpeg sudo add-apt-repository ppa:kirillshkrogalev/f ...

  4. sublime断点调试

    系统重装了之后以前装好的zendstudio的xDebug又不能用了 搞了一天,放弃了 看到sublime也能调试,我就用sublime了 首先要下sublime插件 链接:http://pan.ba ...

  5. java:冒泡排序、选择排序、插入排序实现

    整数排序 给一组整数,按照升序排序,使用选择排序,冒泡排序,插入排序或者任何 O(n2) 的排序算法. 样例 样例 1: 输入: [3, 2, 1, 4, 5] 输出: [1, 2, 3, 4, 5] ...

  6. 第七章|7.4并发编程| I/O模型

    I/O模型 协程是单线程下的并发,并不是对性能都有所提升,一定是监测单个线程下的多个任务的I/O,遇到I/O不要让它阻塞,给它自动切换到其他任务去,这样就能提高单个线程下的运行效率.--->&g ...

  7. js数据结构之hash散列的详细实现方法

    hash散列中需要确定key和value的唯一确定关系. hash散列便于快速的插入删除和修改,不便于查找最大值等其他操作 以下为字符和数字的hash散列: function HashTable () ...

  8. 基于Vue.js的uni-app前端框架结合.net core开发跨平台project

    一.由来 最近由于业务需要要开发一套公益的APP项目,因此结合所给出的需求最终采用uni-app这种跨平台前端框架以及.netcore快速搭建我们的项目,并且能做到一套代码跨多个平台. 当然在前期技术 ...

  9. Codeforces Round #514 (Div. 2)

    目录 Codeforces 1059 A.Cashier B.Forgery C.Sequence Transformation D.Nature Reserve(二分) E.Split the Tr ...

  10. Shiro笔记(一)基本概念

    Shiro笔记(一)基本概念 一.简介 Shiro是一个Java安全框架,可以帮助我们完成:认证.授权.加密.会话管理.与Web集成.缓存等. Authentication:身份认证/登录,验证用户是 ...