在多页编辑器MultiPageEditorPart中加入xml编辑功能

最近在做一个GEF多页编辑器,图形用xml格式保存。为了简单,在source标签页应用了eclipse已经存在xml编辑器。

基本思路用两种:一种是自己的多页编辑器继承XMLMultiPageEditorPart,这样就会继承来design、source两个标签页,然后再加入自己的编辑器页,JBPM designer插件就是用这种思路实现的。
另一种是直接引入source编辑页到自己的MultiPageEditorPart中,也就是StructuredTextEditor。项目中采用了后一种思路。

eclipse.org上有一篇文章对引入StructuredTextEditor有详细的介绍:
[url]http://www.eclipse.org/webtools/wst/components/sse/tutorials/multipage-editor-tutorial.html[/url]

在实现过程中发现,如果设置编辑文件的扩展名为.xml是没有问题的,如果默认扩展名不是.xml,则显示的xml文档是黑白的,非常难看。
这是因为我们的editor没有绑定content type。解决方法:需要实现org.eclipse.core.contenttype.contentTypes扩展点,然后绑定到editor上:
<extension
point="org.eclipse.ui.editors">
<editor
class="com.test.MyMultiEditorPart"
id="com.test.MyMultiEditorPart"
name="%editor.name.1"
icon="resources/icons/runner.gif"
extensions="arl">
<contentTypeBinding
contentTypeId="com.test.MyMultiEditorPart.contenttype.arl"/>
</editor>
</extension>

<extension
point="org.eclipse.core.contenttype.contentTypes">
<content-type
id="com.test.MyMultiEditorPart.contenttype.arl"
name="%content-type.name.1"
base-type="org.eclipse.core.runtime.xml"
file-extensions="arl">
<property name="charset" default="UTF-8"/>
</content-type>
</extension>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值