本文主要介绍Eclipse 4 RCP Application中的:Model Objects和Features。
在Eclipse 框架启动的时候会通过.Application.e4.xmi配置文件自动解析一些Application model Objects。 下表主要展示在Eclipse中常见的一些重要的Model Objects:
Model Elements | Description |
---|---|
MApplication | Describes the application object. All other model elements are contained in this object. |
MAddon | A self-contained component typically without user interface. It can register for events in the application life cycle and handle these events. |
MWindow | Represents a window in your application. |
MTrimmedWindow | Similar to MWindow but it allows containing toolbars for the windows (via the TrimBars model elements). |
MPerspective | Represents a different layout of parts to be shown inside the window. Should be contained in a MPerspectiveStack. |
MPart | Represents the model element part, e.g., a view or an editor. |
MDirtyable | Property of MPart which can be injected. If set to true, this property informs the Eclipse platform that this Part contains unsaved data (is dirty). In a handler you can query this property to provide a save possibility. |
MPartDescriptor | MPartDescriptor is a template for new parts. A new part based on this part descriptor can be created and shown via the Eclipse framework. |
Snippets | Snippets can be used to pre-configure model parts which you want to create via your program. You can use the Eclipse framework to clone such a application model at runtime. |
使用eclipse 的创建feature project 和创建一个plugin project是一样的。一个feature project包含 features。一个 feature可以描述一系列的plugins 和 feature ,通常是将一系列相关的组件组合到一个feature中当做是一个逻辑单元。当然Feature和plug-in 一样,也有名称name,版本号version number,通常在license中指定这些信息。
如下为一个简单的feature.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="com.vogella.eclipse.featuretest.feature"
label="Feature" version="1.0.0.qualifier"
provider-name="vogella GmbH">
<description url="http://www.example.com/description">
[Enter Feature Description here.]
</description>
<license url="http://www.example.com/license">
[Enter License Description here.]
</license>
<plugin
id="com.vogella.eclipse.featuretest.feature"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>
File –> New –>Other –>Plug-in Development –> Feature Project
一个产品,可以是依赖于plugin或者feature的,这些设置可以通过product的Overview tab进行配置。
在product的编辑器界面的contents tab指定该产品由那些plugin或者feature组成的。
一个product不会自动执行依赖关系,若你将一个feature添加进产品,同时也想将其依赖添加进来,就可以点击required 按钮,进行添加。
eclipse提供了几种预定义的features, 比如,给Eclipse RCP application 定义的 org.eclipse.e4.rcp