Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Saving EObjects
Saving EObjects [message #240671] Mon, 14 January 2008 01:51 Go to next message
Eclipse UserFriend
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 #241019 is a reply to message #240671] Mon, 28 January 2008 06:35 Go to previous messageGo to next message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 177
Registered: July 2009
Location: Canada
Senior Member
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


Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
Re: Saving EObjects [message #241046 is a reply to message #241019] Mon, 28 January 2008 12:01 Go to previous message
Eclipse UserFriend
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
>
>
Previous Topic:How to implement a timeframe like the one in gantt chart usting pure gef or gmf?
Next Topic:custom resizing
Goto Forum:
  


Current Time: Thu Apr 25 23:26:38 GMT 2024

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

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

Back to the top