读书人

Eclipse rcp/rap 开发经验总结(13) -R

发布时间: 2012-09-11 10:49:03 作者: rapoo

Eclipse rcp/rap 开发经验总结(13) -Rap/Rcp保存按钮处理方式

在做项目的过程中,处理编辑区的保存机制的时候。发现,同样是扩展eclipse 自带的保存和全部保存按钮时 ? ? ???????? 候,rcp 工程下,保存按钮可以正常的灰显和可用,但是rap 的按钮就是始终呈现灰显的状态,无论编辑区是否有变化。为了解决这个问题,经过研究在rap 上做了以下处理,问题得以解决。

在项目中保存按钮和全部保存按钮是通过扩展点的方式加载的,而且这个扩展点是eclipse 自身带有的扩展点,可以直接调用,并且调用这个保存扩展点,可以直接拥有和eclipse 编辑区类似的功能操作

扩展点的添加方式:

1 、保存的commandId 直接扩展:org.eclipse.ui.file.save

2 、全部保存的commandId 扩展:org.eclipse.ui.file.saveAll

这样保存和全部保存添加上了。

public class ApplicationActionBarAdvisor extends ActionBarAdvisor { public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { super(configurer); } protected void makeActions(IWorkbenchWindow window) { } protected void fillMenuBar(IMenuManager menuBar) { }}

?

?

/** *  * 工具按钮等相关功能注册 *  */public class ApplicationActionBarAdvisor extends ActionBarAdvisor{    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer){        super(configurer);    }        /**     * 工具栏保存、全部保存按钮注册     */protected void makeActions(IWorkbenchWindow window) {    //保存、全部保存按钮的注册        register(ActionFactory.SAVE.create(window));        register(ActionFactory.SAVE_ALL.create(window));        //历史记录回退、重做按钮的注册。        register(ActionFactory.UNDO.create(window));        register(ActionFactory.REDO.create(window));    }        protected void fillMenuBar(IMenuManager menuBar) {    }}

?

?

读书人网 >Eclipse开发

热点推荐