Jdv
Jdv

Reputation: 993

Trigger Eclipse plugin menu-entry programmatically?

I've got this question: I have an menu entry in my Eclipse plugin. It has a handler which extends AbstractHandler and overrides execute() which takes an ExecutionEvent parameter.

Now what I want to do is to trigger this function when something specific happens. May someone tell me how to do it?

I guess I have to create a ExecutionEvent on my own somehow?

Upvotes: 2

Views: 915

Answers (1)

greg-449
greg-449

Reputation: 111142

You can use the IHandlerService to execute the command that the handler handles, which will call your handler:

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

handlerService.executeCommand("command id", event);

There is another variant of executeCommand which takes a ParameterizedCommand if you need to pass command parameters.

Upvotes: 5

Related Questions