GEF Save operation [message #164495] |
Tue, 18 January 2005 17:30  |
Eclipse User |
|
|
|
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 10:15  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.06618 seconds