posts - 20, comments - 16, trackbacks - 0, articles - 0

          [轉載] FAQ How do I associate an action with a command?

          Posted on 2008-01-08 14:44 Raul Gong 閱讀(270) 評論(0)  編輯  收藏 所屬分類: eclipse

          From Eclipsepedia

          http://wiki.eclipse.org/FAQ_How_do_I_associate_an_action_with_a_command?

          Actions are associated with commands in various ways depending on how the actions are defined. For actions contributed via the actionSets extension point, the association with a command is done directly in the action definition. The definitionId attribute of the action element must match the ID of the command it is associated with:

             <actionSet ...>
                <action
                   definitionId="org.eclipse.faq.sampleCommand"
                   ...>
                </action>
             </actionSet>
             <command
                id="org.eclipse.faq.sampleCommand"
                ...>
             </command>

          For actions created programmatically, associating the action with a command is a two-step process. As with declarative actions, the first step is to set the action’s definition ID to match the ID of the command. The command must still be defined declaratively, using the command extension point. The definition ID is set by calling Action.setDefinitionId. The second step is to register the action with the platform, using the key-binding service. This service can be accessed from the IWorkbenchPartSite, which is accessible to both views and editors. Here is an example of these steps for an action in a view:

             action.setActionDefinitionId("some.unique.id");
             view.getSite().getKeyBindingService().registerAction(action);

           

          主站蜘蛛池模板: 永和县| 台北县| 漳浦县| 普陀区| 阿城市| 绍兴市| 蓬溪县| 华安县| 平阴县| 柳州市| 永德县| 肃宁县| 克什克腾旗| 嘉义市| 错那县| 务川| 灵武市| 区。| 陆丰市| 新安县| 沂源县| 辛集市| 汉寿县| 郑州市| 东港市| 凤翔县| 苍溪县| 建德市| 庆阳市| 太仓市| 祁阳县| 武安市| 三门峡市| 阳曲县| 资源县| 吉隆县| 贡觉县| 孙吴县| 兴安盟| 永安市| 章丘市|