How to subscribe action. [message #1298180] |
Wed, 16 April 2014 05:07 |
|
Hi,
I'm developing RCP application based on e4 compatibility layer.
Question is there any way so that i can subscribe any particular action (subscribe mean get notification).
For Example CUT or COPY action: when user select these option i want to get notify. So is there is any extension or some thing else to achieve this.
Thanks,
Sumit
|
|
|
Re: How to subscribe action. [message #1310513 is a reply to message #1298180] |
Wed, 23 April 2014 08:25 |
|
Hi Sumit,
Since IActions are obsolet and Copy&Paste are available as Commands, you could try to solve your issue with an org.eclipse.core.commands.IExecutionListener.
I just created some sample code for you:
ICommandService service = (ICommandService) PlatformUI
.getWorkbench().getService(ICommandService.class);
service.addExecutionListener(new IExecutionListener() {
@Override
public void preExecute(String commandId, ExecutionEvent event) {
if ("org.eclipse.ui.edit.copy".equals(commandId)
|| "org.eclipse.ui.edit.paste".equals(commandId)) {
System.out
.println("Copy or Paste Command is about to be invoked");
}
}
@Override
public void postExecuteSuccess(String commandId,
Object returnValue) {
if ("org.eclipse.ui.edit.copy".equals(commandId)
|| "org.eclipse.ui.edit.paste".equals(commandId)) {
System.out
.println("Copy or Paste Command was successfully invoked");
}
}
@Override
public void postExecuteFailure(String commandId,
ExecutionException exception) {
if ("org.eclipse.ui.edit.copy".equals(commandId)
|| "org.eclipse.ui.edit.paste".equals(commandId)) {
System.out
.println("Copy or Paste Command failed during its invocation");
}
}
@Override
public void notHandled(String commandId,
NotHandledException exception) {
if ("org.eclipse.ui.edit.copy".equals(commandId)
|| "org.eclipse.ui.edit.paste".equals(commandId)) {
System.out
.println("Copy or Paste Command could not be handled due to missing command-handler");
}
}
});
I hope this helps and solves your issue.
Do not hesitate to ask further question on this.
Best regards,
Simon
[Updated on: Wed, 23 April 2014 08:25] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01308 seconds