简体   繁体   English

Eclipse插件:自定义plugin.xml,例如编辑器

[英]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 ). 您可以为此使用FormEditororg.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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM