How to open a generated editor with an existing model [message #1071813] |
Sun, 21 July 2013 04:15  |
Eclipse User |
|
|
|
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 04:46   |
Eclipse User |
|
|
|
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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04627 seconds