All pastes #152381 Raw Edit

Untitled

public text v1 · immutable
#152381 ·published 2006-08-28 19:26 UTC
rendered paste body
Extending the set of services available in a WorkbenchWindow? - Randy Hudson

I am trying to create a service called StyleService to support changing 
something's FontName, etc. So, I have a (combo) contribution item that will 
display the available choices, and the current value. The current value will 
be determined using an interface: StyleProvider (which also allows for 
editing of that style). It is similar to having a retargetable action and a 
globalactionhandler. Note that I can register a global action handler even 
if the retargetable action is not yet created and visibl in the UI. This is 
basically the function that my service needs to provide.

The contribution item could be placed anywhere, including the editor's 
actionbarcontributor. The "stuff" providing the values can be created at any 
time. So I need a way for the contribution item to obtain the instance of 
the service whenever it is added to a toolbar. I need a way for "providers" 
to hook providing whenever they get created. I don't think I can guarantee 
who will go looking for this service first, so I wanted it's creation to 
happen outside of these two clients of my service.

If I can't extend services, the workaround is that I just create "services" 
myself on every workbench part, and my contribution item has to switch 
"services" every time the part activation changes, and then get the service 
from the part using IAdaptable.