Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to subscribe action.(How to subscribe action.)
How to subscribe action. [message #1298180] Wed, 16 April 2014 05:07 Go to next message
Sumit Singh is currently offline Sumit SinghFriend
Messages: 141
Registered: October 2012
Location: Bangalore
Senior Member

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 Go to previous message
Simon Scholz is currently offline Simon ScholzFriend
Messages: 73
Registered: April 2012
Location: Germany
Member
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. Smile

Best regards,

Simon

[Updated on: Wed, 23 April 2014 08:25]

Report message to a moderator

Previous Topic:How can I set the size of completion proposal popup of content assistant?
Next Topic:How to use dynamicHelp in Editor
Goto Forum:
  


Current Time: Fri Apr 19 09:22:03 GMT 2024

Powered by FUDForum. Page generated in 0.01308 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top