rcp(插件开发)Command 传值的问题
来源:互联网 发布:windows.old是什么 编辑:程序博客网 时间:2024/06/03 19:57
有这样一个需求:如果想在command执行的时候携带一些信息,然后还想获取这些信息 这个如何实现呢?
一 传值部分(传递的是ExecutionEvent,通过ExecutionEvent携带的ApplicationContext传递对象,还可以传递别的类型如MAP)
//获取ICommandService
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite().getService(ICommandService.class);
//调用Command并传递对象
commandService.getCommand("CommandId").executeWithChecks(new ExecutionEvent(null, Collections.EMPTY_MAP, null, sendObject));
二 取值部分 这个是在command相关联的handler里取到这个ExecutionEvent,ExecutionEvent里携带相关传入的信息。
package command_test.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.jface.dialogs.MessageDialog;
/**
* Our sample handler extends AbstractHandler, an IHandler base class.
* @see org.eclipse.core.commands.IHandler
* @see org.eclipse.core.commands.AbstractHandler
*/
public class SampleHandler extends AbstractHandler {
/**
* The constructor.
*/
public SampleHandler() {
}
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
MessageDialog.openInformation(
window.getShell(),
"Command_Test",
"Hello, Eclipse world");
return null;
}
}
- rcp(插件开发)Command 传值的问题
- rcp 插件开发中使用 dom4j的问题
- rcp(插件开发)Eclipse下的Java反编译插件
- rcp(插件开发)popupMenus-弹出菜单分组问题
- rcp(插件开发)资源文件国际化问题-中文例子
- rcp(插件开发)国际化
- rcp(插件开发)Part already exists in page layout 老外提出的问题
- rcp(插件开发)RCP程序导出后中文乱码问题
- rcp(插件开发)新建自己的工程文件
- rcp(插件开发)建立自己的Library (classpathContainer)
- rcp(插件开发)屏蔽eclipse的菜单项
- rcp(插件开发)如何获取MenuBar上的菜单
- rcp(插件开发)Action的那点事情
- rcp(插件开发)资源存放的规则
- rcp(插件开发)程序发布到不同的平台
- rcp(插件开发)如何过滤多余的菜单项?
- rcp(插件开发) 如何查找自己定义的扩展点
- rcp(插件开发) 如何获取eclipse or rcp的安装目录
- maven 配置篇 之 settings.xml
- maven构建android项目后,通过eclipse集成工具右键命令行方式部署到模拟器上进行调试
- 网页加载google地图的代码
- jQuery验证控件jquery.validate.js使用说明+中文API
- 【C语言学习笔记】打印九九乘法表,要求只用一个变量(位运算)
- rcp(插件开发)Command 传值的问题
- Java数据库驱动链接大全
- 对于makefile传递参数的一些问题
- Android EditText默认不弹出软件键盘
- ios7彩信配置
- repo使用问题一则
- ubuntu 安装 JDK
- omap下移植usb wifi小结
- hdu1850+2176(尼姆博弈)