If you require specific behavior to copy (or any command) in your editor or view, you must activate a handler for it. Usually in your createPartControl(Composite) method:
IHandlerService serv = (IHandlerService) getSite().getService(IHandlerService.class); MyCopyHandler cp = new MyCopyHandler(this); serv.activateHandler(org.eclipse.ui.IWorkbenchCommandConstants.EDIT_COPY, cp);
Another common way is to provide a handler through your plugin.xml:
<handler commandId="org.eclipse.ui.edit.copy" handler="com.example.app.MyCopyHandler"> <activeWhen> <with variable="activePartId"> <equals value="com.example.app.MyEditorId"/> </with> </activeWhen> </handler>
Then in your handler you will receive the active part and name its implementation. eg:
IWorkbenchPart part = HandlerUtil.getActivePart(event); if (part instanceof MyEditor) { ((MyEditor)part).copy(); }
source share