posts - 36, comments - 30, trackbacks - 0, articles - 3

          Eclipse中一些擴展點介紹二

          Posted on 2010-07-03 15:55 笑看人生 閱讀(2785) 評論(0)  編輯  收藏 所屬分類: Java插件開發
          擴展點:
          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>

          主站蜘蛛池模板: 都昌县| 修武县| 济阳县| 温州市| 中卫市| 张家川| 格尔木市| 宁津县| 满城县| 洛隆县| 武夷山市| 常宁市| 平阳县| 富宁县| 梁山县| 绿春县| 洛阳市| 会东县| 繁昌县| 益阳市| 盖州市| 衡南县| 湟源县| 阳原县| 宁波市| 浏阳市| 建水县| 平昌县| 灵武市| 博乐市| 宁城县| 灵石县| 卢龙县| 白河县| 黑水县| 德兴市| 镇江市| 疏勒县| 翁源县| 南通市| 沙田区|