您可以分別使用 enablement 和 visibility 元素, 來定義動作的啟用狀態及/或可見性狀態。這兩個元素含有一個 boolean 表示式, 將被計算以決定啟用及/或可見性的狀態。
enablement 元素和 visibility 元素的語法是相同的。這兩者僅含有一個 boolean 表示式子元素。在最簡單的情況下, 這將是 objectClass、objectState、pluginState 或 systemProperty 元素。在其他較複雜的情況下,and、or 及 not 元素可以結合以構成 boolean 表示式。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)>
這個元素代表 Boolean AND 運算,以算出它的兩個子元素表示式的結果。
<!ELEMENT or (and | or | not | objectClass | objectState | pluginState | systemProperty)>
這個元素代表 Boolean OR 運算,以算出它的兩個子元素表示式的結果。
<!ELEMENT not (and | or | not | objectClass | objectState | pluginState | systemProperty)>
這個元素代表 Boolean 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(相等於 "resolved" 的 OSGi 概念)或 activated(相等於 "active" 的 OSGi 概念)。
<!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, 2004 IBM Corporation and others.
All rights reserved.
本程式與隨附的資料依照 Elipse Public License 1.0 版此次發行所隨附的條款而提供,
可以在以下網址取得:http://www.eclipse.org/legal/epl-v10.html