[Eclipse] The Eclipse RCP Command Framework

本文探讨了Eclipse RCP中UI扩展的问题,并介绍了Eclipse 3.3之后推出的命令模式来改进原有ActionContribution设计的不足之处,实现UI与逻辑的分离。

准备翻译  The Eclipse RCP Command Framework

 

概述:

    从一Eclipse 设计的一开始,就关注与扩展性。因此,几乎所有的用户界面都能被扩展。但是当Eclipse RCP出现以后,发现UI 的扩展不太好用。Eclipse 3.3 以后,推出了一套新的UI 扩展,来取代以前的扩展。

 

1 以前的Action Contribution  设计

    通过扩展点定义的Action 都继承JFace 的IAction 接口

    IAction 接口, 他抽象了用户的一个动作(Action) ,使动作和特殊的小部件分离,如菜单和工具栏中的按钮:

 

 

请注意这个类中耦合度:文本,图像,快捷键,动作(这里指run 方法) 都耦合在一起。这里UI 和逻辑没有分离,所有Eclipse 3.3 引入command 模式,实现分离。

 

我们在来看看这些扩展:

    org.eclipse.ui.actionSets: 为主菜单和主工具栏贡献UI。 Some abstraction from the implementation is possible by declaring a contributed action as retargetable. In this case parts can register local handlers via API.

    org.eclipse.ui.editorActions: This extension point also allows contributions to the main menu and tool bar which are bound to a particular editor type.

    org.eclipse.ui.actionSetPartAssociations: While the former extension point allows editor specific contributions to the main menu and tool bar this one provides a similar functionality for all parts including views: It controls the visibility of action sets depending whether a particular editor or part is active within the workbench window.

    org.eclipse.ui.viewActions: Each view may have a local tool bar and pull-down menu. This is the extension point to populate them for particular view types.

    org.eclipse.ui.popupMenus: For additions to context menus, either for specific views (viewerContribution) or for particular objects wherever they appear in the views (objectContribution).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值