Button - Action - Job [message #462537] |
Tue, 30 January 2007 06:09  |
Eclipse User |
|
|
|
Originally posted by: kristof.taveirne.intec.ugent.be
Hi,
I have this Job that needs to be executed. The Job reads content from a
smartcard and then does a webservice call, so it can take a while until
it is finished.
The user should be able to execute this from the menu, a shortcut and a
button on some view.
By defining an actionSet i've got a menu-item linked to an
IWorkbenchActionDelegate, so I guess i can schedule the Job in the run
method there.
I've added a org.eclipse.ui.commands extension and via the definitionId
in Action i now have a shortcute that executes the action.
The problem is when I want to use the button.
I've added a SelectionListener to the button and in the
widgetSelected(..) method I've created a new actionDelegate Object and
passed 'new Action(){}' to its run method.
The execution of this action works as long as I don't access
IWorkbenchWindow reference in my actionDelegate implementation. this
ofcourse is a null reference here because the init-method wasn't called.
Is there a way I can access the object that's already initiated so I can
easily provide the window as a parent shell for a message dialog? Or
should I get a reference to the current IWorkbenchWindow in some other way?
Thanks,
kristof.
|
|
|
|
|
Re: Button - Action - Job [message #463057 is a reply to message #462537] |
Mon, 05 February 2007 13:10  |
Eclipse User |
|
|
|
1. you can use org.eclipse.ui.actionSets to add it to the main toolbar,
or org.eclipse.ui.viewActions to add it to the view toolbar.
2. If you've bound your action to a command using the definitionId, you
can call that command from the handler service ... no need to
instantiate another action:
IHandlerService service = (IHandlerService)
getSite().getService(IHandlerService.class);
service.executeCommand(definitionId, null);
You could put that in your widgetSelected(*) method.
3. you could give up on your action, and write it in a handler instead.
Then your keybinding and command work the same way. The only
difference is you would put that service.executeCommand(*) code in your
IActionDelevate#run(*) method.
Later,
PW
|
|
|
Powered by
FUDForum. Page generated in 0.03549 seconds