操作的启用和/或可视性分别可使用元素 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)
lightweight (true|false)
icon CDATA #IMPLIED
location (TOP_LEFT|TOP_RIGHT|BOTTOM_LEFT|BOTTOM_RIGHT|UNDERLAY) >
<!ELEMENT description (#PCDATA)>
一个可选的子元素,其主体应该包含为修饰符提供简短描述的文本。这将显示在“修饰符”首选项页面中,因此,建议包括它。缺省值是空字符串。
<!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>
<!ATTLIST objectClass
name CDATA #REQUIRED>
此元素用来对当前选择中的每个对象的类或接口进行求值。如果选择中的每个对象都实现指定的类或接口,则表达式求值为 true。
<!ELEMENT objectState EMPTY>
<!ATTLIST objectState
name CDATA #REQUIRED
value CDATA #REQUIRED>
此元素用来对当前选择中的每个对象的属性状态求值。如果选择中的每个对象都具有指定的属性状态,则表达式求值为 true。要对此类型的表达式进行求值,选择中的每个对象都必须实现或适用于 org.eclipse.ui.IActionFilter 接口。
<!ELEMENT pluginState EMPTY>
<!ATTLIST pluginState
id CDATA #REQUIRED
value (installed|activated) "installed">
此元素用来对插件的状态进行求值。插件的状态可以是下列其中一项:installed(相当于 OSGi 概念中的“resolved”)或者 activated(相当于 OSGi 概念中的“active”)。
<!ELEMENT systemProperty EMPTY>
<!ATTLIST systemProperty
name CDATA #REQUIRED
value CDATA #REQUIRED>
此元素用来对某些系统属性的状态进行求值。属性值是从 java.lang.System 中检索的。
完全修饰符。插件开发者必须处理它们自己的图像支持。
<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>
Copyright (c) 2002, 2005 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0 which accompanies
this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html