Access EcoreModel instance [message #416420] |
Thu, 31 January 2008 04:17  |
Eclipse User |
|
|
|
Originally posted by: harkon.ogame.gmail.com
Hi everybody...
I encountered a problem in accessing an instance of a Ecore modell
residing in my workspace of Eclipse.
Situation: I want to access an Ecore Modell from a newly created Plugin
existing in the current Eclipse instance. This can be done via an URL file
based. if I now open die URL I can access the content and everything is
fine.
Now if an Ecore Model editor is open in the same time the model won't be
updated immediately. I have to refresh the display.
Question: The Ecore Model Editor owns a Ecore Model reference itself
(EObject root node). How can I access this root node of the opened Ecore
Model Editor?
The background is: I want to alter the content of an Ecore model via EMF
techniques and whenever a change was registered the EMF fires various
events about this update and the Ecore Model Editor changes its display
"on the fly". Now if I change the model from another Eclipse Plugin via
this root node instance of the opened Ecore Model Editor I can "see" the
changes in the moment they happen...
I hope I made myself clear enough that some one could help me ;)
Cheers
harkon
|
|
|
|
|
Re: Access EcoreModel instance [message #416459 is a reply to message #416455] |
Fri, 01 February 2008 12:16   |
Eclipse User |
|
|
|
Karkon,
Comments below.
harkon wrote:
> Hi Ed!
>
> Yes, my intention is to make a m2m transformation on Ecore models and
> to see the changes on the fly.
>
> Okay, all editors implement the interface you mentioned below but now:
> The user chooses which model is the source and which one is the
> destiantion. This decision is made via a workspace browser and the
> files are selected.
>
> After that decision the model shall be opened with the default editor
> (e.g. Ecore Model Editor).
>
> Maybe one model is already opened.
>
> How to find now the corresponding editor?
Each workbench page provides access to all the open editors, so I guess
you could scan them all...
> And above all how to automatically open a file in an editor from
> another plugin?
The generated wizard's performFinish shows how to do that.
I could imagine another way to implement such a thing is as a popup
action on an EPackage...
>
> Hmm, weird ;)
>
> Cheers
> harkon
>
> Ed Merks wrote:
>
>> Harkon,
>
>> Comments below.
>
>
>> harkon wrote:
>>> Hi everybody...
>>>
>>> I encountered a problem in accessing an instance of a Ecore modell
>>> residing in my workspace of Eclipse.
>>>
>>> Situation: I want to access an Ecore Modell from a newly created
>>> Plugin existing in the current Eclipse instance. This can be done
>>> via an URL file based. if I now open die URL I can access the
>>> content and everything is fine.
>>>
>>> Now if an Ecore Model editor is open in the same time the model
>>> won't be updated immediately. I have to refresh the display.
>> You haven't talked about making modifications yet, so I'm missing the
>> connection or a step as to why the display needs refreshing.
>>>
>>> Question: The Ecore Model Editor owns a Ecore Model reference itself
>>> (EObject root node). How can I access this root node of the opened
>>> Ecore Model Editor?
>> All generated editors implement IEditingDomainProvider so you can
>> cast the editor to that, get the editing domain, and from that you
>> have access to the resource set in which all the resources being
>> edited are kept.
>>> The background is: I want to alter the content of an Ecore model via
>>> EMF techniques and whenever a change was registered the EMF fires
>>> various events about this update and the Ecore Model Editor changes
>>> its display "on the fly".
>> Be sure to use the command stack of the editing domain to make all
>> your changes so that the editor can undo the changes and knows that
>> it's dirty and needs to save.
>>> Now if I change the model from another Eclipse Plugin via this root
>>> node instance of the opened Ecore Model Editor I can "see" the
>>> changes in the moment they happen...
>>>
>>> I hope I made myself clear enough that some one could help me ;)
>>>
>>> Cheers
>>> harkon
>>>
>
>
|
|
|
|
Re: Access EcoreModel instance [message #416467 is a reply to message #416465] |
Sun, 03 February 2008 23:19  |
Eclipse User |
|
|
|
Hi Harkon,
The method EcoreUtil.getAllContents(ResourceSet, boolean) returns an
iterator that allows you to do what you are looking for. If you pass
true as the 2nd argument, you will end up loading any resource that has
instances related to the model you are inspecting.
Analyzing the code of this method will probably help you understanding
EMF a bit more.
Cheers,
Marcelo.
harkon wrote:
> Hi Ed!
>
> You wrote:
>>>> All generated editors implement IEditingDomainProvider so you can
>>>> cast the editor to that, get the editing domain, and from that you
>>>> have access to the resource set in which all the resources being
>>>> edited are kept.
>
> Yes - now I see it ;) and i can cast it... But now how to access the
> EObject within?
> I find no way to even identify the correct class -.-
>
> Can I iterate to all EObjects within the model via this resource set?
>
> Cheers
> harkon
>
|
|
|
Powered by
FUDForum. Page generated in 0.09696 seconds