[英]Eclipse plug-in: Custom plugin.xml like editor
I've been trying to mimic the plugin.xml
editor in my own Eclipse plug-in. 我一直在尝试在自己的Eclipse插件中模仿
plugin.xml
编辑器。 I want a graphical editor for a custom file type. 我想要一个用于自定义文件类型的图形编辑器。 The same way in which PDE has a specific form/editor to open
plugin.xml
. PDE具有特定的表单/编辑器来打开
plugin.xml
。
From what I understand I can implement a text Editor
and link a file type to open in a particular editor. 据我了解,我可以实现文本
Editor
并链接文件类型以在特定的编辑器中打开。 To add a graphical aspect I can make a Form
. 要添加图形方面,我可以制作一个
Form
。
What I don't understand is how to link this Form
to my custom file type. 我不明白的是如何将此
Form
链接到我的自定义文件类型。
I would try adding the following two entries in your plugin.xml
file: 我会尝试在您的
plugin.xml
文件中添加以下两个条目:
Firstly, add a contentType
plugin extension, where you specify the file extension
: 首先,添加
contentType
插件扩展名,在其中指定file extension
:
Then, as you said, you need to implement the editor. 然后,正如您所说,您需要实现编辑器。 Add an
editors
plugin, in which you implement your editor. 添加一个
editors
插件,您可以在其中实现编辑器。 Don't forget to enable the default
option: 不要忘记启用
default
选项:
After that, add a new contentTypeBinding
subnode to the edior. 之后,将新的
contentTypeBinding
子节点添加到edior。 There you need to use the id of the content type: 在那里,您需要使用内容类型的ID:
Also, do not forget to add the view in your perspective. 另外,不要忘记在您的透视图中添加视图。
PS I have tested this just now with a simple TextEditor
, and it should work: PS我刚刚用一个简单的
TextEditor
测试了它,它应该可以工作:
You can use FormEditor
for this ( org.eclipse.ui.forms.editor.FormEditor
). 您可以为此使用
FormEditor
( org.eclipse.ui.forms.editor.FormEditor
)。 This extends the more basic MultiPageEditorPart
. 这扩展了更基本的
MultiPageEditorPart
。
FormEditor
supports multiple pages, these can be form based using the FormPage
class, or based on an ordinary text editor, or even just an arbitary set of SWT controls. FormEditor
支持多个页面,这些页面可以是使用FormPage
类的表单,也可以是基于普通文本编辑器的表单,甚至可以是任意的SWT控件集。 So this allows you to have a arrangement like to plugin.xml editor (which is it a FormEditor
). 因此,这使您可以进行类似于plugin.xml编辑器(即
FormEditor
)的安排。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.