首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

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

2012-06-27 
在多页编辑器中加入xml编辑功能?最近在做一个GEF多页编辑器,图形用xml格式保存。为了简单,在source标签页应

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

?

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

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

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

在实现过程中发现,如果设置编辑文件的扩展名为.xml是没有问题的,如果默认扩展名不是.xml,则显示的xml文档是黑白的,非常难看。?
这是因为我们的editor没有绑定content type。解决方法:需要实现org.eclipse.core.contenttype.contentTypes扩展点,然后绑定到editor上:?
Java代码??在多页编辑器中加入xml编者功能
  1. <extension??
  2. ?????????point="org.eclipse.ui.editors">??
  3. ??????<editor??
  4. ????????????class="com.test.MyMultiEditorPart"??
  5. ????????????id="com.test.MyMultiEditorPart"??
  6. ????????????name="%editor.name.1"??
  7. ????????????icon="resources/icons/runner.gif"??
  8. ????????????extensions="arl">??
  9. ????????????<contentTypeBinding??
  10. ???????????????contentTypeId="com.test.MyMultiEditorPart.contenttype.arl"/>??
  11. ??????</editor>??
  12. ???</extension>??
  13. ?????
  14. ????<extension??
  15. ????????point="org.eclipse.core.contenttype.contentTypes">??
  16. ????????<content-type???
  17. ????????????????id="com.test.MyMultiEditorPart.contenttype.arl"??
  18. ????????????????name="%content-type.name.1"??
  19. ????????????????base-type="org.eclipse.core.runtime.xml"??
  20. ????????????????file-extensions="arl">??
  21. ????????????<property?name="charset"?default="UTF-8"/>??
  22. ????????</content-type>??
  23. ????</extension>??
分享到:?在多页编辑器中加入xml编者功能?在多页编辑器中加入xml编者功能

热点排行