Eclipse 플랫폼을 이용하여 Eclipse Plug-in 개발시 Command를 직접 호출할 경우가 생기는데 코드 상에서 어떻게 호출 할 수 있는지 설명한다.
코드는 간단하다. 단순히 Workbench 객체에서 관련 Service 참조 객체를 얻어온 다음 메소드로 실행 시키면 된다.
private void sampleCode() {
IHandlerService handlerService =
(IHandlerService) getSite.getService(IHandlerService.class);
try {
handlerService.executeCommand("Command ID", null);
} catch (ExecutionException e) {
e.printStackTrace();
} catch (NotDefinedException e) {
e.printStackTrace();
} catch (NotEnabledException e) {
e.printStackTrace();
} catch (NotHandledException e) {
e.printStackTrace();
}
}
- 참고 사이트
http://wiki.eclipse.org/Platform_Command_Framework
'개발자 > Eclipse SWT' 카테고리의 다른 글
| Eclipse RCP에서 Quick Access 없애기 (0) | 2013.08.25 |
|---|---|
| Tip. RCP에서 P2 Update 기능 사용시 개발 설정 (0) | 2013.03.22 |
