扩展点:
org.eclipse.ui.commands
org.eclipse.ui.handlers(command的具体行为)
org.eclipse.ui.commandImages(comand的图片)
扩展点org.eclipse.ui.menus用来对菜单进行扩展,可以对主菜单,工具栏,上下文菜单进行扩展。
示例代码如下:
point ="org.eclipse.ui.menus" >
< menuContribution
allPopups ="false"
locationURI ="menu:org.eclipse.ui.main.menu?after=additions" >
< command
commandId ="com.xxxx.test.command1"
style ="push" >
</ command >
</ menuContribution >
</ extension >
其中locationURI属性指定菜单扩展的位置,上述代码是对主菜单进行扩展,如果要对工具栏和上下文菜单进行扩展,书写格式如下:
toolbar:org.eclipse.ui.main.toolbar?after=additions
popup:org.eclipse.ui.popup.any?after=additions(上下文菜单在任何位置出现)
popup:org.eclipse.ui.views.ProblemView?after=additions(上下文菜单在问题视图中出现)
commandId属性指定该menu对应的command,一个menu可以对应多个command。
command可以通过扩展点org.eclipse.ui.commands扩展,示例代码如下:
point ="org.eclipse.ui.commands" >
< category
id ="com.xxxx.test.category1"
name ="MenuTest" >
</ category >
< command
categoryId ="=" com.xxxx.test.category1"
id ="com.xxxx.test.command1"
name ="CommandA" >
</ command >
</ extension >
至于Command具体要做什么,需要通过扩展点org.eclipse.ui.handlers来指定,示例代码如下:
point ="org.eclipse.ui.handlers" >
< handler
class ="com.xxxx.test.SampleHandler"
commandId ="com.xxxx.test.command1" >
</ handler >
</ extension >
还有扩展点org.eclipse.ui.commandImages,可以指定Command对应的图标。
< extension
point ="org.eclipse.ui.commandImages" >
< image
commandId ="com.xxxx.test.command1"
icon ="icons/sample.gif" >
</ image >
</ extension >