Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Programmatically sync EMF editors(I want to synchronise selections between multiple EMF editors)
Programmatically sync EMF editors [message #1063583] Thu, 13 June 2013 13:01 Go to next message
Phillip Drew is currently offline Phillip DrewFriend
Messages: 77
Registered: October 2012
Member
Basically I have two EMF models and then a third which contains references to the first two.

When I select an element in the third (linked) one I'd like the relevant element in the others to be selected.

I'm using the Eclipse selection service and can get a reference to the selected object however when I try and use that to set the selection in the other editors (using the setSelectionToViewer method) it doesn't actually select anything.

Is there something I need to do to the object I'm getting from the linked editor to make the other editors recognise it (and have their selection work)? I would have thought it would recognise and select it automatically.

Thanks!
Re: Programmatically sync EMF editors [message #1063645 is a reply to message #1063583] Thu, 13 June 2013 15:10 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Phillip,

Comments below.

On 13/06/2013 3:01 PM, Phillip Drew wrote:
> Basically I have two EMF models and then a third which contains
> references to the first two.
>
> When I select an element in the third (linked) one I'd like the
> relevant element in the others to be selected.
Are they all in one editor?
>
> I'm using the Eclipse selection service and can get a reference to the
> selected object however when I try and use that to set the selection
> in the other editors (using the setSelectionToViewer method) it
> doesn't actually select anything.
Each separate editor generally has its own local copy/representation of
the models.
>
> Is there something I need to do to the object I'm getting from the
> linked editor to make the other editors recognise it (and have their
> selection work)? I would have thought it would recognise and select it
> automatically.
Generated editors implement IEditingDomainProvider which allows you
access to the editing domain and thereby the resource set in that
editor. So a general approach would be to determine the object in the
first editor, use EcoreUtil.getURI(eObject) and use that URI in
ResourceSet.getEObject in the second editor; that gives corresponding
instance in that second editor and that's something you can select...
>
> Thanks!


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Programmatically sync EMF editors [message #1063738 is a reply to message #1063645] Fri, 14 June 2013 00:12 Go to previous messageGo to next message
Phillip Drew is currently offline Phillip DrewFriend
Messages: 77
Registered: October 2012
Member
Does the second editor have an instance of its ResourceSet or do I need to make it?
Re: Programmatically sync EMF editors [message #1063758 is a reply to message #1063738] Fri, 14 June 2013 06:43 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Phillip,

If you have an EObject, you can do eObject.eResource().getResourceSet()
so yes, if you have an EObject you most likely have a resource set as
well. Generated editors generally create their own resource set and you
need to use that one, so no, you don't need to create one.


On 14/06/2013 2:12 AM, Phillip Drew wrote:
> Does the second editor have an instance of its ResourceSet or do I
> need to make it?


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] Custom query handlers on arbitrary container?
Next Topic:[EMF] EMF-generated model code can't be compiled if model contains class called "Container&
Goto Forum:
  


Current Time: Fri Mar 29 07:27:13 GMT 2024

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

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

Back to the top