【问题标题】:How to associate extension with custom editor in Eclipse 4如何在 Eclipse 4 中将扩展与自定义编辑器相关联
【发布时间】:2013-09-23 09:35:08
【问题描述】:

我最近迁移到 Eclipse 4。在 Eclipse 3.x 中,要定义哪个编辑器将与文件扩展名关联,我必须定义编辑器扩展名以及与之关联的扩展名。如何在 Eclipse 4 中做到这一点,其中编辑器不再从 EditorPart 继承,但它是使用依赖注入定义的部分。

这是版本。当我们在项目视图中双击具有特定扩展名(例如 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> 

【问题讨论】:

  • 如果您正在创建一个“纯”e4 应用程序(不使用任何 Eclipse 3 兼容代码),那么就没有将文件类型与编辑器相关联的内置机制。

标签: eclipse eclipse-plugin eclipse-rcp


【解决方案1】:

有趣的是,即使在 Kepler 的示例插件项目中,也使用了 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.*,而无需为此进行任何更改(出于反向兼容性的原因,我很确定我不想这样做)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    • 2015-10-04
    • 1970-01-01
    相关资源
    最近更新 更多