Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Problem with events and lazy part rendering
Problem with events and lazy part rendering [message #941331] Fri, 12 October 2012 12:14 Go to next message
Ulrich Obst is currently offline Ulrich Obst
Messages: 12
Registered: August 2012
Junior Member
Hi there,

I have an application with a part (part-A) and a part stack with other part. When the user clicks on an item in part-A a certain part in the part stack (part-B) should become visible.

I implemented this by sending an event in part-A via the IEventBroker and part-B catches this event, makes itself visible (by calling partService.activate(me)), and does whatever it has to do.

This works fine if the user manually selected part-B before. If part-B was never selected, the object associated with part-B is not created and therefore the event is not received.

Of cause part-A could call the partService.activate(part-B) before sending the event, but normally the sender of an event should not make any assumptions about the receiver of the event.

It the a way to force the creation of the associated object of part-B? Or is my approach completly wrong and there is a better solution?

Ulli
Re: Problem with events and lazy part rendering [message #941404 is a reply to message #941331] Fri, 12 October 2012 13:39 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph Keimel
Messages: 356
Registered: December 2010
Location: Germany
Senior Member
You could use an AddOn as a controller to listen to the events and activate part-B.
Re: Problem with events and lazy part rendering [message #946431 is a reply to message #941331] Tue, 16 October 2012 07:42 Go to previous messageGo to next message
Ulrich Obst is currently offline Ulrich Obst
Messages: 12
Registered: August 2012
Junior Member
Yes I can do that but, this shifts the problem to the addon. The addon must know about the real receiver of the event and that is not much better as if the sender must know the receiver.
Re: Problem with events and lazy part rendering [message #946485 is a reply to message #946431] Tue, 16 October 2012 08:32 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

If I got this correctly the part B is not getting the event because the contributor (backing POJO) is not instantiated. That is a normal thing as it is lazy loading the part.

As Christoph said you can supply an addon which activates the part-B. You can do a quick show/hide just to create it from the addon and I would not consider it a publisher-receiver link as the publisher is a separate thing from the addon. The addon's job is just to circumvent the lazy loading of the part, not publish events. The publisher (part A) does not know and has no reference to part B so I don't see where the link is.

There are other alternatives as creating the contributions programmatically using contribution factories but it is better to stick to the services.
Re: Problem with events and lazy part rendering [message #946630 is a reply to message #946485] Tue, 16 October 2012 11:02 Go to previous messageGo to next message
Ulrich Obst is currently offline Ulrich Obst
Messages: 12
Registered: August 2012
Junior Member
My solution now is a subclass of the StackRenderer that renders the part immediately and not lazily, depending on a certain tag at the part.

This avoids creating an addon for every event that is sent to an potentially invisible part. (In my application this may occur several times)

Thank you for your suggestions.
Re: Problem with events and lazy part rendering [message #946697 is a reply to message #946630] Tue, 16 October 2012 12:16 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

Fair enough. Providing your own renderer is a good solution also.
Re: Problem with events and lazy part rendering [message #946738 is a reply to message #946697] Tue, 16 October 2012 12:55 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5350
Registered: July 2009
Senior Member
Out of curiosity why are you not pushing stuff to the IEclipseContext
(e.g. of the perspective, window or even application) and when the part
gets activated the value will get injected, this sounds the correct
solution. Your current approach e.g. does not allow closing and
reopening the view.

IMHO one uses:
* DI if you want to have the values available all time
* Event-System if the information is import for those currently active
but not interesting for those currently not shown/rendered

Tom

Am 16.10.12 14:16, schrieb Sopot Cela:
> Fair enough. Providing your own renderer is a good solution also.
Re: Problem with events and lazy part rendering [message #951369 is a reply to message #946738] Sat, 20 October 2012 17:28 Go to previous message
Ulrich Obst is currently offline Ulrich Obst
Messages: 12
Registered: August 2012
Junior Member
I don't think that pushing the data in an eclipse context helps in my situation. The producing part of the information does not know what the receiving part is and what it likes to do with the data. In my situation the receiver may decide that the data is important to the user and it forces its visibility (with partService.activate(...)). I can't wait until the user activates the part manually. So I have a problem if the associated object is not yet created. I can't see what it helps (in my situation) when I push the data in an eclipse context. Pushing it an a context does not create the object.

According to your list, what mechanism I should use, I have a third situation:

* Data that should not be avaibable all the time and is important for parts not visible.
Previous Topic:Dynamically changing the label of a Part
Next Topic:Views problem
Goto Forum:
  


Current Time: Wed Oct 01 16:36:28 GMT 2014

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

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