Hi, all:
For my editor com.my.editor.MyEditor,
I want to define a custom handler for the standard command org.eclipse.ui.edit.copy.
I added the following to plugin.xml, but it doesn't work, my handler CopyHandler is even not called at all.
<handler class="com.my.editor.myEditor.handler.CopyHandler"
commandId="org.eclipse.ui.edit.copy">
<activeWhen>
<with
variable="activePartId">
<equals
value="com.my.editor.MyEditor">
</equals>
</with>
</activeWhen>
</handler>
As suggested in http://www.eclipse.org/forums/index.php?t=msg&goto=53208 3& and http://www.mindfiresolutions.com/Using-custom-handlers-for-s tandard-commands-in-Eclipse-RCP-726.php,
I tried to define a context in plugin.xml:
<extension
point="org.eclipse.ui.contexts">
<context
id="com.my.ui.definition.activatedEditorContext"
name="Editor Context"
parentId="org.eclipse.ui.textEditorScope">
</context>
</extension>
And in editor, activate the context:
IContextService contextService = (IContextService) PlatformUI
.getWorkbench().getService(IContextService.class);
contextService.activateContext("com.my.ui.definition.activatedEditorContext");
Define a handler in plugin.xml, and set it active when context is enabled.
<handler class="com.my.editor.myEditor.handler.CopyHandler"
commandId="org.eclipse.ui.edit.copy">
<activeWhen>
<with
variable="activeContexts">
<iterate
ifEmpty="false"
operator="or">
<equals
value="com.my.ui.definition.activatedEditorContext">
</equals>
</iterate>
</with>
</activeWhen>
</handler>
But it neither works..
As a temporary solution, I restored back to use the old action, overwrite Editor's createActions methods:
protected void createActions() {
super.createActions();
cliEditorCopyAction = new CliEditorCopyAction();
setAction(ActionFactory.COPY.getId(), cliEditorCopyAction);
}
This works, but I prefer to use the command and handler framework.
Is there a way to define custom handler for standard command? this should be a common problem, and should have simple solution, but I tried google search in the last few days, can't find any solution yet.
Or is there anything I missed?
Could anyone help on this? Thanks for any help or reply in advance : )