Calling a command id in the handler of plugin

195 Views Asked by At

I have a menu that triggers Run(Ctrl + F11)

but I want to do more action than Run.

I want to call the command id of run in the handler

public class CheckCodesHandler extends AbstractHandler{

    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);

        /*
         * call the commandid = org.eclipse.debug.ui.runLast here?????
         * */
        return null;
    }
}

so far, I just called the command id in the plugin.xml to execute it.

1

There are 1 best solutions below

0
greg-449 On BEST ANSWER

For a simple command that doesn't need parameters you can use

IHandlerService service = window.getService(IHandlerService.class);

service.executeCommand("command id", null);