- About us
Sometimes it’s necessary to customize the behavior of the existing i.e. the eclipse provided commands according to the business logic of the rcp application.
Let’s say in general “Paste” command pastes the text from the clipboard. Now I want the paste command should paste text from clipboard with a prefix of “Hello”.
The solution is to override the default handler with a custom one. But the problem with that is you can not declare a custom handler for existing command directly. It will raise a conflict.
So what we will do is we will activate the custom handler by activating a context.
Now, declare the custom handler like shown below:
commandId="<standard / existing command id>">
value="<custom context name>">
The above declaration will activate the custom handler when the declared context will be activated.
Now at the start –up of the application you can activate the context by using following code.
IContextService contextService = (IContextService) PlatformUI.getWorkbench().getService(IContextService.class);
contextService.activateContext( <custom context name> );
So now the above declared command will use the custom handler.
Eclipse, EclipseRCP, Custom Handler, Standard Command