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. 分布式任务调度系统xxl-job搭建(基于docker)

    一.简介 XXL-JOB是一个轻量级分布式任务调度平台,其核心设计目标是开发迅速.学习简单.轻量级.易扩展.现已开放源代码并接入多家公司线上产品线,开箱即用. 更多介绍,请访问官网: http://w ...

  2. Python 检测系统时间,k8s版本,redis集群,etcd,mysql,ceph,kafka

    一.概述 线上有一套k8s集群,部署了很多应用.现在需要对一些基础服务做一些常规检测,比如: 系统时间,要求:k8s的每一个节点的时间,差值上下不超过2秒 k8s版本,要求:k8s的每一个节点的版本必 ...

  3. ElasticSearch - How to search for a part of a word with ElasticSearch

    Search a part of word with ElasticSearch 来自stackoverflow https://stackoverflow.com/questions/6467067 ...

  4. 【AtCoder】AGC017

    在此处输入标题 标签(空格分隔): 未分类 A - Biscuits dp[i][0/1]表示当前和是偶数还是奇数,直接转移即可 #include <bits/stdc++.h> #def ...

  5. python全栈开发day13-迭代器、生成器、列表推导式等

    昨日内容:函数的有用信息.带参数的装饰器.多个装饰器修饰一个函数 迭代器 可迭代对象:内部含有__iter__方法 迭代器 定义:可迭代对象.__iter__()就是迭代器,含有__iter__且__ ...

  6. Educational Codeforces Round 26-D. Round Subset

    题目大意:给你n个数字(小于1e18),从n个数中取k个数字相乘,使其后缀0最多,问你后缀0最多是多少. 知道得用三维的dp[ i ] [ j ] [ k ]  第一维表示用到第 i 个数为止,j 表 ...

  7. django基类View.as_view()

    参考:https://www.zmrenwu.com/post/53/ 详细见参考 一般请求的判断方法: def view(request, *args, **kwargs): if request. ...

  8. POJ 2752 (kmp求所有公共前后缀长度)

    <题目链接> <转载于> 题目大意:  给出一个字符串str,求出str中存在多少子串,使得这些子串既是str的前缀,又是str的后缀.从小到大依次输出这些子串的长度.即输出该 ...

  9. 通过反射的方式注入自己的ShutdownHook并清除其他HOOK

    String className = "java.lang.ApplicationShutdownHooks"; Class<?> clazz = Class.forN ...

  10. ubuntu安装nodejs出现./config.gypi错误

    报错的内容如下: xxx@xxx [/usr/local/src/node-v0.8.3]# ./configure { 'target_defaults': { 'cflags': [], 'def ...