博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
eclipse core expression usage
阅读量:6257 次
发布时间:2019-06-22

本文共 3048 字,大约阅读时间需要 10 分钟。

We need to set checkEnabled on the visibleWhen element to false, otherwise the expression will not be active. The section uses activePartId as source. It is a string containing the ID of the active view/editor (see ).

Core expressions are declarative or programmatic expressions based on the org.eclipse.core.expressions plugin. 通过org.eclipse.core.expression 去实现

 

 

 

The uses 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:

 

重用表达式

 

 

  • 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:

 

 

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

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

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

转载地址:http://fzxsa.baihongyu.com/

你可能感兴趣的文章
JS/atan2 pow
查看>>
Pythoh网络编程3:创建TCP服务器和客户端
查看>>
angularjs 出现 “Possibly unhandled rejection: cancel ”错误
查看>>
bzoj 2653 middle (主席树+二分)
查看>>
指导别人,弥补自己
查看>>
BZOJ3932: [CQOI2015]任务查询系统
查看>>
和make相关的一些命令
查看>>
Fiddler抓取https设置及其原理
查看>>
常用的一些模板
查看>>
WPF使用Expression Design设计图形
查看>>
Ubuntu 下Qt安装实用教程
查看>>
DNS 协议2
查看>>
Ubuntu 隐藏所有窗口快捷键不生效问题
查看>>
编译Spring源码
查看>>
javascript运算符优先级
查看>>
Spring Cloud 学习 (七) Spring Cloud Sleuth
查看>>
使用docker api
查看>>
Log4j简单配置解析
查看>>
游戏上线... 记录下...
查看>>
js运动 淡入淡出
查看>>