Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Place dependency in window context
Place dependency in window context [message #1730034] Thu, 21 April 2016 06:20 Go to next message
Colin Sharples is currently offline Colin SharplesFriend
Messages: 90
Registered: July 2009
Location: Wellington, New Zealand
Member

I have a controller class that is shared around between several parts and handlers. I originally had this as a @Creatable @Singleton, so that it was available for any of the parts, but it was getting created after the handlers, so I had to inject it into the @Execute and @CanExecute methods, which was a bit messy.

I changed to use an addon, and registered that addon to run before the command service, so that it was now available for the handlers as well as the parts. All good so far.

I then added another window to the application, which reuses some of the parts, but has a different set of handlers. This caused problems, because some of the controller functionality required the selection and part services, which are bound to the window context. The parts in the second window were not working correctly as the controller was really bound to the first window.

I fixed this by changing the add on to create two instances of the controller class, bound to different names. Each part and handler then uses @Named to retrieve the correct instance, so now it all works again.

However, this still seems like a lot of work. It would be a lot easier if there was a context scope annotation, so instead of just @Singleton you could specify that the @Creatable should be one per part, window or application.

In the absence of such an annotation, is there another way that I can bind the different controller instances into the window context, rather than having them both in the application context but under different names?


Colin Sharples
CTG Games Ltd
Wellington, New Zealand
Re: Place dependency in window context [message #1730279 is a reply to message #1730034] Sat, 23 April 2016 07:27 Go to previous message
Colin Sharples is currently offline Colin SharplesFriend
Messages: 90
Registered: July 2009
Location: Wellington, New Zealand
Member

Short answer: use a context function. The full answer to this can be found at https://www.eclipse.org/forums/index.php/t/1076713/

Colin Sharples
CTG Games Ltd
Wellington, New Zealand
Previous Topic:Editor - list unreadable after last update
Next Topic:Persisted object when closing MPart ?
Goto Forum:
  


Current Time: Mon Sep 25 02:48:07 GMT 2017

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

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