Improving persistance.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2016-07-19 12:41:41 +00:00
parent 1597d9ece5
commit bf98d67b8f
2 changed files with 10 additions and 9 deletions

View File

@ -359,7 +359,7 @@ GrafoscopioGUI class >> startDockingBar [
launchMenu := MenuMorph new.
launchMenu
add: 'New notebook' target: (GrafoscopioNotebook new) selector: #open;
add: 'New notebook' target: (GrafoscopioNotebook new) selector: #openDefault;
add: 'Notebook from file...' target: (GrafoscopioNotebook new) selector: #openFromFileSelector;
add: 'Notebook from Internet...' target: (self new) selector: #openFromUrlUI;
add: 'Recent notebooks...' target: self selector: #openFromRecentlyUsed;

View File

@ -352,8 +352,11 @@ GrafoscopioNotebook >> saveToFile: aFileReference [
aFileReference ifNil: [ self inform: 'No file selected for saving. Save NOT done'. ^ self ].
workingFile := aFileReference.
[ self exportAsSton: self notebook on: (self workingFile writeStream) ]
ensure: [(self workingFile writeStream) ifNotNil: #close].
self workingFile exists ifTrue: [self workingFile delete].
self workingFile ensureCreateFile.
[ self exportAsSton: self notebook on: (self workingFile writeStream)]
ensure: [ (self workingFile writeStream) ifNotNil: #close ].
self inform: ('File saved at: ', String cr, self workingFile fullName).
GrafoscopioGUI updateRecentNotebooksWith: aFileReference.
]
@ -375,12 +378,10 @@ GrafoscopioNotebook >> saveToFileUI [
{ #category : #persistence }
GrafoscopioNotebook >> saveWorkingNotebook [
"Saves the current tree to the user predefined file location used when he/she opened it."
self workingFile exists ifTrue: [self workingFile delete].
self workingFile ensureCreateFile.
[ self exportAsSton: self notebook on: (self workingFile writeStream)]
ensure: [ (self workingFile writeStream) ifNotNil: #close ].
self inform: ('File saved at: ', String cr, self workingFile fullName).
self workingFile
ifNil: [ self saveToFileUI ]
ifNotNil: [ self saveToFile: workingFile ]
]
{ #category : #accessing }