创建Eclipse Editor
来源:互联网 发布:ubuntu 16.04 selinux 编辑:程序博客网 时间:2024/06/05 13:56
原文链接:http://www.vogella.com/articles/EclipseEditors/article.html
配置要求:Eclipse 3.7 Indigo
Eclipse使用editor和view来处理数据。editor一般需要用户点击“save”来保存数据改动,而view一般直接执行改动。
在RCP系统中通常采用下列步骤来创建和使用editor:
- 在perspective中把editor区域设置为可见
- 创建IEditorInput类
- 定义一个“org.eclipse.ui.editors” extension point
- 创建editor类,这个类必须实现IEditorPart接口
IEditorInput是editor模型的轻量级展现,Eclipse会缓冲IEditorInput对象,因此这个对象应该相对较小。Eclipse根据IEditorInput中的equals()方法来判断对应的editor是否已经打开,以及是否需要打开一个新的editor(这个方法很重要)。
editor通过“org.eclipse.ui.editors” extension point定义,editor类必须实现IEditorPart接口,通常会继承EditorPart类。editor会通过init()方法获取IEditorSite和IEditorInput对象,必须调用setInput()和setSite()分别进行设置。init()方法在createPartControl()之前被调用,因此在创建UI的时候,IEditorInput就已经可以被用户使用了。
editor类中的setPartName()方法可以用来设置editor的title,override getTitleToolTip()可以设置tooltip。
editor类中的isDirty()方法可以用来告诉workbench editor的内容是否有改动,我们可以fire一个event来告诉workbench editor的dirty属性已经改动:
firePropertyChange(IEditorPart.PROP.DIRTY);我们可以通过当前活动页面来打开editor,显然我们需要editor的ID(来告诉Eclipse使用哪一个editor),以及一个EditorInput对象(告诉Eclipse的editor使用哪个model):
page.openEditor(new YourEditorInput(), ID_OF_THE_EDITOR);如果获取当前活动页面,有这么几种方法:
// If you are in a viewgetViewSite().getPage();// If you are in an commandHandlerUtil.getActiveWorkbenchWindow(event).getActivePage();// Somewhere elsePlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
原文中有一个详细的例子和源代码,有兴趣的可以实践一下。
- 创建Eclipse Editor
- Properties Editor for Eclipse
- visual editor for eclipse
- Eclipse Editor 深色theme
- 安装Eclipse Html Editor
- eclipse properties editor
- Eclipse Html Editor
- 安装Eclipse Html Editor
- 安装Eclipse Html Editor
- Eclipse Properties Editor
- Eclipse Java properties editor
- eclipse插件Properties Editor
- Eclipse配置 Properties Editor
- Eclipse HTML Editor
- 配置eclipse editor
- 安装Eclipse Html Editor
- eclipse properties editor 安装
- eclipse插件Properties Editor
- C#中调用C++写的DLL注意事项
- asp.net sitemappath站点地图
- uva-10010 - Where's Waldorf?
- 预处理
- Struts2学习笔记(十四) 输入校验(下)
- 创建Eclipse Editor
- jQuery插件AjaxFileUpload
- 淘宝店铺装修收藏链接代码
- 根据字典排序找到下一个由n个不同字符组成的序列
- CouchDB与Couchbase:区别何在,Membase又将如何?
- 明显是数据库的插件没有复制过去呀!(勿推荐)
- SQL Server编程系列(2):SMO常用对象的有关操作
- http://forum.csdn.net/PointForum/Forum/PointExchangeOK.aspx
- 关于中国劳工退中介费的政策规定---新美亚,sanmina,sci,中国劳工,新加坡中介,退中介费,