Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Hook into button from Toolbar
Hook into button from Toolbar [message #892458] Thu, 28 June 2012 10:06 Go to next message
Lars Schütze is currently offline Lars SchützeFriend
Messages: 42
Registered: March 2012
Location: Germany


I want to change the behavior of a button in the toolbar of another plug-in.
I already added a button to this toolbar through the viewActions extension. But the IViewActionDelegate#selectionChanged() method is not called when other buttons of the view's toolbar are pressed, but mine.

How can I achieve to hook in there? The best would be to get notified when the button is pressed, before the action defined for this button is executed.

Re: Hook into button from Toolbar [message #900172 is a reply to message #892458] Sun, 05 August 2012 01:34 Go to previous message
John Steele is currently offline John SteeleFriend
Messages: 50
Registered: January 2010
If it's a Command, you know it's ID, and you have access to a service locator, you can hook a listener to it using the IExecutionListener and the CommandService:

ICommandService commandService = (ICommandService) super.getSite().getService(ICommandService.class);
Command command = commandService.getCommand("the_command_id");
command.addExecutionListener(new IExecutionListener() {
 public void preExecute(String commandId, ExecutionEvent event) {
 public void postExecuteSuccess(String commandId, Object returnValue) {
 public void postExecuteFailure(String commandId, ExecutionException exception) {
 public void notHandled(String commandId, NotHandledException exception) {

You can also add a global execution listener to be notified when any command is executed:

ICommandService commandService = (ICommandService) super.getSite().getService(ICommandService.class);
commandService.addExecutionListener(new IExecutionListener() {

Hope this helps!

[Updated on: Sun, 05 August 2012 01:34]

Report message to a moderator

Previous Topic:[JADE] A lot of instance of JADE's agent in Eclipse
Next Topic:Product definition with ref to entire p2 repos
Goto Forum:

Current Time: Fri Apr 20 22:42:46 GMT 2018

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

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