[英]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.