Eclipse Action 6
来源:互联网 发布:网络固定座机 编辑:程序博客网 时间:2024/05/17 06:59
6.3.2.2. 可见度要素
可见度要素相比于对象贡献的nameFilter 和 objectClass属性,提供了另一种功能强大的方式来指定什么时候对象贡献的action对用户可用,例如,为对象贡献指定过滤方式,可以像下面这样:
name="org.eclipse.core.resources.IResource"/>
...the other stuff here...
如果action只对只读资源可见,那么可见性对象贡献可以像如下这样:
name="org.eclipse.core.resources.IResource"/>
... the other stuff here ...
作为
adapt 使选择的对象适配指定类型,然后可以在任何子表达式中使用新对象。例如,如果你想要使选择的对象(见 20.3节, 适配器)适配一种资源,然后测试一些资源对象状态,那么表达式可以如下:
适配表达式的孩子使用 and 操作符组合起来。如果适配器或者引用的类型都没有被装载,该表达式返回了EvaluationResult.NOT_LOADED。如果类型名不存在,它会在求值的时候抛出ExpressionException异常。
and 如果所有的子元素值为true,则值为true。
instanceof 使用名字来比较选择对象的类。这和objectClass 元素是一样的,只是可以使用and 和 or元素使instanceof和其他的元素组合起来。
not 如果一个元素为false,则为true。
objectClass 向上面描述的那样,用名字比较选择的对象的类。
objectState 和过滤器元素相似,使用指定的状态比较选择对象的状态。(见 6.3.2.3节, 过滤器元素)。
or 如果一个元素为true,则值为true。
pluginState 比较插件的状态,显示其是否被装载或激活。例如,只有org.eclipse.pde插件被装载了,如下的表达式
systemProperty 比较系统属性。例如,如果希望一个对象贡献只有在英文状态下才可见,可以用如下表达式:
systemTest 和systemProperty 元素一样,只是 systemTest 可以使用and 和or 进行组合。
test 设置对象的属性状态。例如,如果一个对象贡献只有在Java项目中的元素被选中时,才处于可见状态,可以使用如下表达式:
property="org.eclipse.debug.ui.projectNature"
value="org.eclipse.jdt.core.javanature"/>
如果执行实际测试的属性测试器没有被装载, test 表达式会返回EvaluationResult.NOT_LOADED。可测试的属性集可以使用org.eclipse.core.expressions.propertyTesters 扩展点来扩展。org.eclipse.debug.internal.ui.ResourceExtender 类是一个很不错的例子。
6.3.2.3. 过滤器元素
过滤器元素比前面讨论的objectState 元素要简单。例如,如果对象贡献只提供给非只读文件,可以使用如下的表达式:
... the other stuff here ...
和objectState 元素一样,, 过滤器元素使用IActionFilter 接口来决定是否选择的对象符合标准。 每个选中的对象必须实现IActionFilter 接口 (参见 20章, 高级主题) ,实现testAttribute() 方法,根据指定对象的状态来测试指定的名字/值。对于资源, Eclipse 提供了如下的内置状态比较关系,在org.eclipse.ui.IResourceActionFilter 类中列出:
name 比较文件名。 "*" 可以用在开头或结尾来代表一个或多个字符。
extension 比较文件扩展名。
path 比较文件路径。"*" 可以用在开头或结尾来代表一个或多个字符。
readOnly 比较文件的只读属性。
projectNature 比较项目特性。
persistentProperty 比较选中资源的持久化属性。如果值是简单的字符串,就检测资源该属性是否存在。如果是propertyName=propertyValue的格式, 就使用指定的名字获取属性的值,检测它与指定值是否相等。
projectPersistentProperty 比较选中资源项目的持久化属性,在语义上与上面的persistentProperty 很相似。
sessionProperty比较选中资源的session属性,在语义上与上面的persistentProperty 很相似。
projectSessionProperty比较选中资源项目的session属性,在语义上与上面的persistentProperty 很相似。
6.3.2.4. 选择元素
选择元素是基于action的名字和类型来设置单个action的可用性,这一点与nameFilter 和 objectClass 属性决定是否一个对象贡献的所有action 都是可见的很相似。
objectClass="java.lang.Object"
id="com.qualityeclipse.favorites.popupMenu">
label="Add to Favorites"
tooltip="Add the selected resource(s) to the
Favorites view"
class="com.qualityeclipse.favorites.actions.
AddToFavoritesActionDelegate"
menubarPath="additions"
enablesFor="+"
id="com.qualityeclipse.favorites.addToFavorites">
class="org.eclipse.core.resources.IResource"
name="*.java"/>
使用了此声明,对象贡献的action将永远可见,但是Add to Favorites action只有在选择的元素中有IResource的实现者,而且名字符合*.java的时候才可用。
6.3.2.5. 可用性元素
可用性元素相比选择元素,是一种功能更强的选择。它支持复杂的条件逻辑表达式和可见度元素比较关系(参见 6.3.2.2节, 可见度元素)。例如, 如下的声明同上面的声明拥有同样的声明:
objectClass="java.lang.Object"
id="com.qualityeclipse.favorites.popupMenu">
label="Add to Favorites"
tooltip="Add the selected resource(s)
to the Favorites view"
class="com.qualityeclipse.favorites.actions.
AddToFavoritesActionDelegate"
menubarPath="additions"
enablesFor="+"
id="com.qualityeclipse.favorites.addToFavorites">
name="org.eclipse.core.resources.IResource"/>
6.3.2.6. 内容敏感的对象贡献
这是一种基于资源内容过滤action的机制。在插件清单文件中指定过滤条件,通过检查文件内容来决定action是否可见或者是否可用。例如,Run Ant... 命令只与build.xml文件相关联,如果Ant脚本写在了export.xml中怎么办? 这种新机制能够基于文件的第一个XML标签或指定的DTD来决定Run Ant...命令是否可见。 org.eclipse.ant.core 插件定义了一个新的antBuildFile 内容类型:
id="antBuildFile"
name="%antBuildFileContentType.name"
base-type="org.eclipse.core.runtime.xml"
file-names="build.xml"
file-extensions="macrodef,ent,xml"
priority="normal">
class="org.eclipse.ant.internal.core.
contentDescriber.AntBuildfileContentDescriber">
上面的声明将antBuildFile 内容类型关联到AntBuildfileContentDescriber 类,此类用来检查是否文件为Ant脚本。antBuildFile 内容类型能够用来指定action的可见度和可用性,编辑器关联,还有更多。想要得到更多的声明和使用你自己的内容类型,参见如下内容:
- "Content Sensitive Object Contributions" 位于 eclipse.org > projects > The Eclipse Project > Platform > UI > Development Resources > Content Sensitive Object Contributions, 或者浏览 dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform-ui-home/object-aware-contributions/objCont.htm.
- "Content types" 位于Eclipse帮助系统 Help > Help Contents > Platform Plug-in Developer Guide > Programmer's Guide > Runtime overview > Content types
- "A central content type catalog for Eclipse" 位于 dev.eclipse.org/viewcvs/index.cgi/platform-core-home/documents/content_types.html?rev=1.11
- Eclipse Action 6
- Eclipse Action 6
- Eclipse Action 6
- Eclipse Action 6
- Eclipse Action
- Eclipse Action
- Eclipse Action
- Eclipse Action 5
- Eclipse Action 4
- Eclipse Action 3
- Eclipse Action 2
- Eclipse Action 5
- Eclipse Action 4
- Eclipse Action 3
- Eclipse Action 2
- Eclipse Action 5
- Eclipse Action 4
- Eclipse Action 5
- 消除主页浏览器差异的一些基本要点
- 组织结构 - 职能型,矩阵型和项目型
- MOICE, 微软发布的OFFICE最新安全功能
- MS CRM Callouts Tip - 调用WCF service in CRM 3 Callouts (.net 1.1)
- EJB3.0 (序)
- Eclipse Action 6
- Printing out your W2 Form using C# and .NET
- MS CRM Callouts Tip - Avoid Dead Loop in Callouts铪
- 项目经理的角色(Roles of Project Manager)
- SWTSwing 和SwingUI 初探
- 对反病毒产品你应该知道的几个事实
- MS CRM Callouts Tip - 在Callouts中调用log4net
- Redirecting Standard Input/Output using the Process Class铪
- commons-beanutils 1.7 新增的 LazyDynaBean