I've a problem and don't have a clue how to solve it
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
Jan Krakora Messages: 402 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.
Jan Krakora Messages: 402 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.
I forgot to mention, that I'll use it as inspiration
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...