Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » serialize GEF Diagram(Completely confused for saving/loading GEF diagrams)
serialize GEF Diagram [message #643574] Tue, 07 December 2010 13:51 Go to next message
ghazi  is currently offline ghazi Friend
Messages: 3
Registered: December 2010
Junior Member
Hello guys,
My life has been so miserable for this problem I have.
I have spent considerable time to find a tutorial or ... to explicitely tells me how I can serialize my GEF diagram.
some people talks about binary files, some other about XML files but I could not find any example to see how save/load is done in GEF. I know that I should implement doSave() function in my peice of code I should write.
Can you please help me and tell me what exactly should I write my doSave(IProgressMonitor arg0) function. Shall I need changes to my model classes or not????

I also do not know how I can print my GEF diagram.

Thank you vey much ,
Re: serialize GEF Diagram [message #645572 is a reply to message #643574] Sat, 18 December 2010 03:25 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
In the editor's doSave() you should persist the model that is displayed in your diagram. How you do that is up to you, but when the editor is opened again, you should set root model back with org.eclipse.gef.EditPartViewer.setContents(Object).
Re: serialize GEF Diagram [message #645574 is a reply to message #645572] Sat, 18 December 2010 03:48 Go to previous messageGo to next message
ghazi  is currently offline ghazi Friend
Messages: 3
Registered: December 2010
Junior Member
Thanks Felix for your comment,

I have been able to save and load my diagram. It is almost like the way you have suggested me. I read from the file and make my model obejct and set it as the main content of the my graphical viewer(EditPartViewer.setContents(model)). Save is completely ok but I have a big problem in opening the dialog in a seperate graphical editor.

I have added an "open" button to my toolbar, which opens the fileselection dialog to choose the file that should be loaded. I want to open a "new editor" and set its contents to my loaded object. But unfortunately the object is loaded in the default (first) graphical editor.

I would like to ask you let me know how I can create a new editor and set my loaded object into that editr as a new one.

Thank you very much for your help.


Re: serialize GEF Diagram [message #645599 is a reply to message #645574] Sat, 18 December 2010 15:04 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
All you need to do is specify a unique file extension in your org.eclipse.ui.editors extension. When you open the file from Eclipse, an instance of your editor will be created with the file as the input.
Re: serialize GEF Diagram [message #645748 is a reply to message #645599] Mon, 20 December 2010 11:31 Go to previous message
ghazi  is currently offline ghazi Friend
Messages: 3
Registered: December 2010
Junior Member
I did it but unfortunately it did not opened a new editor for my loaded file. I set "cnm" (my extension) into the extensions field of my editor in Extensions page from plugin.xml file.

Maybe this is happen because I do not have a standard routine for "Open". I have created my application as "Hello RCP" template and I had no choise to handle all menue and toolbars by myself as well as "open" button on my toolbar. I am confused with your last commnet about the opening the file from Eclipse rather than my application itself. I run my application as an Eclipse application and it does not have access to the open of Eclipse software.

Shall I do something else?

Thank you for your help
Previous Topic:How to extend Figure to create a rectangle with a line?
Next Topic:Setting scroll position programmatically seems to fail
Goto Forum:
  


Current Time: Tue Apr 23 07:37:10 GMT 2024

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

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

Back to the top