Problem:
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.
Example:
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”.
Solution:
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:
<handler
class="<custom handler>"
commandId="<standard / existing command id>">
<activeWhen>
<with
variable="activeContexts">
<iterate
ifEmpty="false"
operator="or">
<equals
value="<custom context name>">
</equals>
</iterate>
</with>
</activeWhen>
</handler>