Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to notify View of Editor changes
How to notify View of Editor changes [message #449007] Mon, 17 January 2005 17:20 Go to next message
Andy Doddington is currently offline Andy DoddingtonFriend
Messages: 17
Registered: July 2009
Junior Member
I have a view defined whose purpose is to show some details for the
currently selected item in my editor - both the editor and view are
optional (though obviously the view will be empty if the editor does not
exist or does not have a current selection).

What is the recommended way of connecting these two 'things' so that the
event get propagated correctly and that the lifetimes etc are also managed
correctly?

My guess is that I need to register the view with some common 'manager' -
e.g. the workspace - which can then be notified by the editor(s), but
there do not appear to be any built-in mechanisms for me to use (or more
likely, I can't find them).

Any advice would be gratefully received
Re: How to notify View of Editor changes [message #449203 is a reply to message #449007] Wed, 19 January 2005 11:53 Go to previous message
Andy Doddington is currently offline Andy DoddingtonFriend
Messages: 17
Registered: July 2009
Junior Member
OK - I found this answer for myself, but thought I'd note it here for
future reference, plus details of some curious behaviour which somebody
may be able to help me with.

SOLUTION:

I register each editor's viewer with the site, using code of the form:

getSite().setSelectionProvider(myViewer);

In my view, I have registered a listener to handle events from my
editor(s), thus:

getSite().getPage().addSelectionListener(mySelectionListener );

PROBLEM:

The issue I have is that if I specify a typeId as the first parameter for
the 'addSelectionListener' method, then I *only* seem to get events for
the most recently created editor instance. However, if I do not give a
typeId then I get events for all instances (which is what I want).

This would be fine, since I can always filter on the class of the
IWorkbenchPart that gets passed into my handler. However, this does not
work for the null case (which I also need to process). In this case I
can't test the part because it is null. However in the case of the null
handler the registration process seems to work correctly when I give the
optional typeId in the call to 'addSelectionListener' (though only for
null events).

I have therefore had to register two handlers - one with no typeId
specified to process 'normal' events (doing hand-written filtering), and a
special null handler which is registered using a typeId and which *only*
processes null events.

Note: my 'normal' handler implemented the INullHandler interface, since I
wanted it to process both normal and null events.

As always - any advice most appreciated.

Andy D


Andy D wrote:

> I have a view defined whose purpose is to show some details for the
> currently selected item in my editor - both the editor and view are
> optional (though obviously the view will be empty if the editor does not
> exist or does not have a current selection).

> What is the recommended way of connecting these two 'things' so that the
> event get propagated correctly and that the lifetimes etc are also managed
> correctly?

> My guess is that I need to register the view with some common 'manager' -
> e.g. the workspace - which can then be notified by the editor(s), but
> there do not appear to be any built-in mechanisms for me to use (or more
> likely, I can't find them).

> Any advice would be gratefully received
Previous Topic:RichText in SWT?
Next Topic:Window closing event in compare editor
Goto Forum:
  


Current Time: Tue Apr 23 13:24:46 GMT 2024

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

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

Back to the top