1
通过例子学习 Eclipse RCP 开发
翻译:孙江湖
2009 年 10 月
2
ECLIPSE RCP
This article describes how to develop applications using the Eclipse Rich Client Platform (RCP)
architecture.
本文讲述如何利用 Eclipse RCP 架构来进行应用开发
The article covers among others the creating of RCP applications, using commands, views,
editors, dialogs and creating and deploying a Eclipse product.
本文涵盖了创建 RCP 应用的各个方面:使用命令、视图、编辑器、对话框及创建与部署 Eclipse
产品。
This article is based on Eclipse 3.5 (Eclipse Galileo).
本文基于 Eclipse 3.5 讲述(Eclipse Galileo)
简介
此文通过若干个例子介绍了使用 Eclipse 进行 RCP 应用开发的过程。
学习环境:
Eclipse 的不同版本中环境差异较大。本教程是利用 Eclipse SDK 3.5.0 编写的。为了保持一致,
请使用如下 Eclipse 的安装包(小版本也很重要):
Eclipse SDK:eclipse-SDK-3.5-win32.zip
Eclipse RCP:eclipse-rcp-galileo-win32.zip
代码说明:
本教程中的代码都经过译者的验证,但不保证百分之百正确。屏幕截图是实际运行时的效果。
注:
原文下载地址:http://www.vogella.de/articles/Eclipse/article.html。在翻译过程中译者对原
文中的有些部分进行了修改、纠正。
欢迎传播,敬请指正。
3
目 录
Eclipse RCP ........................................................................................................................................................................... 2
1. Eclipse RCP Eclipse 富客户端 ................................................................................................................. 6
1.1. Overview 概览 ..................................................................................................................................... 6
1.2. Eclipse RCP Architecture - Plugins, Extensions and Extension-Points Eclipse RCP
架构-插件、扩展与扩展点 ......................................................................................................................... 6
1.3. Main components of an Eclipse RCP application Eclipse RCP 应用的主要组件 ... 7
1.4. Application versus Product 应用与产品 ................................................................................... 8
1.5. Important files 重要文件 ................................................................................................................. 8
2. Installation 安装 .............................................................................................................................................. 10
3. Create your first RCP application 创建你的第一个 RCP 应用 .................................................... 12
3.1. Create a RCP application 创建 RCP 应用 ............................................................................... 12
3.2. Start your RCP application 启动你的 RCP 应用 .................................................................. 15
4. Startup process of an RCP application RCP 应用的启动过程 ..................................................... 17
5. Run configuration 运行配置 ..................................................................................................................... 18
5.1. Overview 概览 ..................................................................................................................................... 18
5.2. Check your runtime configuration 检查运行时配置 ........................................................ 19
5.3. Important Parameters 重要参数 ................................................................................................. 20
6. Commands 命令 ............................................................................................................................................... 22
6.1. Overview 概览 ..................................................................................................................................... 22
6.2. Defining commands 定义命令.................................................................................................... 22
6.3. Using commands in menus 在菜单中使用命令 .................................................................. 26
7. System Tray 系统托盘 ................................................................................................................................ 31
8. Views 视图 .......................................................................................................................................................... 36
8.1. Overview 概览 .................................................................................................................................. 36
4
8.2. Create a view 创建视图 ................................................................................................................... 36
8.3. Add the view to your perspective. 将视图添加到透视图 ............................................... 39
8.4. Result 结果 ............................................................................................................................................ 41
8.5. Add view to perspective via code 利用代码将视图添加到透视图中 ........................... 41
9. Working with Editors, View Interaction and Model Updates 使用编辑器、视图进行交
互及模型更新 .......................................................................................................................................................... 43
9.1. Overview 概览 .................................................................................................................................. 43
9.2. Create project 创建项目................................................................................................................ 43
9.3. Create and prepare the domain model 创建并准备域模型 ........................................... 44
9.4. Content and Label provider 内容与标签提供者 ................................................................. 48
9.5. Use the domain model in the view 在视图中使用域模型 ................................................. 51
9.6. Editor area 编辑区 .......................................................................................................................... 53
9.7. Editor Input 编辑器输入............................................................................................................... 54
9.8. Adding the editor 添加编辑器 .................................................................................................... 56
9.9. Creating a command for calling the editor 创建编辑器调用命令 ............................... 59
10. Dialog 对话框 ............................................................................................................................................... 64
10.1. Overview 概览 ................................................................................................................................ 64
10.2. Using standard dialogs 使用标准对话框............................................................................. 64
10.3. Selection 选择 ................................................................................................................................. 67
10.4. User defined dialogs 使用自定义对话框 ............................................................................. 69
11. Field Assist 字段助手 ................................................................................................................................ 74
12. Wizards 向导 ................................................................................................................................................ 76
12.1. Overview 概览 ................................................................................................................................ 76
12.2. Example 例子 .................................................................................................................................... 76
13. Adding a status line 添加状态行 .......................................................................................................... 84
5
13.1. Setup Status line 设置状态行 ..................................................................................................... 84
13.2. Shared Status Line 共享状态行 ............................................................................................... 85
14. Perspectives 透视图 .................................................................................................................................. 90
14.1. Adding a perspective to your application 为应用添加透视图 ...................................... 90
14.2. Select the perspective 选择透视图 ........................................................................................ 92
14.2.1. Select perspective via the toolbar / coolbar 通过工具条/快捷键选择
透视图 ..................................................................................................................................................... 92
14.2.2. Select perspective via the menu 通过菜单选择透视图 ................................. 94
15. Products and Branding 产品与商标 ................................................................................................... 95
15.1. Product Configuration 产品配置 ............................................................................................ 95
15.2. Create a project 创建项目 ......................................................................................................... 95
15.3. Create your product configuration 创建你的产品配置 ................................................ 95
15.4. Maintain the overview tab 概览页维护 ............................................................................. 96
15.5. Dependencies 依赖性 ............................................................................................................... 99
15.6. Launch your product 启动你的应用 .................................................................................. 100
15.7. Splash Screen 溅射屏幕 .......................................................................................................... 101
15.8. Branding your product 制作产品商标 .............................................................................. 102
15.9. Customizing the start icon and launcher arguments 定制开始图标与启动参数
.......................................................................................................................................................................... 103
15.10. Done 完成了! ......................................................................................................................... 104
16. Deploy your product 部署你的产品 ................................................................................................ 105
17. Tips and Tricks 提示与技巧 ................................................................................................................ 108
17.1. Save users layout 保存用户布局.......................................................................................... 108
17.2. Plugin ID in application 应用中的插件 ID ....................................................................... 108
17.3. Finding unused dependencies 查找无用的依赖 ........................................................... 109
18. Next steps 下一步 .................................................................................................................................... 110
- 1
- 2
前往页