Eclipse RCP Command的Handler设置不起作用?
来源:互联网 发布:淘宝排名越来越靠后 编辑:程序博客网 时间:2024/04/27 23:14
网上很多种教程教我们设置Command的Handler从而可以有效的控制Command的使用状态,比如只针对某种类型文件启用Command等。
但当我们按教程上一步步试用时,却看不到期望的效果,command总是一直出现,不能随着Handler的设置而变化。如以下的Handler:
<extension point="org.eclipse.ui.handlers">
<handler class="test.TestCommand" commandId="test.command ">
<activeWhen>
<iterate>
<adapt type="org.eclipse.core.resources.IResource">
<test property="org.eclipse.core.resources.name" value="*.java">
</test>
</adapt>
</iterate>
</activeWhen>
</handler>
理论上来说,它是只当我们选中java文件时,test.command命令才会起作用。但当我们测试运行时,command一直正常使用。
解决方法:将test.command的扩展处,将其defaultHandler内容删除。如下所示:
<extension point="org.eclipse.ui.commands">
<command id="test.command " name="Test">
</command>
</extension>
回过头来,我们可以理解到:如果此处定义 了defaultHandler,系统会将这个做为默认的Handler来处理,而不会执行到我们定义的Handler,因此从这里我们可以看出,sorg.eclipse.ui.handler实际上就是一层过滤器,当我们没有定义Command的defaultHandler时,会默认去寻找其它地方定义(org.eclipse.ui.handlers)里的内容,正因为这样,我们定义的这些规则也在这里起了作用。
刚接触RCP,遇到此问题,没能解决,此处文字记录下来。
转载请注明版权。
- Eclipse RCP Command的Handler设置不起作用?
- [Eclipse] The Eclipse RCP Command Framework
- rcp(插件开发)org.eclipse.core.commands.NotHandledException: There is no handler to execute for command
- RCP中的Plugin.properties不起作用的解决方法
- Eclipse RCP perspective 最大化设置
- Eclipse RCP中设置视图标题栏的弧线形外观
- 设置Eclipse RCP程序的外观和首选项
- 设置Eclipse RCP程序的外观和首选项
- RCP 中设置和Eclipse一样的流线型视图窗口
- RCP 中设置和Eclipse一样的流线型视图窗口
- 仿Extjs 蓝色风格的Eclipse RCP CSS 设置
- Eclipse的RCP
- eclipse rcp 插件快捷键设置 冲突解决方案
- Eclipse RCP开发设置透视图(Perspective)
- 从Eclipse RCP想到的
- eclipse rcp环境的搭建
- eclipse rcp 的各个配置文件
- eclipse调试时设置断点不起作用问题。
- 如何利用CSS+DIV 实现三列自适应高和宽的布局(不用javascript)
- 如何在MFC中添加消息响应
- C++对txt文件的读取和写入
- Hibernate属性查询简单讲述
- C语言 编写的一个简单的Server/Client
- Eclipse RCP Command的Handler设置不起作用?
- cramfs文件系统识别nand坏块
- A*寻路算法(译)
- ObjectOuputStream判断文件读取结束
- 为什么要集成分类器
- ballFrame
- 字节对齐详解
- NullPointerException
- awk命令的使用(一):简介