起始发行版:发行版 2.0
描述:此扩展点用来将修饰符添加到遵从修饰符管理器的视图。 对于 2.1,存在轻量级修饰符的概念,它用来处理修饰符的图像管理。还有可能声明启用时只覆盖图标不需要插件中的实现的轻量级修饰符。
操作的启用和/或可视性分别可使用元素 enablement 和 visibility 定义。这两个元素包含进行求值来确定启用和/或可视性的布尔表达式。
enablement 和 visibility 元素的语法相同。两者都只包含一个布尔表达式子元素。在最简单的情况下,这将是 objectClass、objectState、pluginState 或 systemProperty 元素。在更复杂的情况下,可复合 and、or 和 not 元素来组成布尔表达式。and 和 or 元素必须包含 2 个子元素。not 元素一定只能包含 1 个子元素。
配置标记:
<!ELEMENT extension (decorator*)>
<!ATTLIST extension
point CDATA #REQUIRED
id CDATA #IMPLIED
name CDATA #IMPLIED
>
<!ELEMENT decorator (description? , enablement?)>
<!ATTLIST decorator
id CDATA #REQUIRED
label CDATA #REQUIRED
class CDATA #IMPLIED
objectClass CDATA #IMPLIED
adaptable (true | false)
state (true | false)
quadrant (TOP_LEFT|TOP_RIGHT|BOTTOM_RIGHT|BOTTOM_LEFT)
lightweight (true|false)
icon CDATA #IMPLIED
location (TOP_LEFT|TOP_RIGHT|BOTTOM_LEFT|BOTTOM_RIGHT|UNDERLAY)
>
<!ELEMENT description (#CDATA)>
一个可选的子元素,其主体应该包含为修饰符提供简短描述的文本。这将显示在“修饰符”首选项页面中,因此,建议包括它。缺省值是空“字符串”。
<!ELEMENT enablement (and | or | not | objectClass | objectState | pluginState | systemProperty)>
此元素用来定义操作的启用。
<!ELEMENT visibility (and | or | not | objectClass | objectState | pluginState | systemProperty)>
此元素用来定义操作的可视性。
<!ELEMENT and (and | or | not | objectClass | objectState | pluginState | systemProperty)>
此元素表示对其两个子元素表达式求值的结果的布尔 AND 操作。
<!ELEMENT or (and | or | not | objectClass | objectState | pluginState | systemProperty)>
此元素表示对其两个子元素表达式求值的结果的布尔 OR 操作。
<!ELEMENT not (and | or | not | objectClass | objectState | pluginState | systemProperty)>
此元素表示对其子元素表达式求值的结果的布尔 NOT 操作。
<!ELEMENT objectClass EMPTY>
此元素用来对当前选择中的每个对象的类或接口进行求值。如果选择中的每个对象都实现指定的类或接口,则表达式求值为 true。
<!ATTLIST objectClass<!ELEMENT objectState EMPTY>
此元素用来对当前选择中的每个对象的属性状态求值。如果选择中的每个对象都具有指定的属性状态,则表达式求值为 true。要对此类型的表达式进行求值,选择中的每个对象都必须实现或采用 org.eclipse.ui.IActionFilter 接口。
<!ATTLIST objectState<!ELEMENT pluginState EMPTY>
此元素用来对插件的状态进行求值。插件的状态可以是下列项之一:installed 或 activated。
<!ATTLIST pluginState<!ELEMENT systemProperty EMPTY>
此元素用来对某些系统属性进行求值。属性值是从 java.lang.System 中检索的。
<!ATTLIST systemProperty完全修饰符。插件开发者必须处理它们自己的图像支持。
<extension point="org.eclipse.ui.decorators"> <decorator id="com.xyz.decorator" label="XYZ Decorator" state="true" class="com.xyz.DecoratorContributor"> <enablement> <objectClass name="org.eclipse.core.resources.IResource"/> </enablement> </decorator> </extension>
轻量级修饰符。存在具体类,但因为它是 ILightweightLabelDecorator,所以它只需要提供文本和 ImageDescriptor 并因此不需要资源处理。
<extension point="org.eclipse.ui.decorators"> <decorator id="com.xyz.lightweight.decorator" label="XYZ Lightweight Decorator" state="false" class="com.xyz.LightweightDecoratorContributor" lightweight="true" > <enablement> <objectClass name="org.eclipse.core.resources.IResource"/> </enablement> </decorator> </extension>
可声明的轻量级修饰符。不存在具体类,所以它提供一个图标和一个应用该图标的象限。
<extension point="org.eclipse.ui.decorators"> <decorator id="com.xyz.lightweight.declarative.decorator" label="XYZ Lightweight Declarative Decorator" state="false" lightweight="true" icon="icons/full/declarative.gif" location="TOP_LEFT"> <enablement> <objectClass name="org.eclipse.core.resources.IResource"/> </enablement> </decorator> </extension>
API 信息:class 属性的值必须是实现 org.eclipse.jface.viewers.ILabelDecorator(如果 lightweight 为 false)或者 org.eclipse.jface.viewers.ILightweightLabelDecorator 的类的全限定名。尽可能迟地装入此类以避免在真正需要整个插件之前就装入该插件。可声明的修饰符不需要任何插件激活并且应尽可能使用。最终将建议不要使用非轻量级修饰符。
所提供的实现:插件可以使用此扩展点来将要应用的新修饰符添加至将修饰符管理器用作它们的标号修饰符的视图。要使用修饰符管理器,将 IViewPart.getDecoratorManager() 的结果用作 DecoratingLabelProvider 的实例的修饰符。“资源导航器”当前正在使用它。
Copyright (c) 2002,2003 IBM Corporation and others.
All rights reserved. 该程序及附带提供的资料是基于“一般公共许可证”(Common
Public License) v1.0 的条款提供的,本发行版中提供了该许可证条款,并且也可
在以下位置处找到该条款:http://www.eclipse.org/legal/cpl-v10.htm