Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Sharing Object between Viewparts
Sharing Object between Viewparts [message #328540] Tue, 27 May 2008 13:37 Go to next message
Eclipse UserFriend
Originally posted by: yagayoga.hotmail.com

Hey!

I have three ViewParts which must access an object selected in a list in a
different Viewpart. What is the preferred method of sharing the object?

Presently all ViewParts implement ISelectionListener and discover the
selected object this way, in the selectionChanged method.

However, when the perspective is brought up initially, the views are not
updated until the user actually clicks the list. What is the solution to
this? Should I be using data binding or something? Thanks!

Jen
Re: Sharing Object between Viewparts [message #328544 is a reply to message #328540] Tue, 27 May 2008 14:36 Go to previous messageGo to next message
Wayne Beaton is currently offline Wayne BeatonFriend
Messages: 554
Registered: December 2017
Senior Member
You probably need to have an underlying UI model that the views provide
a "view" on (basically an implementation of the MVC pattern).

It might be enough to get the current selection from the selection
service when the view is created. That is, go get the selection rather
than just wait for one to be delivered.

HTH,

Wayne

On Tue, 2008-05-27 at 13:37 +0000, Jennifer LLewelyn wrote:
> Hey!
>
> I have three ViewParts which must access an object selected in a list in a
> different Viewpart. What is the preferred method of sharing the object?
>
> Presently all ViewParts implement ISelectionListener and discover the
> selected object this way, in the selectionChanged method.
>
> However, when the perspective is brought up initially, the views are not
> updated until the user actually clicks the list. What is the solution to
> this? Should I be using data binding or something? Thanks!
>
> Jen
>
Re: Sharing Object between Viewparts [message #328559 is a reply to message #328544] Tue, 27 May 2008 16:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: yagayoga.hotmail.com

Wayne Beaton wrote:

> You probably need to have an underlying UI model that the views provide
> a "view" on (basically an implementation of the MVC pattern).

> It might be enough to get the current selection from the selection
> service when the view is created. That is, go get the selection rather
> than just wait for one to be delivered.


Thanks wayne, I've decided to try adding the three ViewParts as listeners
on an ObservableValue in the "main" ViewPart, so they will implement
IChangeListener and register as the user invokes them.

I need to set the order in which the views load when the perspective is
clicked, though. It's important that the "main" ViewPart gets loaded
first, so the others can add themselves as listeners on this, or not load
at all if it doesn't exist. Does anyone know what features Eclipse offers
for setting up the load order and configuring how the ViewParts initialize?

Jen
Re: Sharing Object between Viewparts [message #328570 is a reply to message #328559] Tue, 27 May 2008 17:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: yagayoga.hotmail.com

> Thanks wayne, I've decided to try adding the three ViewParts as listeners
> on an ObservableValue in the "main" ViewPart, so they will implement
> IChangeListener and register as the user invokes them.

> I need to set the order in which the views load when the perspective is
> clicked, though. It's important that the "main" ViewPart gets loaded
> first, so the others can add themselves as listeners on this, or not load
> at all if it doesn't exist. Does anyone know what features Eclipse offers
> for setting up the load order and configuring how the ViewParts initialize?

Think I've solved this - I setup every ViewPart as an IPartListener, then
add them as listeners to the main ViewPart when I detect that it's opened
and remove on close.

Also, I add a check to the reliant ViewParts to see if the main ViewPart
is already displaying when opening them. I use the IViewReferences to
check for this. Thanks for your time.

Jen
Re: Sharing Object between Viewparts [message #328578 is a reply to message #328570] Tue, 27 May 2008 20:13 Go to previous message
Boris Bokowski is currently offline Boris BokowskiFriend
Messages: 272
Registered: July 2009
Senior Member
You might be seeing a bug that was fixed for 3.4 but it is hard to tell
because I don't know which Eclipse version you were using, and if the views
were multi-instance views:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=193832

If using ISelectionService.addSelectionListener(partId, listener) does not
work for you (in 3.4), could you please file a bug?

Thanks
Boris

"Jennifer LLewelyn" <yagayoga@hotmail.com> wrote in message
news:f5188b4b0748156dc1e700730b466ed0$1@www.eclipse.org...
>
>> Thanks wayne, I've decided to try adding the three ViewParts as listeners
>> on an ObservableValue in the "main" ViewPart, so they will implement
>> IChangeListener and register as the user invokes them.
>
>> I need to set the order in which the views load when the perspective is
>> clicked, though. It's important that the "main" ViewPart gets loaded
>> first, so the others can add themselves as listeners on this, or not load
>> at all if it doesn't exist. Does anyone know what features Eclipse offers
>> for setting up the load order and configuring how the ViewParts
>> initialize?
>
> Think I've solved this - I setup every ViewPart as an IPartListener, then
> add them as listeners to the main ViewPart when I detect that it's opened
> and remove on close.
> Also, I add a check to the reliant ViewParts to see if the main ViewPart
> is already displaying when opening them. I use the IViewReferences to
> check for this. Thanks for your time.
>
> Jen
>
Previous Topic:Some strings in plugin.properties not loading?
Next Topic:CommonNavigator with large files
Goto Forum:
  


Current Time: Mon Jul 29 21:43:47 GMT 2024

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

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

Back to the top