Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Updating command contributions on handler switch
Updating command contributions on handler switch [message #1395817] Mon, 07 July 2014 12:45 Go to next message
Marco Descher is currently offline Marco DescherFriend
Messages: 156
Registered: October 2010
Location: Austria
Senior Member
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 #1396724 is a reply to message #1395817] Tue, 08 July 2014 17:35 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 599
Registered: January 2012
Senior Member

We don't have anything like this, and I don't see a bug report for tracking it. You could look at how the compat code supports IElementUpdater/ICommandService#updateElements().

Brian.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Updating command contributions on handler switch [message #1396814 is a reply to message #1396724] Tue, 08 July 2014 20:43 Go to previous messageGo to next message
Marco Descher is currently offline Marco DescherFriend
Messages: 156
Registered: October 2010
Location: Austria
Senior Member
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?!
Re: Updating command contributions on handler switch [message #1397278 is a reply to message #1396814] Wed, 09 July 2014 13:40 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 599
Registered: January 2012
Senior Member

Was the active part in both perspectives?

You'll only be reinjected if the handler changed.

Brian.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Updating command contributions on handler switch [message #1397829 is a reply to message #1397278] Thu, 10 July 2014 08:01 Go to previous message
Marco Descher is currently offline Marco DescherFriend
Messages: 156
Registered: October 2010
Location: Austria
Senior Member
Hy Brian, the problem is not with the perspectives, thats a bug with my software Smile However, I found a solution, with some deficiences outlined in a blog post http://www.descher.at/descher-vu/2014/07/e4-updating-ui-contributions-on-context-switch/
Previous Topic:Invalid ToolItem state with "org.eclipse.ui.file.save"
Next Topic:Addons execution order changed in Eclipse 4.4
Goto Forum:
  


Current Time: Fri Jun 23 22:48:19 GMT 2017

Powered by FUDForum. Page generated in 0.02651 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software