RCPアプリケーションのある時点で、F5、Shift + F5、Ctrl + N、Ctrl + Pなどのショートカットを使用して、開始、停止、次、前などを提供したいと考えています。これらは標準スキームですでに定義されており、標準アクションをオーバーライドしたいと考えています。実行時にキーバインディングをアクティブにする方法は?
実行時にアクティブなキーバインディングスキームを切り替えることはできますか?
RCPアプリケーションのある時点で、F5、Shift + F5、Ctrl + N、Ctrl + Pなどのショートカットを使用して、開始、停止、次、前などを提供したいと考えています。これらは標準スキームですでに定義されており、標準アクションをオーバーライドしたいと考えています。実行時にキーバインディングをアクティブにする方法は?
実行時にアクティブなキーバインディングスキームを切り替えることはできますか?
org.eclipse.ui.contexts
拡張ポイントを使用して、キーバインディングの新しい「コンテキスト」を定義し、そのコンテキストでキーバインディングを宣言することができます。
<extension
point="org.eclipse.ui.contexts">
<context
name="%context.editingAnt.name"
description="%context.editingAnt.description"
parentId="org.eclipse.ui.textEditorScope"
id="org.eclipse.ant.ui.AntEditorScope">
</context>
</extension>
とそのコンテキストでキーバインディングを宣言します:Antのエディタは、コンテキストorg.eclipse.ant.ui.AntEditorScope
を宣言例えば
<extension point="org.eclipse.ui.bindings">
<key
sequence="M1+M2+F"
contextId="org.eclipse.ant.ui.AntEditorScope"
commandId="org.eclipse.jdt.ui.edit.text.java.format"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
あなたがそれを有効にする必要があり、コンテキストを使用します。 TextEditor
オーバーライドinitializeKeyBindingScopes
拡張エディタで:
@Override
protected void initializeKeyBindingScopes() {
setKeyBindingScopes(new String[] { "org.eclipse.ant.ui.AntEditorScope" });
}
を他の場所でIContextService
サービスactivateContext
メソッドを使用します。