2015-07-03 153 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为需要并且类型为标识符