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 := MenuMorph new.
launchMenu 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 file...' target: (GrafoscopioNotebook new) selector: #openFromFileSelector;
add: 'Notebook from Internet...' target: (self new) selector: #openFromUrlUI; add: 'Notebook from Internet...' target: (self new) selector: #openFromUrlUI;
add: 'Recent notebooks...' target: self selector: #openFromRecentlyUsed; 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 ]. aFileReference ifNil: [ self inform: 'No file selected for saving. Save NOT done'. ^ self ].
workingFile := aFileReference. workingFile := aFileReference.
[ self exportAsSton: self notebook on: (self workingFile writeStream) ] self workingFile exists ifTrue: [self workingFile delete].
ensure: [(self workingFile writeStream) ifNotNil: #close]. 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. GrafoscopioGUI updateRecentNotebooksWith: aFileReference.
] ]
@ -375,12 +378,10 @@ GrafoscopioNotebook >> saveToFileUI [
{ #category : #persistence } { #category : #persistence }
GrafoscopioNotebook >> saveWorkingNotebook [ GrafoscopioNotebook >> saveWorkingNotebook [
"Saves the current tree to the user predefined file location used when he/she opened it." "Saves the current tree to the user predefined file location used when he/she opened it."
self workingFile
self workingFile exists ifTrue: [self workingFile delete]. ifNil: [ self saveToFileUI ]
self workingFile ensureCreateFile. ifNotNil: [ self saveToFile: workingFile ]
[ self exportAsSton: self notebook on: (self workingFile writeStream)]
ensure: [ (self workingFile writeStream) ifNotNil: #close ].
self inform: ('File saved at: ', String cr, self workingFile fullName).
] ]
{ #category : #accessing } { #category : #accessing }