kukooBlog

look to the master, follow the master, walk with the master, see through the master, become the master.

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  213 随笔 :: 0 文章 :: 285 评论 :: 0 Trackbacks

Eclipse 3.1M7中对RCP的支持更加完善,RCP团队为RCP程序的创建,配置,发布提供了非常精巧的办法。在这里,仅介绍3.1M7中创建RCP的4个步骤,基本上可以全部通过窗口操作来完成,而避免了直接编辑plug-in.xml和.product文件。

第一步: 创建包含RCP框架代码的plug-in

  1. “File > New > Project...”
  2. 选择“Plug-in Project”然后“Next >”
  3. 输入你的项目名称(Project name) (比如“MyRCPApp”) 然后 “Next >”
  4. 在下方的“Rich Client Application”中,“Would you like to create a rich client application?”选择“Yes”,然后“Next >”
  5. 在“Templates”中,选择“RCP application with a view”
  6. 点击“Finish”,plug-in的Overview编辑页面将会打开

你的RCP将拥有一个简单的Viewer,并且包含了Rich Client App的基础框架代码。在“*.rcp”包下面,你可以编辑生成的View.java文件,通过createPartcontrol()来放入SWT或者JFace的构件。选择“Run as > Eclipse Application”来测试你的RCP程序。你可以把运行时的配置保存起来:选择“Run...”,然后创建一个新的配置文件(比如命名为MyRCPApp),在Main页的“Run an application”中选择MyRCPApp.application。然后在Plug-in页中,选择“Choose plug-ins and fragments to launch from the list”,点击“Deselect all”清除所有的plug-in,然后选中MyRCPApp(1.0.0),点击“Add Required Plug-ins”添加必须的plug-ins。最后,你就可以Run了。

第二步:创建.product配置文件

  1. 在Package Explorer中选中MyRCPApp,鼠标右键选择“New > Product Configuration.”。这是3.1M5a中新增加的!
  2. 输入文件名,必须以.product结尾(比如MyRCPApp.product)。
  3. 在“Initialize the file content”部分, 选择 “Create a configuration file with basic settings”,这样创建了一个最小化的配置。
  4. 点击 “Finish”。

.product的 “Overview”页面将被打开,这个页面和plug-in.xml的编辑页面非常类似。

第三步: 配置你的RCP程序的.product

  1. 在.product文件的Overview页中
  2. 定义“Product ID:”,点击“New...” 
  3. 在“Product Definition”对话框中,选择“Defining Plug-in:”并且点“Browse...”来选择RCP程序的核心plug-in,比如MyRCPApp(1.0.0)
  4. 输入“Product ID:”,比如“myrcpapp_product_1”
  5. 在“Product Application”部分, 选择MyRCPApp.application
  6. 点击“Finish”
  7. 回到Overview页面,在Product Name中可以制定你的RCP程序在title bar上显示的程序名称,比如MyRCPApp。
  8. 点击“product configuration”的超链接,这会打开Configuration页面,允许你添加你的RCP程序需要用到的其他的plug-in。通过“Add”来添加你要的plug-in,比如加入MyRCPApp,然后选中MyRCPApp,点击“Add Required Plug-ins”,这将替你解决plug-in之间的依赖关系,你会看到所有必须的plug-in都被自动添加了
  9. 保存

回到Overview页面,你可以通过点击“Launch the product”来启动你的RCP程序。

第四步: 导出你的RCP程序

你已经创建了一个.product文件,并且对你的RCP做了基本的配置,并且测试过了,那么你就可以把你的RCP程序导出用于发布了。

  1. 在Overview页面的Exporting部分,点击“Synchronize”超级链接来同步.product和plug-in的配置
  2. 输入一个“Archive:”的名字,默认的输出文件是默认以.zip结尾的
  3. 点击“Export”超级链接。所有的plug-in,RCP的基础运行库(你所需要的一切)都会被打包在你命名的.zip文件中

你可也分发你的RCP了,解开.zip文件,运行其中的eclipse.exe,一切OK!

那么如何“branding”你的RCP呢?打开.product文件,并且打开“Branding”页面。你可以指定Launcher Name(比如MyRCPApp),这样,你的RCP就不是eclipse.exe而是MyRCPApp.exe了。你也可以指定Root Directory,这样,.zip文件将自动解压缩在你指定的目录下。你还可以指定RCP程序的图标。重新导出,你就有了带有你自己商标的RCP程序了。

还有一种分发方式是Java WebStart。你可以下载Ed Burnette放在SourceForge上的一个example,来看如何配置Java WebStart。

RCP的创建,配置和导出发布已经变得非常方便了。而RCP的核心,还是Eclipse的plug-in,你可以通过各种plug-in,来写自己的Perspective, Viewer,Editor来添加各种功能。


www.eclipse.org
SourceForge上的一个example

Email this store to a friend (send a short email with a subject to this story)
Subscribe to kukooBlog (subscribe kukooBlog's RSS feed)
Send me feedback on this story

Yourit Technorati cosmos
Mycat Eclipse

posted on 2005-05-27 11:02 kukooBlog 阅读(676) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: