<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    子非魚

    BlogJava 首頁 新隨筆 聯系 聚合 管理
      21 Posts :: 0 Stories :: 1 Comments :: 0 Trackbacks
    轉自:http://lemon.javaeye.com/blog/51480
            http://m.tkk7.com/fhawk/archive/2007/01/16/28993.html
    利用IKeyBindingService接口為Action綁定快捷鍵:

    1、
    設置commands extension

       <extension
               
    point = "org.eclipse.ui.commands">
               
    <!-- activeKeyConfiguration項用來說明所綁定快捷鍵的初始設置 -->
               
    <activeKeyConfiguration value="org.eclipse.ui.defaultAcceleratorConfiguration"/>
               
    <!-- 如果快捷鍵設置有多套,可以添加多個類別 -->
               
    <category
                   
    name="intelliPlatform.Category1"
                   description
    ="Test description"
                   id
    ="intelliPlatform.Category1"/>
               
    <!-- 其中id為這個command的ID,相關的action通過這個ID標志找到這個command -->
               
    <command
                 
    name="intelliPlatform.command.DataSource"
                 category
    ="intelliPlatform.Category1"
                 description
    ="數據源配置"
                 id
    ="com.longtop.intelliplatform.ide.project.commands.DataSource"/>
            
    <!-- 具體的快捷鍵設置,其中command指定實際的coomand的ID -->
            
    <keyBinding
                 
    command="com.longtop.intelliplatform.ide.project.commands.DataSource"
                 configuration
    ="org.eclipse.ui.defaultAcceleratorConfiguration"
                 keySequence
    ="Ctrl+Shift+D"/>
       
    </extension>
     以上是設置了plugin.xml中command extension,并指定了keybinding,在keybinding中
     的keysequence中的字符串是設置的快捷鍵。 

    ------------

    在具體的Action配置中,只要在其屬性definitionId設置成command的ID即可,示例如下:
    <action
     
    label="Sample Action"
     icon
    ="icons/sample.gif"
     class
    ="cli.bacchus.portal.ui.actions.BacchusAction"
     tooltip
    ="Hello, Eclipse world"
     menubarPath
    ="sampleMenu/sampleGroup"
     toolbarPath
    ="sampleGroup"
     id
    ="bacchus.portal.ui.actions.BacchusAction"
     definitionId
    ="com.longtop.intelliplatform.ide.project.commands.datesource">
    </action>

    注意:當給相關的action設置完definitionID后,必須保證其中設置的command是有的,而且是正確的,否則有可能導致該action顯示不出來。
    更具體的信息請參考eclipse開發參考中關于擴展點org.eclipse.ui.commands的詳細描述。

    ------------

    2、
     建立Acion,在此建立的action可以是實現IAction接口的任何類。比較方便的是繼承
     org.eclipse.jface.Action,然后在新類中覆蓋父類的run() 方法.

     public class CopyAction extends Action{
       
    public CopyAction(){
        setId(
    "org.example.copyaction");
        setActionDefinitionId(
    "com.longtop.intelliplatform.ide.project.commands.DataSource");
       }

     }

    3、
    在創建CopyAction的instance之后,將copyActionInstance用IKeyBindingService綁定到
    指定的command。
    獲得IKeyBinddingservice的一種簡單方式為:
    IKeyBindingService keyBindingService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite().getKeyBindingService();
    keyBindingService.registerAction(copyActionInstance);


    注意:
    1、action的definitionid和command定義的id必須一致。
    2、當指定的keySequence與系統默認的沖突時,如:在窗體的菜單欄中
    指定了Edit->Copy(默認的快捷鍵為Ctrl+C),若將上面的keySequence改為
    M1+C(Ctrl+C)則系統默認的快捷鍵(Ctrl+C)將更改為Ctrl+Insert。即RCP默認
    的為用戶指定的優先,系統動態更新。
    3、IKeyBindingService指定的快捷鍵是有作用范圍的。




    為主菜單綁定快捷鍵

    主菜單的快捷鍵即為 Alt + 菜單名稱中帶下劃線的字母
    定義主菜單快捷鍵只要在主菜單lable中確定的字母前面加上&字符即可
    如:
    plugin.properties  menulabel = &Intelliplatform
    plugin_zh.properties menulabel = 平臺(&I)
    (注意:在該label引用的properties國際化文件中加,直接在plugin.xml中加好像無效,此處存疑)
    posted on 2008-10-06 15:18 子非魚 閱讀(1256) 評論(0)  編輯  收藏 所屬分類: eclipse
    主站蜘蛛池模板: 日本免费xxxx| 中文字幕免费在线看电影大全| 久99久精品免费视频热77| 午夜国产大片免费观看| 亚洲av无码专区在线观看亚| 曰批视频免费30分钟成人| 亚洲人成网址在线观看| a级毛片免费高清毛片视频| 久久精品国产精品亚洲艾草网美妙| 青娱乐在线免费观看视频| 成人au免费视频影院| 狠狠色香婷婷久久亚洲精品| 免费观看的毛片大全| 亚洲国产夜色在线观看| 无码国产精品一区二区免费I6| 天天爽亚洲中文字幕| 麻豆国产VA免费精品高清在线| 亚洲综合精品成人| 国产成人免费全部网站| 日韩大片免费观看视频播放 | 久久免费看黄a级毛片| 日本久久久久亚洲中字幕| 亚洲一级毛片免费在线观看| 亚洲成a人片在线网站| 成人黄软件网18免费下载成人黄18免费视频 | 亚洲精品无码久久久久sm| 免费无码av片在线观看 | 亚洲无码日韩精品第一页| 两性色午夜视频免费播放| 亚洲一卡2卡三卡4卡有限公司| 国产成人AV免费观看| 亚洲成AV人片在线观看| 亚洲午夜av影院| 亚洲女女女同性video| 免费观看国产网址你懂的| 亚洲色在线无码国产精品不卡| 亚洲AV中文无码乱人伦在线视色| 曰批全过程免费视频在线观看| 亚洲精品无码久久久久牙蜜区| 日韩精品亚洲专区在线观看| 亚洲AV成人噜噜无码网站|