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

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

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

时间: 2024-10-06 09:04:09

eclipse core expression usage的相关文章

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

转自:http://blog.csdn.net/niu_hao/article/details/9332521 eclipse启动时报错如下:java.lang.NoClassDefFoundError: org/eclipse/core/resources/IContainer解决方法:可能是丢失部分起动文件,解决... eclipse启动时报错如下: java.lang.NoClassDefFoundError: org/eclipse/core/resources/IContainer 解

org.eclipse.core.resources.natures org.eclipse.core.resources.builders扩展点介绍

builder和nature是Eclipse中提供的两个扩展点.一般来说我们都是先有自己特定的project类型,然后在这类project上加上自定义的builder和nature. 其实所谓的特定的project通常都是由特有的nature来标识的:而又一般builder是建立在某类特定的project上,所以我们可以得出:Nature决定了project和builder. 1.创建nature扩展点 <extension id="nature" name="Work

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

org.eclipse.core.runtime.CoreException: Plug-in TRAIN was unable to load class train.Application. 利用UP将其移到第一位 再次运行程序,OK. 网络力量是无穷的,这是一个庞大的知识库,有很多营养供我们汲取,谢谢每一个无私分享学习经历.学习成果的人们! 注意:RCP在运行时要使用自己的类包,要在classpath中配置添加,common-logging.jar,spring.jar. 当在RCP中使用

Eclipse启动报错:An internal error occurred during: &quot;Updating indexes&quot;.org/eclipse/core/runtime/internal/adaptor/BasicLocation解决方法

Eclipse一直用的好好的,突然这两天每次启动都会出现如下的错误:An internal error occurred during: "Updating indexes".org/eclipse/core/runtime/internal/adaptor/BasicLocation,刚开始没有在意,以为是机器的内存不够导致,但后来发现不是怎么回事,刚开机,打开Eclipse也报这个错误.找到Eclipse的日志文件,workspace/.metadata/.log,查询"

VCSA6.0 /storage/core 100% Usage

VCSA6.0 /storage/core 100% Usage due to the big core dumps. I ran into this issue recently when one of the vCenter appliances in my test environment triggered this alarm in the vSphere web client: Logging into the VCSA via SSH and running 'df –h' sho

Core Expression

https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm A Cron Expressions Cron expressions are used to configure instances of CronTrigger, a subclass of org.quartz.Trigger. A cron expression is a string consisting of six or sev

org.eclipse.core.internal.resources.ResourceException: A resource exists with a different case:

在使用Eclipse进行开发的时候,出现了如下的问题: Description Resource Path Location Type The project was not built due to "A resource exists with a different case: '/SeenTaoImp_zhV2/bin/seentao'.". Fix the problem, then try refreshing this project and building it si

com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Unable to read D:\系统软件\安卓工作空间\4-15\AndroidManifest.xml: org.eclipse.core.internal.resources.ResourceException

解决: 进入:C:\Documents and Settings\Administrator\.android删除:debug.keystore及 ddms.cfg

Description Resource Path Location Type Unknown Unknown Unknown org.eclipse.core.internal.resources.Marker is not of a displayable type

是访问限制报错. 方法一: 全局属性Project>preferences>java>Compiler>Errors/Warnings>把右侧的[Deprecated and restricted API>Forbidden reference的Error]置为[Warning]. 方法二(终极方法:) 项目属性preferences>java build path>把右侧[libraries中的JRE System Library]删除重新导入. 原文地址