Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » GEF Save operation
GEF Save operation [message #164495] Tue, 18 January 2005 22:30 Go to next message
Sapna George is currently offline Sapna GeorgeFriend
Messages: 76
Registered: July 2009
Member
Can someone explain to me how the Save operation works. In all the examples,
the doSave method in the Editor class only saves the model. Snippet shown
below from the Logic example: createOutputStream(out);
serializes the LogicDiagram class. So, how are the EditParts saved? If they
are not saved, how are they recreated when a saved diagram is opened?

What i really want to do is to save the model as an XML file. And my worry
is that when i read the XML to create the classes, will the EditParts be
created as well?

public void doSave(IProgressMonitor progressMonitor) {
try {
editorSaving = true;
saveProperties();
ByteArrayOutputStream out = new ByteArrayOutputStream();
createOutputStream(out);
IFile file = ((IFileEditorInput)getEditorInput()).getFile();
file.setContents(new ByteArrayInputStream(out.toByteArray()),
true, false, progressMonitor);
out.close();
getCommandStack().markSaveLocation();
}
catch (Exception e) {
e.printStackTrace();
} finally {
editorSaving = false;
}
}

thanks in advance.
Sapna
Re: GEF Save operation [message #164580 is a reply to message #164495] Wed, 19 January 2005 15:15 Go to previous message
Brian Fernandes is currently offline Brian FernandesFriend
Messages: 68
Registered: July 2009
Member
Sapna,

Only the models are saved. The AbstractEditPart#refreshChildren method
will create the corresponding EditParts at runtime, using the
GraphicalViewers EditPartFactory.

You can go right ahead and save the model as an XML file.

All the best,
Brian.

Sapna George wrote:

> Can someone explain to me how the Save operation works. In all the examples,
> the doSave method in the Editor class only saves the model. Snippet shown
> below from the Logic example: createOutputStream(out);
> serializes the LogicDiagram class. So, how are the EditParts saved? If they
> are not saved, how are they recreated when a saved diagram is opened?

> What i really want to do is to save the model as an XML file. And my worry
> is that when i read the XML to create the classes, will the EditParts be
> created as well?

> public void doSave(IProgressMonitor progressMonitor) {
> try {
> editorSaving = true;
> saveProperties();
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> createOutputStream(out);
> IFile file = ((IFileEditorInput)getEditorInput()).getFile();
> file.setContents(new ByteArrayInputStream(out.toByteArray()),
> true, false, progressMonitor);
> out.close();
> getCommandStack().markSaveLocation();
> }
> catch (Exception e) {
> e.printStackTrace();
> } finally {
> editorSaving = false;
> }
> }

> thanks in advance.
> Sapna
Previous Topic:paletteviewer
Next Topic:Connection problem
Goto Forum:
  


Current Time: Sun Sep 22 22:12:22 GMT 2024

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

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

Back to the top