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

          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);

           

          主站蜘蛛池模板: 昌邑市| 上饶市| 蛟河市| 石台县| 含山县| 科尔| 民权县| 青神县| 长葛市| 宜君县| 池州市| 磐安县| 河南省| 沙坪坝区| 温宿县| 台南市| 樟树市| 阜宁县| 临澧县| 永州市| 赣州市| 抚顺市| 务川| 长宁县| 锦州市| 安塞县| 定安县| 海淀区| 宜州市| 横山县| 阿拉善盟| 镇雄县| 郁南县| 榆林市| 乌审旗| 长垣县| 贵州省| 文成县| 泗阳县| 湘潭县| 凯里市|