Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Selection synchronizing in two Editors
icon4.gif  Selection synchronizing in two Editors [message #997181] Fri, 04 January 2013 09:56 Go to next message
Tim E. is currently offline Tim E.
Messages: 56
Registered: November 2012
Member
Hi,

I've a problem and don't have a clue how to solve it Smile

The problem is, that I've two editors.
1) Textual Editor (not mine)
2) Graphical Editor (mine)

I want to display the textual model of the first editor
in the second editor. The second editor is based on GEF.

At the moment I'm thinking of one requirement I have,
but no idea how to solve it.

A selection mechanism:
Whenever something is selected in one of the editors,
it should also be selected in the other one.

So I don't know how to achieve this
and would really appreciate some help.

Some more informations/constraints:

- the graphical editor can also be used without the textual editor!
- not sure if this information is helpful:
-- the input of the graphical editor is the text of the file
-- but it is parsed and represented as a AST (Abstract Syntax Tree)
-- which is the model for the graphical Editor

Thanks in advance,
Tim
Re: Selection synchronizing in two Editors [message #997202 is a reply to message #997181] Fri, 04 January 2013 12:57 Go to previous messageGo to next message
Jan Krakora is currently offline Jan Krakora
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi,

both editors should have to provide selection and a way to set selection. If they do, then it's just about mapping the selection between them.
The GEF's EditPartViewer implements ISelectionProvider so it's done for you. Its selection objects are EditParts.

So basically you have to add selection listeners to both editors and when selection changes, you have to map selection from source editor (the one which fires the selection change) to
the target editor selection model and set that selection on it. Take a look at org.eclipse.gef.ui.parts.SelectionSynchronizer which does exactly you are asking for, but
only for EditPartViewer editors.
Re: Selection synchronizing in two Editors [message #997204 is a reply to message #997202] Fri, 04 January 2013 13:01 Go to previous messageGo to next message
Tim E. is currently offline Tim E.
Messages: 56
Registered: November 2012
Member
Hi,

thanks a lot for your help.

Unfortunately, the textual editor is not GEF based.
Therefore the SelectionSynchronizer won't work, if I understood it correctly.
Re: Selection synchronizing in two Editors [message #997217 is a reply to message #997204] Fri, 04 January 2013 14:01 Go to previous messageGo to next message
Jan Krakora is currently offline Jan Krakora
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Yes, I assumed that. The SelectionSynchronizer is for your inspiration because there is all the stuff about listening to selection changes
and mapping selection from source editor to the target editor.
Re: Selection synchronizing in two Editors [message #997218 is a reply to message #997217] Fri, 04 January 2013 14:05 Go to previous messageGo to next message
Tim E. is currently offline Tim E.
Messages: 56
Registered: November 2012
Member
Again, thanks Smile

I forgot to mention, that I'll use it as inspiration Smile

Although, I don't know how to accomplish the "registration"
of a SelectionSynchronizer class for two editors.
Especially, when I don't know if one of them it open or not...
I'm fairly new to the creation of Editors for Eclipse.

I'm also not sure, if this topic belongs to the GEF forum... Smile
Re: Selection synchronizing in two Editors [message #997398 is a reply to message #997218] Mon, 07 January 2013 10:18 Go to previous messageGo to next message
Jan Krakora is currently offline Jan Krakora
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Well, it's more platform related question. Look at this article to get more information about selections in Eclipse.
Re: Selection synchronizing in two Editors [message #997402 is a reply to message #997398] Mon, 07 January 2013 10:28 Go to previous message
Tim E. is currently offline Tim E.
Messages: 56
Registered: November 2012
Member
Thanks a lot!

This looks exactly like what I was looking for.
Previous Topic:performance issues on GEF
Next Topic:SWT.TAB key
Goto Forum:
  


Current Time: Thu Sep 18 18:05:00 GMT 2014

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

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