2009-06-23 60 views
4

我正在用我自己的觀點來擴展Eclipse的平臺。該視圖在其工具欄中包含一個動作。Eclipse Key綁定衝突

我想創建一個與關聯的鍵綁定快捷鍵Ctrl + R對於此操作。爲此,我創建了一個my.context(我的上下文擴展了org.eclipse.ui.window上下文),my.command和一個my.command.binding擴展。

然後創建我的看法的時候,在的createPartControl(*)方法,啓動我的背景:

IContextService contextService = (IContextService) getSite() 
    .getService(IContextService.class); 
contextService.activateContext(VIEW_CONTEXT_ID); 

當我的觀點是在調試角度,我有以下警告開:

Warning: A conflict occurred for CTRL+R: 
    Binding(CTRL+R, 
    ParameterizedCommand(Command(org.eclipse.debug.ui.commands.RunToLine,Run to Line, 
    Resume and break when execution reaches the current line, 
    Category(org.eclipse.debug.ui.category.run,Run/Debug,Run/Debug command category,true), 
ActionDelegateHandlerProxy(null,org.eclipse.debug.internal.ui.actions.RetargetRunToLineAction), 
    ,,true),null), 
    org.eclipse.ui.defaultAcceleratorConfiguration, 
    org.eclipse.debug.ui.debugging,,,system) 
    Binding(CTRL+R, 
    ParameterizedCommand(Command(RestoreAction,Restore Chart (T-Charts), 
    Restore the initial chart display, 
    Category(TChartsActions,T-Charts Actions,null,true), 
    ActionHandler([email protected]), 
    ,,true),null), 
    org.eclipse.ui.defaultAcceleratorConfiguration, 
    com.st.tcharts.ui.view,,,system) 

我不知道爲什麼我有這個警告....

在給定的時間有幾個活動的上下文嗎?

如果我改變我的快捷方式,按Ctrl +ç例如,我沒有這個警告,但按Ctrl +ç也綁定在debugg上下文中的另一個命令(複印件)..爲什麼?

我沒有找到明確ressources delaing有關在網絡上的Eclipse環境...

在此先感謝

馬努

+0

用更多的想法更新了我的答案。 – VonC 2009-06-23 20:06:20

+0

感謝您的反饋(在評論中)。如果你確實找到了解決方案,不要猶豫,在這裏發佈(並將其作爲正式答案)。我會upvote它;) – VonC 2009-06-24 13:00:45

回答

2

我不知道爲什麼你的上下文不從隔離您的綁定但如果CTRL+R已經與「Run to Line」命令相關聯,則可以簡單地更改其處理程序,如this thread中所述:

(適用於您的ca的示例SE)

<handler 
     class="test.handlers.DeleteFooHandler" 
     commandId="org.eclipse.ui.edit.delete"> 
    <activeWhen> 
     <iterate 
      ifEmpty="false" 
      operator="and"> 
      <instanceof 
       value="test.model.Foo"> 
      </instanceof> 
     </iterate></activeWhen> 
</handler> 

注:此方法也被this thread說明:現在

IHandlerService handlerService = 
    getSite().getService(IHandlerService.class); 


IHandler myPaste = new org.eclipse.core.commands.AbstractHandler() { 
    public Object execute(ExecutionEvent event) throws ExecutionException{ 
    System.out.println("This is MyPaste"); 
    } 
}; 

,因爲它並沒有解釋爲什麼自己IContext不會禁止Eclipse的綁定,我只能找到現在爲this thread,解釋當你的情況是或不是實際上有效:

如果您正在打開自己的窗口(對話框或外殼)並且使工作臺窗口不活動,則您的上下文也不會處於活動狀態。
你可以嘗試設置你的窗口外殼來鍵入==窗口也使用IContextService#registerShell(*) ...應該保持標準窗口上下文有效。
當您的SW窗口外殼處於活動狀態(禁用匹配)時,您仍可能需要激活上下文。

到的OP回答說:

我通過激活所需的窗口的聚焦增益這方面得到了它的解決方案,並取消激活焦點這方面失去了和同一個窗口的處理。

可能會有所幫助。
與此同時,您可以查看「Platform Command Framework」以激活「追蹤選項」並查看確切激活了哪些綁定以及哪些命令。