给RCP系统添加全局快捷键
来源:互联网 发布:unix高级编程pdf网盘 编辑:程序博客网 时间:2024/04/30 06:32
文章转自:http://www.blogjava.net/chengang/archive/2006/04/28/43873.html
一个RCP系统,给它添加一个象Eclipse中Ctrl+Shift+O一样的全局快捷键,怎么加?
参考了RCP的Email项目示例,给我RCP项目中MonitorAction(显示一个监视器的命令)添加一个快捷键Ctrl+1。简单把添加的过程概述如下:
1、首先在plugin.xml中添加两个扩展点如下
说明:
。org.eclipse.ui.file.exit是另一个退出系统命令,是复用了Eclipse本身的那个,它和本例无关。
。commandId要求唯一
。cmmands扩展点的category是一个组,估计不要也可以,最后还是加上吧。
。bindings扩展点中的commandId对应于cmmands扩展点中的id
2、创建一个类,专门保存所有commandId
3、创建Action类,在构造函数里用两个方法注册一下
4、在ApplicationActionBarAdvisor的makeActions方法,给monitorAction对象加上这样一句
注意:如果你没有在plugin.xml和makeActions做上面讲过的设置,加上这一句将可能导致
你的RCP系统无法启动。
一个RCP系统,给它添加一个象Eclipse中Ctrl+Shift+O一样的全局快捷键,怎么加?
参考了RCP的Email项目示例,给我RCP项目中MonitorAction(显示一个监视器的命令)添加一个快捷键Ctrl+1。简单把添加的过程概述如下:
1、首先在plugin.xml中添加两个扩展点如下
<extension
point="org.eclipse.ui.bindings">
<key
commandId="org.eclipse.ui.file.exit"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="CTRL+X"/>
<key
commandId="adminconsole.monitor"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="CTRL+1"/>
</extension>
<extension
point="org.eclipse.ui.commands">
<category
id="adminconsole.perspective"
name="Perspective"/>
<command
categoryId="adminconsole.perspective"
id="adminconsole.monitor"
name="Open Monitor Perspective"/>
</extension>
point="org.eclipse.ui.bindings">
<key
commandId="org.eclipse.ui.file.exit"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="CTRL+X"/>
<key
commandId="adminconsole.monitor"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="CTRL+1"/>
</extension>
<extension
point="org.eclipse.ui.commands">
<category
id="adminconsole.perspective"
name="Perspective"/>
<command
categoryId="adminconsole.perspective"
id="adminconsole.monitor"
name="Open Monitor Perspective"/>
</extension>
说明:
。org.eclipse.ui.file.exit是另一个退出系统命令,是复用了Eclipse本身的那个,它和本例无关。
。commandId要求唯一
。cmmands扩展点的category是一个组,估计不要也可以,最后还是加上吧。
。bindings扩展点中的commandId对应于cmmands扩展点中的id
2、创建一个类,专门保存所有commandId
public interface ICommandIds {
public static final String CMD_MONITOR = "adminconsole.monitor";
}
public static final String CMD_MONITOR = "adminconsole.monitor";
}
3、创建Action类,在构造函数里用两个方法注册一下
private static class MonitorAction extends Action {
public MonitorAction() {
setText("监视");
// The id is used to refer to the action in a menu or toolbar
setId(ICommandIds.CMD_MONITOR);
// Associate the action with a pre-defined command, to allow key bindings.
setActionDefinitionId(ICommandIds.CMD_MONITOR);
}
}
public MonitorAction() {
setText("监视");
// The id is used to refer to the action in a menu or toolbar
setId(ICommandIds.CMD_MONITOR);
// Associate the action with a pre-defined command, to allow key bindings.
setActionDefinitionId(ICommandIds.CMD_MONITOR);
}
}
4、在ApplicationActionBarAdvisor的makeActions方法,给monitorAction对象加上这样一句
register(monitorAction);
注意:如果你没有在plugin.xml和makeActions做上面讲过的设置,加上这一句将可能导致
你的RCP系统无法启动。
- 给RCP系统添加全局快捷键
- 给RCP系统添加全局快捷键
- 给RCP系统添加全局快捷键
- 给RCP系统添加全局快捷键
- 给rcp系统添加全局快捷键
- 给RCP系统添加全局快捷键
- Android系统添加全局快捷键的方法
- Android系统添加全局快捷键的方法 .
- rcp添加帮助系统
- 为RCP添加帮助系统
- 为RCP添加帮助系统
- 为RCP添加帮助系统
- 为RCP添加帮助系统
- 为RCP添加帮助系统
- Eclipse Rcp中替换Eclipse默认全局快捷键
- 给菜单添加快捷键
- C# 注册系统全局快捷键
- 添加完整的Eclipse RCP帮助系统
- 话说勇敢
- 简明AT指令
- 又见银杏
- 纯做技术是自娱自乐 抛开技术做技术才是出路【转】
- J2EE面试题
- 给RCP系统添加全局快捷键
- session保存对象的取出问题
- Ajax 和 XML: 将 Ajax 用于聊天-使用 Ajax 和 PHP 创建聊天应用程序
- Linux那些事儿之我是Block层(4)浓缩就是精华?(一)
- Access 查询同一张表中某个字段含有重复项的记录
- Oracle常用数据字典
- 直击现场—名门问题锁质量追踪
- IQ之外还有多少个Q? ——6个Q提升你的个人品牌竞争力
- 用 Flickr API 扩展 Project Zero 的脚本平台