2015-07-03 155 views
0


讓我們考慮一個名爲'列編輯器'的編輯器,我們有許多列。我們已經將此列作爲「擴展點」提供,以便任何想貢獻列的人都可以在此擴展點上添加「擴展名」。擴展點引用另一個擴展

現在,我們正在爲這些列提供排序功能。無論何時編輯器啓動並且列正在加載,列數據應按「默認列」(來自貢獻列中的一個)進行排序。

首先,我想爲這些'擴展點'提供一個屬性來設置它是否是默認排序的列。但是,多重貢獻爲這個屬性提供了「真實」,並且導致了含糊不清。

是否有價值來消除這種歧義,並提供一個默認排序列的乾淨解決方案?

我想提供另一個擴展點,並說哪個列可以是默認的排序列。但是,這需要對Extension的引用。如何引用擴展點中的另一個分機?

因此,我想提供另一個分機的proint

回答

1

這是很常見的一個擴展點是指另一個。

例如,看看Ant編輯聲明:

<extension 
    point="org.eclipse.ui.editors"> 
    <editor 
     name="%AntEditor.name" 
     icon="$nl$/icons/full/obj16/ant_buildfile.png" 
     class="org.eclipse.ant.internal.ui.editor.AntEditor" 
     contributorClass="org.eclipse.ant.internal.ui.editor.AntEditorActionContributor" 
     id="org.eclipse.ant.ui.internal.editor.AntEditor"> 
     <contentTypeBinding 
      contentTypeId="org.eclipse.ant.core.antBuildFile"/> 
    </editor> 

contentTypeBinding元素是指contentTypeId與ID org.eclipse.ant.core.antBuildFile宣稱這裏:

<extension 
    point="org.eclipse.core.contenttype.contentTypes"> 
    <content-type 
     id="org.eclipse.ant.core.antBuildFile" 
     name="%antBuildFileContentType.name" 
     base-type="org.eclipse.core.runtime.xml" 
     file-names="build.xml" 
     file-extensions="macrodef,ent,xml,ant" 
     priority="normal"> 
     <describer 
      class="org.eclipse.ant.internal.core.contentDescriber.AntBuildfileContentDescriber"> 
     </describer> 
    </content-type> 
</extension> 

所以關鍵事情是爲擴展提供一個唯一的ID。在您的擴展點模式中,您聲明該ID爲需要並且類型爲標識符