Decorator

識別碼:org.eclipse.ui.decorators

從: 版本 2.0

說明:這個延伸點是用來新增 Decorator 至向 Decorator 管理程式訂閱的檢視畫面。 如同 2.1 一般,將有輕量型 Decorator 的概念,用來處理 Decorator 的影像管理。 同時也可能宣告一個輕量型 Decorator,僅在啟用時才覆蓋一個不需要來自外掛程式的任何實作方式的圖示。

您可以分別使用 enablementvisibility 元素, 來定義動作的啟用狀態及/或可見性狀態。這兩個元素含有一個 boolean 表示式, 將被計算以決定啟用及/或可見性的狀態。

enablement 元素和 visibility 元素的語法是相同的。 這兩者僅含有一個 boolean 表示式子元素。在最簡單的情況中, 這將是 objectClassobjectStatepluginStatesystemProperty 元素。 在其他較複雜的情況中,andornot 元素可以結合以構成 boolean 表示式。andor 元素兩者必須含有 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)>

   主體應含有文字來提供 Decorator 之簡短說明的選用子元素。將顯示在 Decorators 喜好設定頁面,所以建議將它併入。預設值是空字串。

   <!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>

   這個元素係用來計算現行選擇中每個物件的類別或介面。 如果選擇中的每個物件都實作指定的類別或介面,則表示式將計算為 true。

   <!ATTLIST objectClass
     name CDATA #REQUIRED
   >

   <!ELEMENT objectState EMPTY>

   這個元素係用來計算現行選擇中每個物件的屬性狀態。 如果選擇中的每個物件都具有指定的屬性狀態,則表示式將計算為 true。 如果要計算這種類型的表示式,則選擇中的每個物件都必須實作或適合於 org.eclipse.ui.IActionFilter 介面。

   <!ATTLIST objectState
     name  CDATA #REQUIRED
     value CDATA #REQUIRED
   >

   <!ELEMENT pluginState EMPTY>

   這個元素係用來計算外掛程式的狀態。外掛程式的狀態可以是下列之一:installedactivated

   <!ATTLIST pluginState
      id    CDATA #REQUIRED
     value (installed|activated) "installed"
   >

   <!ELEMENT systemProperty EMPTY>

   這個元素係用來計算某個系統內容的狀態。內容值擷取自 java.lang.System

   <!ATTLIST systemProperty
     name  CDATA #REQUIRED
     value CDATA #REQUIRED
   >
範例:以下是 Decorator 的範例:

完整 Decorator。外掛程式開發人員必須處理他們自己的影像支援。

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

輕量型 Decorator。有一個具體類別,但當它是 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> 

宣告的小型 Decorator。沒有具體類別,所以它提供一個圖示,以及要套用該圖示的象限。

 <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 之類別的完整名稱。這個類別的載入要儘可能晚,以避免在真正需要它之前載入整個外掛程式。 宣告的 Decorator 不需要任何外掛程式啟動,因此應該儘可能使用它。非小型的 Decorator 最終將作廢。

提供的實作方式:外掛程式可以使用這個延伸點, 將要套用的新 Decorator 新增至使用 Decorator 管理程式作為其標籤 Decorator 的檢視畫面。 若要使用 Decorator 管理程式,請使用 IViewPart.getDecoratorManager() 的結果, 作為 DecoratingLabelProvider 實例的 Decorator。目前正被「資源瀏覽器」使用。

Copyright (c) 2002,2003 IBM Corporation and others. All rights reserved. 這個程式和伴隨的素材可以根據伴隨這個分送,而且可在 http://www.eclipse.org/legal/cpl-v10.html 中取得的 Common Public License v1.0 的條款來使用