Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to open a generated editor with an existing model
How to open a generated editor with an existing model [message #1071813] Sun, 21 July 2013 08:15 Go to next message
Vincent De Bry is currently offline Vincent De BryFriend
Messages: 55
Registered: May 2013
Member
Hi,

I have a File (myModelfile) that conforms to the ECore Model for which I have generated an Editor.

It appears that opening this file within this editor using the following code:
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(page, myModelfile, editorId);

leads to the creation of a new model instance (call of method createModel() of the generated editor).
Thus, I cannot keep the track of the model object I have selected between 2 model opening (the selection of a same model element -from a user point of view- returns 2 different objects -from a java point of view-), whereas my file is the same and most of the time has not been modified at all (I may use the editor for edition, but also only viewing the model content)

I want to keep a track because I am managing a kind of selection history...

How should I proceed so that the same model instance related to myModelfile is managed at each new editor opening request ?

Thanks.
Re: How to open a generated editor with an existing model [message #1071822 is a reply to message #1071813] Sun, 21 July 2013 08:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Vincent,

Comments below

On 21/07/2013 10:15 AM, Vincent De Bry wrote:
> Hi,
>
> I have a File (myModelfile) that conforms to the ECore Model for which
> I have generated an Editor.
>
> It appears that opening this file within this editor using the
> following code:
>
> IWorkbenchPage page =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
> IDE.openEditor(page, myModelfile, editorId);
>
> leads to the creation of a new model instance (call of method
> createModel() of the generated editor).
Yes.
> Thus, I cannot keep the track of the model object I have selected
> between 2 model opening (the selection of a same model element -from a
> user point of view- returns 2 different objects -from a java point of
> view-),
Yes.
> whereas my file is the same and most of the time has not been modified
> at all (I may use the editor for edition, but also only viewing the
> model content)
>
> I want to keep a track because I am managing a kind of selection
> history...
EcoreUtil.getURI(eObject) yields a URI x that for any resourceSet s,
s.getEObject(x) will yield either that eObject itself, or a "clone" of
that eObject specific to that resource set.
>
> How should I proceed so that the same model instance related to
> myModelfile is managed at each new editor opening request ?
You should not try to achieve that. Based on URIs you can locate/load
the object as needed.
>
> Thanks.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to open a generated editor with an existing model [message #1071884 is a reply to message #1071822] Sun, 21 July 2013 13:06 Go to previous message
Vincent De Bry is currently offline Vincent De BryFriend
Messages: 55
Registered: May 2013
Member
Ok, thank you Ed, I will try thinking to a solution based on URIs...
Previous Topic:[Xcore] How to define/constrain a class when it is referenced in two containers
Next Topic:Derived attributes, stored in feature map (for anyAttribute support)
Goto Forum:
  


Current Time: Thu Mar 28 22:07:13 GMT 2024

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

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

Back to the top