




已阅读5页,还剩9页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
附录 (英文翻译)Rich Client Tutorial Part 1The Rich Client Platform (RCP) is an exciting new way to build Java applications that can compete with native applications on any platform. This tutorial is designed to get you started building RCP applications quickly. It has been updated for Eclipse 3.1.2By Ed Burnette, SASJuly 28, 2004Updated for 3.1.2: February 6, 2006 IntroductionTry this experiment: Show Eclipse to some friends or co-workers who havent seen it before and ask them to guess what language it is written in. Chances are, theyll guess VB, C+, or C#, because those languages are used most often for high quality client side applications. Then watch the look on their faces when you tell them it was created in Java, especially if they are Java programmers.Because of its unique open source license, you can use the technologies that went into Eclipse to create your own commercial quality programs. Before version 3.0, this was possible but difficult, especially when you wanted to heavily customize the menus, layouts, and other user interface elements. That was because the IDE-ness of Eclipse was hard-wired into it. Version 3.0 introduced the Rich Client Platform (RCP), which is basically a refactoring of the fundamental parts of Eclipses UI, allowing it to be used for non-IDE applications. Version 3.1 updated RCP with new capabilities, and, most importantly, new tooling support to make it easier to create than before.If you want to cut to the chase and look at the code for this part you can find it in the accompanying zip file. Otherwise, lets take a look at how to construct an RCP application.Getting startedRCP applications are based on the familiar Eclipse plug-in architecture, (if its not familiar to you, see the references section). Therefore, youll need to create a plug-in to be your main program. Eclipses Plug-in Development Environment (PDE) provides a number of wizards and editors that take some of the drudgery out of the process. PDE is included with the Eclipse SDK download so that is the package you should be using. Here are the steps you should follow to get started.First, bring up Eclipse and select File New Project, then expand Plug-in Development and double-click Plug-in Project to bring up the Plug-in Project wizard. On the subsequent pages, enter a Project name such as org.eclipse.ui.tutorials.rcp.part1, indicate you want a Java project, select the version of Eclipse youre targeting (at least 3.1), and enable the option to Create an OSGi bundle manifest. Then click Next .Beginning in Eclipse 3.1 you will get best results by using the OSGi bundle manifest. In contrast to previous versions, this is now the default.In the next page of the Wizard you can change the Plug-in ID and other parameters. Of particular importance is the question, Would you like to create a rich client application?. Select Yes. The generated plug-in class is optional but for this example just leave all the other options at their default values. Click Next to continue.If you get a dialog asking if Eclipse can switch to the Plug-in Development Perspective click Remember my decision and select Yes (this is optional).Starting with Eclipse 3.1, several templates have been provided to make creating an RCP application a breeze. Well use the simplest one available and see how it works. Make sure the option to Create a plug-in using one of the templates is enabled, then select the Hello RCP template. This is RCPs equivalent of Hello, world. Click Finish to accept all the defaults and generate the project (see Figure 1). Eclipse will open the Plug-in Manifest Editor. The Plug-in Manifest editor puts a friendly face on the various configuration files that control your RCP application.Figure 1. The Hello World RCP project was created by a PDE wizard.Taking it for a spinTrying out RCP applications used to be somewhat tedious. You had to create a custom launch configuration, enter the right application name, and tweak the plug-ins that were included. Thankfully the PDE keeps track of all this now. All you have to do is click on the Launch an Eclipse Application button in the Plug-in Manifest editors Overview page. You should see a bare-bones Workbench start up (see Figure 2).Figure 2. By using the templates you can be up and running an RCP application in minutes.Making it a productIn Eclipse terms a product is everything that goes with your application, including all the other plug-ins it depends on, a command to run the application (called the native launcher), and any branding (icons, etc.) that make your application distinctive. Although as weve just seen you can run a RCP application without defining a product, having one makes it a whole lot easier to run the application outside of Eclipse. This is one of the major innovations that Eclipse 3.1 brought to RCP development.Some of the more complicated RCP templates already come with a product defined, but the Hello RCP template does not so well have to make one.In order to create a product, the easiest way is to add a product configuration file to the project. Right click on the plug-in project and select New Product Configuration. Then enter a file name for this new configuration file, such as duct. Leave the other options at their default values. Then click Finish. The Product Configuration editor will open. This editor lets you control exactly what makes up your product including all its plug-ins and branding elements.In the Overview page, select the New. button to create a new product extension. Type in or browse to the defining plug-in (org.eclipse.ui.tutorials.rcp.part1). Enter a Product ID such as product, and for the Product Application select org.eclipse.ui.tutorials.rcp.part1.application. Click Finish to define the product. Back in the Overview page, type in a new Product Name, for example RCP Tutorial 1.In Eclipse 3.1.0 if you create the product before filling in the Product Name you may see an error appear in the Problems view. The error will go away when you Synchronize (see below). This is a known bug that is fixed in newer versions. Always use the latest available maintenance release for the version of Eclipse youre targeting!Now select the Configuration tab and click Add. Select the plug-in you just created (org.eclipse.ui.tutorials.rcp.part1) and then click on Add Required Plug-ins. Then go back to the Overview page and press Ctrl+S or File Save to save your work.If your application needs to reference plug-ins that cannot be determined until run time (for example the tomcat plug-in), then add them manually in the Configuration tab.At this point you should test out the product to make sure it runs correctly. In the Testing section of the Overview page, click on Synchronize then click on Launch the product. If all goes well, the application should start up just like before.Plug-ins vs. featuresOn the Overview page you may have noticed an option that says the product configuration is based on either plug-ins or features. The simplest kind of configuration is one based on plug-ins, so thats what this tutorial uses. If your product needs automatic update or Java Web Start support, then eventually you should convert it to use features. But take my advice and get it working without them first.Running it outside of EclipseThe whole point of all this is to be able to deploy and run stand-alone applications without the user having to know anything about the Java and Eclipse code being used under the covers. For a real application you may want to provide a self-contained executable generated by an install program like InstallShield or NSIS. Thats really beyond the scope of this article though, so well do something simpler.The Eclipse plug-in loader expects things to be in a certain layout so well need to create a simplified version of the Eclipse install directory. This directory has to contain the native launcher program, config files, and all the plug-ins required by the product. Thankfully, weve given the PDE enough information that it can put all this together for us now.In the Exporting section of the Product Configuration editor, click the link to Use the Eclipse Product export wizard. Set the root directory to something like RcpTutorial1. Then select the option to deploy into a Directory, and enter a directory path to a temporary (scratch) area such as C:Deploy. Check the option to Include source code if youre building an open source project. Press Finish to build and export the program.The compiler options for source and class compatibility in the Eclipse Product export wizard will override any options you have specified on your project or global preferences. As part of the Export process, the plug-in is code is recompiled by an Ant script using these options.The application is now ready to run outside Eclipse. When youre done you should have a structure that looks like this in your deployment directory: RcpTutorial1 | .eclipseproduct | eclipse.exe | startup.jar +- configuration | config.ini +- plugins mands_3.1.0.jar org.eclipse.core.expressions_3.1.0.jar org.eclipse.core.runtime_3.1.2.jar org.eclipse.help_3.1.0.jar org.eclipse.jface_3.1.1.jar org.eclipse.osgi_3.1.2.jar org.eclipse.swt.win32.win32.x86_3.1.2.jar org.eclipse.swt_3.1.0.jar org.eclipse.ui.tutorials.rcp.part1_1.0.0.jar org.eclipse.ui.workbench_3.1.2.jar org.eclipse.ui_3.1.2.jarNote that all the plug-ins are deployed as jar files. This is the recommended format starting in Eclipse 3.1. Among other things this saves disk space in the deployed application.Previous versions of this tutorial recommended using a batch file or shell script to invoke your RCP program. It turns out this is a bad idea because you will not be able to fully brand your application later on. For example, you wont be able to add a splash screen. Besides, the export wizard does not support the batch file approach so just stick with the native launcher.Give it a try! Execute the native launcher (eclipse or eclipse.exe by default) outside Eclipse and watch the application come up. The name of the launcher is controlled by branding options in the product configuration.TroubleshootingError: Launching failed because the org.eclipse.osgi plug-in is not included. You can get this error when testing the product if youve forgotten to list the plug-ins that make up the product. In the Product Configuration editor, select the Configuration tab, and add all your plug-ins plus all the ones they require as instructed above. Compatibility and migrationIf you are migrating a plug-in from version 2.1 to version 3.1 there are number of issues covered in the on-line documentation that you need to be aware of. If youre making the smaller step from 3.0 to 3.1, the number of differences is much smaller. See the References section for more information.One word of advice: be careful not to duplicate any information in both plug-in.xml and MANIFEST.MF. Typically this would not occur unless you are converting an older plug-in that did not use MANIFEST.MF into one that does, and even then only if you are editing the files by hand instead of going through the PDE.ConclusionIn part 1 of this tutorial, we looked at what is necessary to create a bare-bones Rich Client application. The next part will delve into the classes created by the wizards such as the WorkbenchAdvisor class. All the sample code for this part may be found in the accompanying zip file.ReferencesRCP Tutorial Part 2 RCP Tutorial Part 3 Eclipse Rich Client Platform RCP Browser example (project org.eclipse.ui.examples.rcp.browser) PDE Does Plug-ins How to Internationalize your Eclipse Plug-in Notes on the Eclipse Plug-in Architecture Plug-in Migration Guide: Migrating to 3.1 from 3.0 Plug-in Migration Guide: Migrating to 3.0 from 2.1译文:Rich Client教程第一部分The Rich Client Platform (RCP)是一种创建Java应用程序的令人兴奋的新方法,可以和任何平台下的自带应用程序进行竞争。这个教程会使你较快学会创建RCP应用程序,已更新到Eclipse 3.1.2版本作者: Ed Burnette, SASJuly 28, 2004更新到3.1.2: February 6, 2006介绍试试这样的试验:展示Eclipse给一些以前从来没有看见过它的朋友或同事,并让他们猜测一下它是用什么语言编写的。很大可能,他们会猜VB, C+, or C#,因为那些语言通常用于优质客户端应用程序。告诉他们这是用Java编制的,看看他们的表情,尤其他们是java程序员的话。因为它独一无二的开放源码许可的缘故,你可以使用Eclipse生成你自己的商用的优质程序。在3.0以前的版本,这样是可能的但是非常的麻烦,特别当你想要着重个性化设计菜单,编排,以及其他的用户接口部分。主要是由于Eclipse 的“集成电路设备”固化。3.0版本引入了the Rich Client Platform (RCP),主要基于Eclipse的用户界面基本部分进行了重新分解。3.1版本对RCP进行了一些新特性的更新,并且最重要的是,通过新工具的支持使它比以前更加容易创建。如果你想直接跳到重点,看这部分的代码你可以在accompanying zip file.里找到。否则的话,让我们看看怎样构建一个RCP。 开始RCP应用程序是基于熟悉的Eclipse插件结构,(如果你对这部分不熟悉的话,请看参考书目部分)。因此,你将需要创建一个插件程序成为你的主程序。Eclipse的插件发展环境(PDE)提供大量的向导和编辑器,负担了创建中的一些苦工。PDE包含在了你将使用的Eclipse SDK下载包里。现在跟着一下步骤开始。首先,打开Eclipse,选择File New Project,然后展开Plug-in Development,双击Plug-in Project来打开Plug-in Project 向导。在接下来的页面上,输入一个项目的名字,例如org.eclipse.ui.tutorials.rcp.part1,说明你想要一个Java 项目,选择你需要的Eclipse版本,并且勾选Create an OSGi bundle manifest选项。然后单击Next插图一. PDE向导创建的The Hello World RCP 项目换一个角度理解试用RCP应用程序通常有些单调乏味。你不得不生成一个定制的首次配置,输入正确的应用程序名称,并且管理调整所有包含的插件。非常感激PDE现在保存所有这些记录。你全部需要做的只是单击Manifest编辑器总览页上的Eclipse 应用程序按钮。你将看到一个简单的工作台页面跳出来(见插图二)。插图二. 使用模板,你可以在几分钟之内创建运行一个RCP应用程序创建一个产品对于Eclipse来说,一个产品是你的应用程序及所伴随的所有相关设置,包括它依靠的所有其他插件,用来运行程序的命令(称为自带的发射台),和一些使你的产品与众不同的商标(标记,等等)。虽然我们只在意你可以不需要定义一个产品来运行RCP应用程序,使不依赖Eclipse而运行一个应用程序更加轻松简单。引入RCP开发这是Eclipse 3.1版本的主要创新。一些更加复杂的RCP模板已经和产品一起定义了,但是Hello RCP 模板没有带,所以我们将需要定义一个。为了创建一个产品,最简单的方法是给项目增加一个产品配置文件,在plug-in项目上右键单击,选择New Product Configuration。接下来,给这个这个新配置文件输入一个文件名,例如duct。保留余下的选择和默认值一致。然后单击Finish。 产品配置编辑器将会打开。这个编辑器允许你严密的控制构成你产品的所有plug-ins和商标元素在总览页面,选择New. 按钮来创建一个新的产品扩展名。输入或者使用浏览方式找到定义的plug-in(org.eclipse.ui.tutorials.rcp.part1)。输入一个产品ID, 例如product,对应的产品应用程序选择org.eclipse.ui.tutorials.rcp.part1.application.。单击Finish 来完成定义产品。回到总览页面,输入一个新的产品名称,比如RCP Tutorial 1。在Eclipse 3.1.0版本,如果你在填入产品名称之前创建一个产品,你可能会看见一个出错信息出现在问题视窗。当你同步的时候,出错信息将会消失(见后面)。这是一个已知的缺陷,在后续版本作了修正。总是使用最新修正可用的Eclipse版本现在选择配置标签,并且单击Add,选择你前面所创建的插件程序(org.eclipse.ui.tutorials.rcp.part1),然后单击Add Required Plug-ins,回到总览页面,按住Ctrl+S,或者选择File Save来保存你的工作。如果你的应用程序需要涉及的plug-ins直到运行的时候才能决定(例如:tomcat plug-in),那就在配置表标签内手动增加。到这个阶段,你应该测试产品确认它运行正常。在总览页面的测试部分,单击同步,然后单击运行产品。如果一切顺利,应用程序窗口应该像先前一样跳出来。依赖插件还是依赖特性在总览页面,你可能注意到一个选项关于:产品的配置是基于插件或特性两者任何一个。这种最简单的配置是一种基于插件,这个教程所用的。如果你的产品需要自动升级或java网站的初始支持,那么最终你需要将它转换成特性。但是请接受我的建议,先在不使用特性情况下使它工作在Eclipse环境外运行最重要的观点是:配置和运行一个独立的应用程序,不需要用户知道任何封装起来的Java 和 Eclipse代码。对于一个真正的应用程序,你可能想要提供通过安装程序例如InstallShield 或者NSIS一个完整执行包。这个远远超过了这篇文章的范围,因此我们只作简单介绍。Eclipse插件导入装置期望事件按某种规划执行,因此我们需要创建一个简单版本的Eclipse 安装目录。这个目录必须包含自带的启动程序,设置文件,和产品需要的全部插件。幸好,我们给予PDE足够的信息,现在它可以为我们将这些组织起来。在产品配置编辑器的输出部分,单击使用Eclipse 输出向导的连接。设定根目录类似RcpTutorial1。然后选择展开目录的选项,输入一个目录路径到一个临时(草稿)区域比如C:Deploy 。如果你建立了一个开放源码项目,勾选包含源代码选项。按Finish 来建立和输出这个程序。在Eclipse产品输出向导中的源码和类兼容性编辑器选项可能会无视你在你的项目中特别指定的
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 【正版授权】 ISO 24631-3:2025 EN Radiofrequency identification of animals - Part 3: Evaluation of performance of RFID transponders conforming with ISO 11784 and ISO 11785
- 【正版授权】 ISO 11237:2025 EN Rubber hoses and hose assemblies - Compact wire-braid-reinforced hydraulic types for oil-based or water-based fluids - Specification
- 【正版授权】 IEC 61300-2-5:2022/AMD1:2025 EN-FR Amendment 1 - Fibre optic interconnecting devices and passive components - Basic test and measurement procedures - Part 2-5: Tests - Torsi
- 【正版授权】 IEC 60300-3-10:2025 EN-FR Dependability management - Part 3-10: Application guide - Maintainability and maintenance
- 北汽越野安全知识培训课件
- 校园火灾逃亡安全知识培训课件
- 校园消防知识培训课件标语
- 校园消防安全知识培训课件
- 安全饮水面试题及答案
- 更换轴承考试试题及答案
- 2025年教育综合理论知识试题及答案
- 普速《铁路技术管理规程》普速铁路部分
- 双减新政下 如何优化小学数学的作业设计专题讲座ppt
- 绿色建筑施工专项方案
- 法兰与垫片的基础知识
- 急性呼吸窘迫综合征护理
- GA 576-2018防尾随联动互锁安全门通用技术条件
- 渠道维护工试题
- 管道安装组对检查记录
- 初中生简历模板
- 哈尔滨市城市规划管理技术规定
评论
0/150
提交评论