加速键集

操作定义和应调用该操作的键组合之间的关联称为 加速键加速键集是加速键的列表。 插件可以使用 org.eclipse.ui.acceleratorSets 扩展点添加加速键集。工作台定义提供编辑器宏指令相似的键绑定的加速键集。

<extension
      point="org.eclipse.ui.acceleratorSets">
   <acceleratorSet
         scopeId="org.eclipse.ui.globalScope"
         configurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
      <accelerator
            key="Ctrl+F4||Ctrl+X Ctrl+K"
            id="org.eclipse.ui.file.close">
      </accelerator>
      <accelerator
            key="Ctrl+Shift+F4||Ctrl+X Ctrl+C"
            id="org.eclipse.ui.file.closeAll">
      </accelerator>
      <accelerator
            key="Ctrl+X Ctrl+S"
            id="org.eclipse.ui.file.save">
      </accelerator>
      ...

这里是我们的朋友 org.eclipse.ui.file.save。重调用试探性操作定义:

<extension point = "org.eclipse.ui.actionSets">
   <actionSet id="com.example.actions.actionSet"
   label="Example Actions"
   visible="true">
   <action id="com.example.actions.action1"
   menubarPath="additions"
   label="Example Save Action"
   class="org.example.actions.ExampleActionDelegate"
   definitionID="org.eclipse.ui.file.save">
   </action>
		   ...
   </actionSet>
</extension>

示例操作集活动时,如果用户选择 Ctrl+X,然后选择 Ctrl+S, 则将调用保存操作。(使用 ||(如“Ctrl+Shift+F4||Ctrl+X Ctrl+C”)指示可使用任一键组合激活操作。)

相似的,当工作台 SaveAction 活动时, 相同的键组合会调用它,因为工作台对 SaveAction 使用了相同的操作定义标识。

要完成示例,需要了解 scopeIDconfigurationId 的涵意。 让我们先解决配置问题。

Copyright IBM Corp. and others 2000,2002.