Hook into button from Toolbar [message #892458] |
Thu, 28 June 2012 10:06 |
|
Hello,
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.
Regards,
Lars.
|
|
|
Re: Hook into button from Toolbar [message #900172 is a reply to message #892458] |
Sun, 05 August 2012 01:34 |
John Steele Messages: 50 Registered: January 2010 |
Member |
|
|
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() {
@Override
public void preExecute(String commandId, ExecutionEvent event) {
}
@Override
public void postExecuteSuccess(String commandId, Object returnValue) {
}
@Override
public void postExecuteFailure(String commandId, ExecutionException exception) {
}
@Override
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
|
|
|
Powered by
FUDForum. Page generated in 0.02965 seconds