[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Re: How to associate global actions (copy, rename, etc.) with handler via plugin

If I want to use the command framework and its extension points, do I have to write a handler to use the existing standard PasteAction for resources or is there a nicer way to do that?

Thanks

Paul Webster wrote:
In 3.3 you  would provide something in org.eclipse.ui.handlers:

[xml]
<handler
    class="org.example.MyPasteHandler"
    commandId="org.eclipse.ui.edit.paste">
  <activeWhen>
    <with variable="activePartId">
      <equals value="org.example.my.view.id"/>
    </with>
  </activeWhen>
</handler>
[/xml]

In 3.3 if you use ActionFactory.PASTE to create this action, then it will not necessarily be enabled properly when your view is active.

But placing paste in the Edit menu using org.eclipse.ui.menus should work fine.

The other way, acceptable for views and editors is to hook up handlers in your createPartControl(*):
IHandlerService service
= (IHandlerService) getSite().getService(IHandlerService.class);
pasteHandle = new MyPasteHandler(this);
service.activateHandler("org.eclipse.ui.edit.paste", pasteHandler);


Later,
PW