Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Communicating between Views
Communicating between Views [message #33389] Thu, 15 May 2003 12:01 Go to next message
Eclipse UserFriend
Originally posted by: george.hetrick.hp.com

The Java perspective has Views that update in response to changes in other
Views -- for example, switching editors causes the Outline View and the
Package Explorer to update themselves.

What are the Views listening for, and when do they establish themselves as
listeners? I'd expect that they might be using
getSite().setSelectionProvider()
and
getSite().getSelectionProvider().addSelectionChangedListener ()
but I always get a null back from getSite().getSelectionProvider(), so I
haven't figured out how to control the order of things in different Views.

Pointing me towards the appropriate source would be fine.
Re: Communicating between Views [message #33424 is a reply to message #33389] Thu, 15 May 2003 12:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.ibm.oti.lab

You may also want to post your question to eclipse.tools.jdt

When you say " getSite().getSelectionProvider().addSelectionChangedListener ()
returns null", is that for your view? If so, did you setup a selection
provider (call setSelectionProvider())?

You can get the selection service from the IWorkbenchWindow. There you can
listen for selection changes for the entire window or only from specific
views/editors.

The outline view is a bit different. It tracks the active editor and asks
for its outline page if the editor has one. Then its up to the editor and
its outline page to keep in sync

Simon :-)

"George Hetrick" <george.hetrick@hp.com> wrote in message
news:ba0dk6$g7k$1@rogue.oti.com...
> The Java perspective has Views that update in response to changes in other
> Views -- for example, switching editors causes the Outline View and the
> Package Explorer to update themselves.
>
> What are the Views listening for, and when do they establish themselves as
> listeners? I'd expect that they might be using
> getSite().setSelectionProvider()
> and
> getSite().getSelectionProvider().addSelectionChangedListener ()
> but I always get a null back from getSite().getSelectionProvider(), so I
> haven't figured out how to control the order of things in different Views.
>
> Pointing me towards the appropriate source would be fine.
>
>
Re: Communicating between Views [message #33473 is a reply to message #33424] Thu, 15 May 2003 12:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: george.hetrick.hp.com

Simon Arsenault wrote:

> You may also want to post your question to eclipse.tools.jdt

Now that we've split newsgroups, it's not always clear where to ask ...

> The outline view is a bit different. It tracks the active editor and asks
> for its outline page if the editor has one. Then its up to the editor and
> its outline page to keep in sync

How does it do that? That's really the missing part for my case.
Re: Communicating between Views [message #33643 is a reply to message #33473] Thu, 15 May 2003 13:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: george.hetrick.hp.com

George Hetrick wrote:

> > The outline view is a bit different. It tracks the active editor and asks
> > for its outline page if the editor has one. Then its up to the editor and
> > its outline page to keep in sync

> How does it do that? That's really the missing part for my case.

I think I see now -- each of my Views that wants to respond to editor
changes establishes a PartListener on the Page. And my Outline View wants
to create itself as a PageBookView, so it doesn't need to regenerate its
tree when different editors come up. DOes that sound correct?
Re: Communicating between Views [message #33720 is a reply to message #33473] Thu, 15 May 2003 13:33 Go to previous messageGo to next message
Eclipse UserFriend
George Hetrick wrote:
> Simon Arsenault wrote:
>>The outline view is a bit different. It tracks the active editor and asks
>>for its outline page if the editor has one. Then its up to the editor and
>>its outline page to keep in sync
>
> How does it do that? That's really the missing part for my case.

I recommend that you take a look at the docs for IContentOutlinePage and
ContentOutlinePage, as well as the Java Editor example (specifically
JavaEditor.getAdapter()).

Jeff
Re: Communicating between Views [message #34330 is a reply to message #33643] Thu, 15 May 2003 16:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: knut_radloff.oti.com

"George Hetrick" <george.hetrick@hp.com> wrote in message news:ba0i8s$kop$1@rogue.oti.com...
> I think I see now -- each of my Views that wants to respond to editor
> changes establishes a PartListener on the Page. And my Outline View wants

Yes, when you register an IPartListener you get a partActivated and partDeactivated notification when editors are switched.

> to create itself as a PageBookView, so it doesn't need to regenerate its
> tree when different editors come up. DOes that sound correct?

It should be sufficient if you create a ContentOutlinePage/IContentOutlinePage. You don't have to create a PageBookView. The default
outline view is a PageBookView and you don't really want to reimplement that. The beauty of the content outliner is that you can
just plug in your own page.
Each editor has its own IContentOutlinePage. The outline view caches the pages of any editors that are activated so they aren't
recreated constantly when you switch editors.

Have a look at the readme example (org.eclipse.ui.examples.readmetool). It implements an outline page. You will also find many other
uses of the outliner if you search for references to IContentOutlinePage in the Eclipse code base.

Knut
Re: Communicating between Views [message #35159 is a reply to message #34330] Fri, 16 May 2003 04:57 Go to previous message
Eclipse UserFriend
Originally posted by: anthony.saucet.freesbee.fr

It's a interesting thread and I try to do the same with a simple view.
I'm quite newbie in eclipse and java, and don't really know where to seek
the right classes and don't really know what happens during a view
lifecycle.
Is there a tutorial on this? Or does anybody could explain to me?

If I want to update a simple view (not viewer or special view like the
outline one) containing only SWT things (layout, combos, texts, labels),
what do I have to implement to have my view automatically updated to have
the combos, texts and labels displaying new info?

many thx for helping me, I'm a bit lost.
anthony



Knut Radloff wrote:

> "George Hetrick" <george.hetrick@hp.com> wrote in message
news:ba0i8s$kop$1@rogue.oti.com...
> > I think I see now -- each of my Views that wants to respond to editor
> > changes establishes a PartListener on the Page. And my Outline View wants

> Yes, when you register an IPartListener you get a partActivated and
partDeactivated notification when editors are switched.

> > to create itself as a PageBookView, so it doesn't need to regenerate its
> > tree when different editors come up. DOes that sound correct?

> It should be sufficient if you create a
ContentOutlinePage/IContentOutlinePage. You don't have to create a
PageBookView. The default
> outline view is a PageBookView and you don't really want to reimplement
that. The beauty of the content outliner is that you can
> just plug in your own page.
> Each editor has its own IContentOutlinePage. The outline view caches the
pages of any editors that are activated so they aren't
> recreated constantly when you switch editors.

> Have a look at the readme example (org.eclipse.ui.examples.readmetool). It
implements an outline page. You will also find many other
> uses of the outliner if you search for references to IContentOutlinePage in
the Eclipse code base.

> Knut
Previous Topic:How to get the Active Project from a list of Projects
Next Topic:[Q] Need direction on how build a source formatter
Goto Forum:
  


Current Time: Thu Mar 13 13:50:52 EDT 2025

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

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

Back to the top