Java 学习

坚持不懈,打通-->软件—控制—机械
posts - 5, comments - 3, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Rich Client Tutorial Part 1(翻译)

Posted on 2006-06-30 18:27 燕然 阅读(973) 评论(1)  编辑  收藏 所属分类: eclipse
Rich Client Tutorial是Eclipse官方网站的RCP开发指南。原文地址为: http://www.eclipse.org/articles/Article-RCP-1/tutorial1.html
第一次翻译,有错误,欢迎指正。

Rich Client Tutorial Part 1

The 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.2

富客户端平台( RCP )是一个令人兴奋的创建 java 应用程序的新方式,她可以与任何平台下的本地应用程序相媲美。这份指南目的在于让你快速的构建 rcp 应用程序。本指南已更新,适用于 Eclipse 3.1.2

Introduction

Try this experiment: Show Eclipse to some friends or co-workers who haven't seen it before and ask them to guess what language it is written in. Chances are, they'll 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 Eclipse's 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, let's take a look at how to construct an RCP application.

引言

尝试做这个实验:把 Eclipse 展示给你的那些以前没见过 Eclipse 的朋友或合作伙伴,让他们猜猜这是用何种语言编写的。很有可能,他们会说是 VB C++ 或者 C# ,因为这些语言经常被用来作为高质量客户端方面的应用程序。当你告诉他们是用 java 编写时,察看他们脸上的表情,尤其当他们是 java 程序员的话。

因为 Eclipse 是唯一 开放源代码许可的,你可以用 Eclipse 这个技术来创建你自己商业质量的程序。在 3.0 版本以前,这是可能的,但也是困难的,尤其当你想要订制菜单,多层和其他用户界面元素时。那是因为很难接触到 Eclipse IDE 核心。 3.0 版本的 Eclipse 引入了富客户端编程( RCP ),这基本上是 Eclipse UI 的重新构建,也就允许 Eclipse UI 被应用到非 Eclipse IDE 的应用程序中。 3.1 版本的 Eclipse 用新特性升级了 RCP ,最重要的是,新的工具使的创建 RCP 应用程序比以前更加容易。

如果你想要研究 Rich Client Tutorial Part 1 的代码,你可以到 accompanying zip file 下载。另外,让我们一步步来看看如何创建一个 RCP 应用程序。

Getting started

开始

RCP applications are based on the familiar Eclipse plug-in architecture, (if it's not familiar to you, see the references section). Therefore, you'll need to create a plug-in to be your main program. Eclipse's 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.

RCP 应用程序基于熟悉的 Eclipse 插件机制,(如果你不熟悉,请查看参考书目部分)。因此,你要创建一个插件来作为你的主程序。 Eclipse 的插件开发环境( PDE )提供了大量的控件和编辑器来使得开发过程脱离苦海。 PDE 包括在了 Eclipse SDK ,所以 PDE 开发包你可以直接使用。以下是开始开发的步骤:

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 you're targeting (at least 3.1), and enable the option to Create an OSGi bundle manifest. Then click Next >.

首先,启动 Eclipse ,选择File > New > Project接下来选中 Plug-in Development双击来打开插件工程向导。在弹出的页面中,键入工程名(例如: org.eclipse.ui.tutorials.rcp.part1),指明你要一个 java工程,选择你想创建适用的 Eclise的版本,并选中使用 OSGI包。接下来点击 Next>

note: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.

注: 通过使用 Eclipse 3.1 OSGI 包,你会获得很好的结果。与以前的版本相比, OSGi 现在是默认的了。

在下一页向导中,你可以更改插件的 ID 号和其他参数。尤其要关注一个问题:“你想要创建一个富客户端的应用程序吗?”,选择“是”。生成的插件类是可选的,但对于这个例子,一切其他的可选项都设为默认值。单击Next >到下一页

note: 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).

注:如果你得到一个对话框,询问 Eclipse 是否切换到插件开发透视图。这时单击记住我的选择并选择“是”(这是可选的)。

Starting with Eclipse 3.1, several templates have been provided to make creating an RCP application a breeze. We'll 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 RCP's 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.

Eclipse 3.1 开始,提供了几个模板使得创建 RCP 应用程序相当容易。我们使用最简单的一个模板来观察这是如何工作的。确保创建一个插件使用模板之一是允许的,接着选择“ Hello RCP ”模板。这是 RCP 应用程序中的“ Hello, world ”。选择“完成”来创建工程(见图一)。 Eclipse 将会打开插件编辑器。插件编辑器提供了友好的界面,拥有多样的配置文件来控制你的RCP应用程序。



Figure 1. The Hello World RCP project was created by a PDE wizard.

图一,PDE向导创建的Hello World工程

(未完,待续)


评论

# re: Rich Client Tutorial Part 1(翻译)  回复  更多评论   

2006-09-13 15:38 by ak_zct
这篇文章写得好!

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


网站导航: