让我们考虑一个名为"Column editor"的编辑器,其中有许多列。我们将此列作为"扩展点"提供,因此任何想要贡献列的人都可以向此扩展点添加"扩展"。
现在,我们正在为这些列提供排序功能。每当编辑器启动并加载列时,列数据都应按"默认列"(其中一个来自已贡献列(进行排序。
首先,我想为这些"扩展点"提供一个属性,以设置它是否是默认排序的列。但是,多重贡献为该属性提供了"true",这导致了歧义。
有没有一个值可以消除这种模糊性,并为一个默认排序列提供一个干净的解决方案?
我想提供另一个扩展点,并说明哪一列可以作为默认排序列。但是,这需要参考Extension。如何在Extension点中引用另一个Extension?
因此,我正在考虑提供另一种扩展
一个扩展点引用另一个是很常见的。
例如,查看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
元素指的是这里声明id为org.eclipse.ant.core.antBuildFile
的contentTypeId
:
<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为必需,并具有标识符