2016-07-22 41 views
0

我一直試圖在我自己的Eclipse插件中模仿plugin.xml編輯器。我想要一個自定義文件類型的圖形編輯器。 PDE具有特定表單/編輯器以打開plugin.xml的相同方式。Eclipse插件:像編輯器一樣定製plugin.xml

根據我的理解,我可以實現文本Editor並鏈接文件類型以在特定編輯器中打開。要添加圖形方面,我可以製作一個Form

我不明白的是如何將此Form鏈接到我的自定義文件類型。

+1

看看FormEditor。 –

+0

也許這可能會有幫助,還有一個類似的問題:https://stackoverflow.com/questions/15877123/eclipse-rcp-programmatically-associate-file-type-with-editor。 – DrKaoliN

回答

1

您可以使用FormEditor這個(org.eclipse.ui.forms.editor.FormEditor)。這擴展了更基本的MultiPageEditorPart

FormEditor支持多頁,這些都可以形成可以根據使用FormPage類,或基於普通的文本編輯器,甚至只是一個arbitary集SWT控制。所以這可以讓你有一個像plugin.xml編輯器(這是一個FormEditor)的安排。

1

我會嘗試加入以下兩個項目在您的plugin.xml文件:

首先,加contentType插件擴展,在那裏你指定file extension

enter image description here

然後,如你所說,你需要實現編輯器。添加一個editors插件,在其中實現您的編輯器。不要忘了啓用default選項:

enter image description here

之後,添加一個新的子節點contentTypeBinding向edior。在那裏,您需要使用內容類型的ID:

enter image description here

另外,不要忘記添加視圖在你的觀點。

enter image description here

附:我有一個簡單的TextEditor剛纔進行了測試,它應該工作:

enter image description here

+0

感謝您的答覆,但我正在尋找實施圖形編輯器。發現使用'MultiPageEditorPart'而不是'TextEditor'就可以做到。 – Araf