Programming/Eclipse RCP

Key Binding 바꾸기

Lawmin 2011. 4. 19. 17:10
기존 binding은 org.eclipse.ui.contexts.window 을 통해 이루어 진다.

1. 새 context 를 생성하여 parentId 를 org.eclipse.ui.contexts.window 로 함
2. org.eclipse.ui.bindings 에 새 key binding 추가
- contextId를 새로만든 contextId 로 지정하고 commandId 를 적절히 지정한다. (연결할 command)
3. context 를 바꿔줘야 한다. (기존 책이나 pdf 등에 나오질 않음)
- workbench 가 생성된 이후에 아래 코드를 호출하여 바꿔준다.
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
 ((IContextService) PlatformUI.getWorkbench()
  .getService(IContextService.class))
   .activateContext("새 contextId);
}
});