Selection Service between different IEditorParts [message #334642] |
Sun, 22 February 2009 16:33  |
Eclipse User |
|
|
|
Originally posted by: alexm.xxx.yyy
I am somewhat puzzled by the ISelectionService. I have two editors that
need to talk to each other. When the user does something in one editor
(e.g. presses the mouse), the other's state changes (e.g. it draws a
different image).
As far as I understand, the ISelectionChangedListeners are notified when
the target part becomes active. But what about the case when the editor
where the selection changed remains active at all times? Is there any
way to force (fire) the selection change event from the
ISelectionProvider that received the new selection in its setSelection()
method, so that all registered listeners are notified?
Another complication is that the two editors belong to different plugins
that should not have any mutual dependency. IOW, they should remain
agnostic of each other.
Any advice is greatly appreciated.
Alex Molochnikov
Kelman Technologies Inc
|
|
|
|
|
Re: Selection Service between different IEditorParts [message #334664 is a reply to message #334661] |
Mon, 23 February 2009 17:38  |
Eclipse User |
|
|
|
Originally posted by: alexm.xxx.yyy
Alex Molochnikov wrote:
> Paul,
>
> Thank you for the reply. I was not clear on the issue that I have. The
> editor that needs to send the selection change event does not have any
> JFace components. It tracks the mouse events and needs to alert other
> editors (from another plugin) about the selection.
>
> The problem is that if I wire up the editor as ISelectionProvider, and
> attempt to notify the listeners from its setSelection() method, I will
> have to maintain the list of these listeners (i.e. the other editors) in
> it, which leads to tight coupling of otherwise unrelated plugins.
>
> I was hoping that there is some editor-agnostic way of telling the
> selection service to fire the selection change events to all registered
> listeners, without exposing that list to the editor.
>
> Alex Molochnikov
>
> Paul Webster wrote:
>> The selection change events are fired every time the selection changes
>> (although it's slightly different for text editors).
>>
>> As long as your main editor is active, changing the selection of its
>> ISelectionProvider would fire a selection changed event (ex, if your
>> editor's ISelectionProvider was set to its TreeViewer, its selection
>> would track the TreeViewer selection)
>>
>> PW
>>
Never mind. I figured it out. You register a selection provider to every
site (editor and view). The one that happens to own the focus fires the
events.
Thanks anyway, Paul. You put me on the right track.
Alex
|
|
|
Powered by
FUDForum. Page generated in 0.03354 seconds