Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Selection Service between different IEditorParts
Selection Service between different IEditorParts [message #334642] Sun, 22 February 2009 21:33 Go to next message
Eclipse UserFriend
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 #334659 is a reply to message #334642] Mon, 23 February 2009 19:10 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: Selection Service between different IEditorParts [message #334661 is a reply to message #334659] Mon, 23 February 2009 19:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alexm.xxx.yyy

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
>
Re: Selection Service between different IEditorParts [message #334664 is a reply to message #334661] Mon, 23 February 2009 22:38 Go to previous message
Eclipse UserFriend
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
Previous Topic:Preferences vs. IPreferenceStore
Next Topic:Contributing how-to articles to the Eclipse platform. How?
Goto Forum:
  


Current Time: Wed Sep 18 09:49:14 GMT 2024

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

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

Back to the top