Saving EObjects [message #240671] |
Mon, 14 January 2008 01:51 |
Eclipse User |
|
|
|
Originally posted by: ptat004.ec.auckland.ac.nz
Hi there
I am trying to save a list of EObjects that have been selected graphically by the user, i.e. something like the following
MyEditor editor = (MyEditor)window.getActivePage().getActiveEditor();
//editor.getDiagramEditPart()
List selection = editor.getSelected();
MyDiagram diagram = editor.getModel();
FileOutputStream fos = new FileOutputStream(someFileName);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(selection);
oos.writeObject(diagram);
oos.close();
THe problem is that when I try to read it again I am getting null values as to where the objects should be. I assume maybe that I am hoping to achieve a lot by doing very little and I do not have much of an idea yet as to how the models etc are to be saved
I am a newbie at using GEF, EMF etc and any code, recommended reading would be helpful
Thank you
|
|
|
|
Re: Saving EObjects [message #241046 is a reply to message #241019] |
Mon, 28 January 2008 12:01 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Neeraj,
I didn't see this post before. Yes, I'd suggest Piran use the Generator
to invoke "Generate Test Code" for his model, and have a look at the
generated *.test project for the XyzExample.java that shows how to read
and write model instances using EMF's resource APIs. The introductory
overview paper on EMF's documentation page would be good to read as
well. And of course the generated EMF editor shows how to do this as
well.
Neeraj wrote:
> Piran wrote:
>
>> Hi there
>
>> I am trying to save a list of EObjects that have been selected
>> graphically
> by the user, i.e. something like the following
>
>> MyEditor editor = (MyEditor)window.getActivePage().getActiveEditor();
>> //editor.getDiagramEditPart()
>> List selection = editor.getSelected();
>> MyDiagram diagram = editor.getModel();
>
>> FileOutputStream fos = new FileOutputStream(someFileName);
>> ObjectOutputStream oos = new ObjectOutputStream(fos);
>
>> oos.writeObject(selection);
>> oos.writeObject(diagram);
>
>> oos.close();
>
> Hello Piran,
> You may like to have a look at -
> org.eclipse.emf.ecore.resource.impl.ResourceImpl API.
>> THe problem is that when I try to read it again I am getting null
>> values as
> to where the objects should be. I assume maybe that I am hoping to
> achieve a lot by doing very little and I do not have much of an idea
> yet as to how the models etc are to be saved
>
>> I am a newbie at using GEF, EMF etc and any code, recommended reading
>> would
> be helpful
>
>
>> Thank you
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03251 seconds