Eclipse rcp model扩展

阅读数:78 评论数:0

跳转到新版页面

分类

python/Java

正文

每个plug-ins可以通过下面方式作用于application model:

(1)static contributions

通过文件,这些扩展称为fragments或model fragments。

(2)Dynamic contributions

通过Java类,这些扩展称为processors或model processors。

这些model contributions一定要通过org.eclipse.e4.workbench.model扩展点进行注册,并在应用程序启动时被读取和加载。

运行时application model的改变会被写回到model中,如果Eclipse application关闭了,这些改变会被记录和保存在workbench.xmi文件中,这个文件位于.metadata/.plugins/org.eclipse.e4.workbench目录下。如果某些model elements在关闭时不想被持久化,可以在设置其persistedState状态。

Model fragments

一个model fragment就是一个以.e4xmi后缀的文件,它会指添加的model elements和要扩展的model elements。

在fragment中,Featurename指向你想扩展的model element。下面的列举了一些Featurename值。

要扩展的目标 Featurename Element Id
Command to the application commands ID of your application
Handler to the application handlers ID of your application

New MenuItem/

HandledMenuItem to existing menu

children ID of the menu
New memu to the main menu of the window children ID of your main menu
New Part to existing PartStack children ID of your PartStack

 

1、指定要扩展的model elements:

(1)扩展element ID

(2)使用XPATH表达式,下面给出一些XPATH的例子。

xpath://mainMenu 主菜单
xpath://mainMenu/children 主菜单的所有孩子
xpath://mainMenu/*[1] 主菜单的第一个孩子,一般是menu:File menu
xpath://mainMenu/[@[local-name()='type' and .='menu:Menu']] 主菜单的第一个孩子,相对于上一个,指定的孩子类型为menu:Menu
xpath://trimBars[@isde="Bottom"] 底部的trimbar
xpath://trimBars[not(@side)] 顶部的trimbar
xpath://children[@*[local-name='type' and .='basic:Part']] MPart
xpath://children[@*[local-name()='type' and .='basic:Part']][./tags='Editor'] 一个Editor标签的MPart

 

2、在fragment中指定新model element的位置(通过Position in List属性)

(1)first

element在list的头部。

(2)index:theIndex

指定位置为theIndex值,如index:0

(3)before:theOtherElementsId

放在指定元素的前面。

(4)after:theOtherElementsId

放在指定无素的后面。

plug-ins中独立的fragments以MANIFEST.MF文件指定的顺序处理,所以first或index可能得不到想要的效果。

 

Model prcessors

一个processor可以通过代码来扩展model,这可以在应用起动后动态的创建model elements。

 




相关推荐

Eclipse RCP是Rich Client Platform,即富客户平台,使用者可以使用Java来创建桌面程序,这些应用程序能够得到Eclipse的底层支持。 1、下载</p

运行时,Eclipse 应用的结构是通过一个application model来描述的。这个application model包含了应用中独立的元素和它们的结构关系。 每个mode

1、@javax.inject.Inject 定义在JSR330中 ,可以写在字段、构建函数或方法上,Eclipse 框架试图把相关的对象注入到字段或实例的参数上。

一个Eclipse应用在启动过程时会创建一个实现IEclipseContext接口的对象,这个对象称为Eclipse context。 这个context和Map数据结构类似,但和

1、@PostConstruct 当一个类的构造函数执行,字段和方法都注入后执行。 2、@PreDestroy 类被destroyed前执行,可以用来清

Eclipse application model允许你指定command和handlers。 command和handlers model element的使用是可选的,你可以使

一个Eclipse application的配置包括icons、splash screen和plug-ins。 一个product总是指向一个application class,对

一个feature可以理解为一个逻辑单元,描述了一组plug-in和其它features。它也有name、version number和license information。 f

SWT全称是Standard Widget Toolkit。 Display和Shell Display和Shell类是SWT应用的主要组件,org.eclips

JFace是基于SWT的一组plug-ins,但是JFace不会隐藏SWT的API。JFace提供了viewers框架,它可以简化数据模型和可视化显示的匹配。 JFace也提供了帮