キー・バインディング

コマンドを起動する、コマンドとキーの組み合わせの関連をキー・バインディングと呼びます。 プラグインは、キー・バインディングとコマンドを org.eclipse.ui.commands 拡張ポイントに定義できます。 ワークベンチは、次のように、マークアップにコマンドを定義した後にキー・バインディングを定義します。

...
<keyBinding
      string="Ctrl+S"
      scope="org.eclipse.ui.globalScope"
      command="org.eclipse.ui.file.save"
      configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
</keyBinding>
...

同様に 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>

キー・バインディングの string 属性は、コマンドを起動するために使用されるキーの組み合わせを定義します。 そのため、サンプルのアクション・セットがアクティブであるとき、ユーザーが Ctrl+S を選択すると save アクションが起動されます。

同様に、ワークベンチ SaveAction がアクティブであるときは、同じキー組み合わせを使用して、 代わりにこれを起動できます。これは、ワークベンチが SaveAction のために同じコマンド ID を使用するためです。

サンプルを完了するには、スコープ構成について理解する必要があります。 まず、構成について考えてみましょう。

Copyright IBM Corporation and others 2000, 2003.