From bf98d67b8fa89e546c7064bb673acffe0250e4f3 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Tue, 19 Jul 2016 12:41:41 +0000 Subject: [PATCH] Improving persistance. --- repository/Grafoscopio/GrafoscopioGUI.class.st | 2 +- .../Grafoscopio/GrafoscopioNotebook.class.st | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/repository/Grafoscopio/GrafoscopioGUI.class.st b/repository/Grafoscopio/GrafoscopioGUI.class.st index 8b3105c..05e4e18 100644 --- a/repository/Grafoscopio/GrafoscopioGUI.class.st +++ b/repository/Grafoscopio/GrafoscopioGUI.class.st @@ -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; diff --git a/repository/Grafoscopio/GrafoscopioNotebook.class.st b/repository/Grafoscopio/GrafoscopioNotebook.class.st index 97c85a3..c14ec5b 100644 --- a/repository/Grafoscopio/GrafoscopioNotebook.class.st +++ b/repository/Grafoscopio/GrafoscopioNotebook.class.st @@ -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 }