How to set services into handler [message #485225] |
Thu, 10 September 2009 20:30 |
Eclipse User |
|
|
|
Originally posted by: iossif.gmx.de
Hi,
i've got a very simple question. I have a simple application where I
defined some handler under the org.eclipse.ui.handler extension point.
I also created some handler-classes implementing the execute-method.
There I want to call a simple service-method of service class outside of
the application. At the moment I simply create an instance and call the
service. But thats not what I need, because I want to configure the
service into the handler class. Also remembering the IoC-Principle I
want to set the service into that class.
How do I get the service into the handler or where do I configure the
properties of the handler?
Whats the recommended way?
Thanks for your help
|
|
|
|
|
Re: How to set services into handler [message #485369 is a reply to message #485291] |
Fri, 11 September 2009 14:00 |
|
Well ...
Currently when the handler executes, it gets the ExecutionEvent and from that can get the application context. That's an IEvaluationContext. From there you have access to any variables coming from a source provider (like the ones listed in org.eclipse.ui.ISources).
As for services, there are 2 kinds.
1) OSGi services. They can be requested from your BundleContext/ServiceTracker, usually be interacting with your Activator.
2) eclipse framework services. They're contributed through the org.eclipse.ui.services EP and retrieved through an IServiceLocator. Current IServiceLocators are any editor or view site, the workbench windows, and the workbench (PlatformUI.getWorkbench()) itself.
currently, you can reach out to a workbench/part/window or use OSGi services and your activator. We hope to add a way to get an IServiceLocator from your ExecutionEvent or application context.
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
|
Powered by
FUDForum. Page generated in 0.09142 seconds