Eclipse中一些扩展点介绍二

扩展点:

org.eclipse.ui.menus(确定菜单创建的区域)
org.eclipse.ui.commands
org.eclipse.ui.handlers(command的具体行为)
org.eclipse.ui.commandImages(comand的图片)


扩展点org.eclipse.ui.menus用来对菜单进行扩展,可以对主菜单,工具栏,上下文菜单进行扩展。

示例代码如下:

< extension
         
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扩展,示例代码如下:

< extension
         
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来指定,示例代码如下:

< extension
         
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 >

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值