准备翻译 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).
本文探讨了Eclipse RCP中UI扩展的问题,并介绍了Eclipse 3.3之后推出的命令模式来改进原有ActionContribution设计的不足之处,实现UI与逻辑的分离。

被折叠的 条评论
为什么被折叠?



