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.definitionsextension 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

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

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


本文转自hcy's workbench博客园博客,原文链接:http://www.cnblogs.com/alterhu/p/4032580.html,如需转载请自行联系原作者。


目录
相关文章
|
Android开发 Python 运维
|
5月前
|
Java Maven Android开发
在Eclipse里配置Maven插件
Maven是一款比较常用的Java开发拓展包,它相当于一个全自动jar包管理器,会导入用户开发时需要使用的相应jar包。使用Maven开发Java程序,可以极大提升开发者的开发效率。下面我就跟大家介绍一下如何在Eclipse里安装和配置Maven插件。
131 0
|
5月前
|
XML Java Maven
eclipse 、idea 安装activiti插件
eclipse 、idea 安装activiti插件
114 0
|
10月前
|
Java Android开发
eclipse安装SpringBoot插件的无敌办法
eclipse安装SpringBoot插件的无敌办法
100 0
|
10月前
|
Java Android开发 Spring
在 Eclipse 中安装 SpringTools 插件
在 Eclipse 中安装 SpringTools 插件
107 0
|
11月前
|
XML Java 应用服务中间件
Eclipse插件下载地址汇总
Eclipse插件下载地址汇总
256 0
|
12月前
|
存储 Android开发
Eclipse安装Flowable Eclipse Designer插件实现图形建模BPMN 2.0流程图
Eclipse安装Flowable Eclipse Designer插件实现图形建模BPMN 2.0流程图
342 0
|
IDE Java Apache
Eclipse 安装了 Groovy 开发插件之后,双击打不开 .java 文件了
Eclipse 安装了 Groovy 开发插件之后,双击打不开 .java 文件了
|
Android开发
Eclipse 里一个 SAP Hybris Commerce 的开发插件
Eclipse 里一个 SAP Hybris Commerce 的开发插件