Updating command contributions on handler switch [message #1395817] |
Mon, 07 July 2014 12:45  |
Eclipse User |
|
|
|
Hy there,
as described on stackoverflow, i am trying to find a way to update all Contributions (HandledMenuItem, HandledToolItem, ...) allocated to a Command on the switch to a certain handler.
That is (plz refer to the image on stackoverflow), I have globally defined the add command, overriding it with specific behaviour on selection of the resp. part. On doing this I want to update the tooltips of all contributions.
I do not see a clear way to do this, however, but some approaches I can't seem to follow:
- Have a list of all contributions (List<MContribution>) injected to the @CanExecute (Not supported)
- Use the EModelService to find all contributions to a command (Not implemented)
- Something else?
am I missing something? Is there a solution for this? If not I am willing to go for an implementation!
|
|
|
|
Re: Updating command contributions on handler switch [message #1396814 is a reply to message #1396724] |
Tue, 08 July 2014 20:43   |
Eclipse User |
|
|
|
I did some more experiments, with different approaches. My current findings are:
On switching the parts the EclipseContext.set("handler::handler_id") is called which activates the new handler. It is possible to listen to this event using
@Inject
public void bla(@Optional @Active @Named("handler::command.add") Object value, MApplication application) {}
for example. So on any change for the given command you receive the now activated handler and may act accordingly. This solution located in an Addon, however, does not satisfy me, so I tried to implement the aforementioned into the resp. handlers. Where I have now the interesting behaviour, that on switch of the perspective (through partService.switchPerspective(perspective)) the handler is not exchanged, although the old registered handler in the new Perspective is clearly out of scope. The handler is only swapped if I select one of the parts within the Perspective (not necessarily the one part defining the new handler).
Could this be a bug? I would expect the handler to be exchanged on selecting a different Perspective?!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05089 seconds