2012-03-12 2 views
3

프로그래밍 방식으로 관점을 전환하는 기존 명령 및 처리기가있는 RCP 응용 프로그램이 있습니다. 또한 기존 RCP 응용 프로그램에서 사용하는 새로운 플러그 인을 사용합니다. 이 새로운 플러그인이 내 RCP 응용 프로그램의 명령/처리기를 실행하기를 원하지만이 솔루션에 대한 가능한 해결책은 무엇입니까?다른 플러그인에서 기존 플러그인의 명령/처리기를 실행하십시오.

답변

4

당신은 그 명령 (확실하지 않음)에 대한 핸들러를 정의해야하지만 프로그램 명령을 실행하면 다음과 같습니다 수 있습니다

Command command = ((ICommandService) getSite().getService(ICommandService.class)).getCommand(commandId); 
... 
final Event trigger = new Event(); 
ExecutionEvent executionEvent = ((IHandlerService) getSite().getService(IHandlerService.class)).createExecutionEvent(command, trigger); 
command.executeWithChecks(executionEvent); 
3

이 명령을 실행하는 방법에는 여러 가지가 있습니다. @Bela 하나의 선물 - 나는 일반적으로 다음 코드를 사용

ICommandService commandService = (ICommandService) locationService.getService(ICommandService.class); 
IHandlerService hs = (IHandlerService) locationService.getService(IHandlerService.class); 

ParameterizedCommand pc = commandService.deserialize("<cmd-id>(<p-id>=<value>)"); 

hs.executeCommand(pc, null); 

이 방법의 장점은 당신이 명령에 매개 변수를 추가 할 수 있다는 점 차있다 - 예를 들어, org.eclipse.ui.newWizardnewWizardId

관련 문제