![](/img/trans.png)
[英]In plug-in.xml how to associate a file extension with a particular kind of editor in eclipse plug-in
[英]How to associate extension with custom editor in Eclipse 4
我最近移到了Eclipse4。在eclipse 3.x中,要定义与文件扩展名关联的编辑器,我必须定义与文件扩展名关联的编辑器扩展。 如何在Eclipse 4中做到这一点,在该版本中,编辑器不再从EditorPart
继承,而是通过依赖项注入定义的一部分。
这是旧版本。 当我们在Projects View中双击具有某些扩展名(例如bcx)的文件时,定义打开自定义编辑器的最佳实践是什么?
<extension
point="org.eclipse.ui.editors">
<editor
class="com.abb.pestc.cothex.ui.editors.AirToAirEditor"
default="true"
extensions="acx"
icon="icons/cothexAirToAir.png"
id="com.abb.pestc.cothex.ui.editors.AirToAirEditor"
name="Air to Air Editor">
</editor>
<editor
class="com.abb.pestc.cothex.ui.editors.BaseToAirEditor"
default="true"
extensions="bcx"
icon="icons/cothexBaseToAir.png"
id="com.abb.pestc.cothex.ui.editors.BaseToAirEditor"
name="Base to Air Editor">
</editor>
</extension>
有趣的是,即使在开普勒的示例插件项目中,也使用3. *代码:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.editors">
<editor
name="Sample XML Editor"
extensions="xml"
icon="icons/sample.gif"
contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
class="tempse.editors.XMLEditor"
id="tempse.editors.XMLEditor">
</editor>
</extension>
</plugin>
因此,我怀疑答案是“您之前做过的方式相同”。 我只是将自定义编辑器项目从3. *移到了4. *,而不必在那末进行任何更改(并且出于反向兼容性的原因,我很确定我不想这样做)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.