eclipse命令框架(一)
在eclipse中有两种方式添加菜单,上下文菜单,工具栏等,一种是IAction,另一种是command。犹豫IAction实现的时候UI跟业务是耦合在一起的,所以eclipse才推出command。
?
1.命令框架类图体系结构的概述:
?

?
?
?
2.创建一个简单完整的命令:
?
(1)扩展org.eclipse.ui.commands,此扩展点只是定义command而不实现其业务逻辑
?
?
ICommandService cmdService = (ICommandService) getSite().getService( ICommandService.class);Category lunch = cmdService .getCategory("z.ex.view.keybindings.category");if (!lunch.isDefined()) { lunch.define("Lunch", "Actions take at lunch time.");}Command eatTaco = cmdService .getCommand("z.ex.view.keybindings.eatTaco");if (!eatTaco.isDefined()) { eatTaco.define("Eat That Taco", "Go for the taco.", lunch);}??