2014-10-13 2 views
2

벨로우즈 스 니펫을 시도했지만 호출 된 명령은 빈 매개 변수 맵을 사용하여 실행됩니다.프로그래밍 방식으로 매개 변수를 전달하는 명령을 호출하는 방법은 무엇입니까?

ICommandService service = (ICommandService) ((IServiceLocator) PlatformUI.getWorkbench()) 
         .getService(ICommandService.class); 

Command command = service.getCommand(Constants.COMMAND_ID); 

ExecutionEvent eventWithParam = new ExecutionEvent(command, 
     Collections.singletonMap(Constants.COMMAND_PARAM, "true"), null, null); 

command.execute(eventWithParam); 

문제는 호환성 계층에 갈 때입니다 HandlerServiceHanlder.execute 방법에 PARM_MAP을 잃어 버릴 것 같다.

해결 방법이 있습니까?

+0

'(지원되지 않습니다) Command.execute'는'ExecutionEvent' 접촉하지 않습니다 - 단지 바로 현재의 핸들러에 전달합니다. 귀하의 처리기 코드를 보여주십시오. –

+0

호출 핸들러 : 공용 클래스 RunHandler는 AbstractHandler가 IHandler를 구현 확장 { \t @Override \t 공공 객체 실행 (ExecutionEvent 이벤트가) ExecutionException을 던졌습니다 { \t \t 문자열 sIsCleanup = event.getParameter (Constants.COMMAND_PARAM); \t \t if (sIsCleanup! = null) { \t \t \t isCleanup = Boolean.parseBoolean (sIsCleanup); \t \t} – kmaziarz

답변

1

감사합니다. @ greg-449, 내가 계속 파고 들도록 유도했습니다.

마지막으로 Command.excecuteCommand.executeWithChecks도 작동하지 않습니다 (모든 매개 변수는 HandlerServiceHandler으로 전달되는 동안 손실됩니다).

그러나 이것은 기본적으로 작업을 수행 할 수있는 HandlerService과 같은 것을 상기시켜줍니다. 다음 코드 조각은 다음과 같습니다

IHandlerService handlerService = (IHandlerService) ((IServiceLocator) PlatformUI.getWorkbench()) 
        .getService(IHandlerService.class); 

Parameterization[] params = new Parameterization[] { new Parameterization(
        command.getParameter(Constants.COMMAND_PARAM), "true") }; 
ParameterizedCommand parametrizedCommand = new ParameterizedCommand(command, params); 
handlerService.executeCommand(parametrizedCommand, null); 
관련 문제