'Call'에 해당되는 글 1건

  1. 2013.03.22 Eclipse RCP - Command를 코드로 불러오기

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


Posted by 빌리 :