解决Eclipse RCP开发中Run As菜单项只出现一次的问题
来源:互联网 发布:mysql myisam 事务 编辑:程序博客网 时间:2024/05/17 23:48
症状:
运行RCP application后,在Project Explorer里面右键某个项目,可以看到context menu里面有Run As这么个选项,可是当第二次右键同一个项目时,Run As却消失了,不管你有没有真正地Run这个application,Run As都只会在context menu中出现一次。
调查:
在org.eclipse.debug.ui这个插件的extension point中有这么一段逻辑
<extension point="org.eclipse.ui.popupMenus"> ... <objectContribution objectClass="java.lang.Object" id="org.eclipse.debug.ui.contextualLaunch.run"> <action label="%RunContextMenu.label" style="pulldown" class="org.eclipse.debug.internal.ui.actions.RunContextualLaunchAction" menubarPath="additions" enablesFor="+" id="org.eclipse.debug.ui.contextualLaunch.run.submenu"> </action> <enablement> <or> <and> <not><with variable="org.eclipse.core.runtime.Platform"> <test property="org.eclipse.core.runtime.bundleState" args="org.eclipse.debug.core" value="ACTIVE"/> </with></not> <adapt type="org.eclipse.core.resources.IResource"/> <and> <with variable="org.eclipse.core.runtime.Platform"> <test property="org.eclipse.core.runtime.bundleState" args="org.eclipse.debug.core" value="ACTIVE"/> </with> <test property="org.eclipse.debug.core.launchable" value="run"/> </and> </or> </enablement> </objectContribution> ...</extension>仔细分析这段逻辑,可以看出,org.eclipse.core.runtime.bundleState这个属性是否为ACTIVE,即这个plugin是否已经被load,会对Run As这个context menu是否enable有不同的影响。
在bundleState没有ACTIVE的情况下,只要是可适应(adaptable to)org.eclipse.core.resources.IResource的都会显示出来;在bundleState ACTIVE的情况下,会通过执行org.eclipse.debug.core.launchable这个测试属性来判断。org.eclipse.debug.core.launchable定义于org.eclipse.debug.core,在org.eclipse.debug.internal.core.LaunchablePropertyTester 中执行一个测试方法。这个方法会检测是否有 run 这个launch mode存在,并且选中的这个项目或者文件是否有org.eclipse.debug.ui.actions.ILaunchable这个adaptor。
解决方法:
把ILaunchable这个adaptor加到相应的文件或者项目中去
即,在plugin.xml中加上这么一段
<extension point="org.eclipse.core.runtime.adapters"> <factory class="org.eclipse.core.runtime.IAdaptable" adaptableType="org.eclipse.core.resources.IResource"> <adapter type="org.eclipse.debug.ui.actions.ILaunchable"/> </factory></extension>
- 解决Eclipse RCP开发中Run As菜单项只出现一次的问题
- Eclipse的 Run as 不出现Android Application的问题
- rcp(插件开发)屏蔽eclipse的菜单项
- android run as 出现 .. 的各种问题
- Android开发中解决动画只执行一次的方法
- 数组中只出现一次的数字
- 数组中只出现一次的数字
- 数组中只出现一次的数字
- 数组中只出现一次的数字
- 数组中只出现一次的数字
- 数组中只出现一次的数字
- 数组中只出现一次的数字
- 数组中只出现一次的数字
- 数组中只出现一次的数
- 数组中只出现一次的数字
- 数组中只出现一次的数字
- 数组中只出现一次的数
- 数组中只出现一次的数字
- 软件版本号
- ubuntu10.10硬盘空间不够了,扩容方法
- 一段非常经典的一分钟视频“李嘉诚劝读书
- Android开发好有爱。。刚才在小米论坛上找到了开发的入门教程。。假期有货了
- 三种东西永远不要放到数据库里
- 解决Eclipse RCP开发中Run As菜单项只出现一次的问题
- 2012.6.25
- keychain的使用
- MySql面试
- 用Java程序编写兔子繁殖题目
- 关于SharePoint打开PerformancePoint Services出错解决方法
- 说说大型高并发高负载网站的系统架构
- 报表重叠分组并置于同一列下
- 旋屏