#UI_ENHANCEMENT by cg
class: ApplicationWithFileHistory class
added: #fileHistoryFilteredForStillExistingFilesDo:removeNonExisting:
comment/format in:
#addToFileHistory:
#directoryForFileHistory
--- a/ApplicationWithFileHistory.st Tue Sep 26 16:41:47 2017 +0200
+++ b/ApplicationWithFileHistory.st Sun Oct 29 11:18:59 2017 +0100
@@ -11,6 +11,8 @@
"
"{ Package: 'stx:libview2' }"
+"{ NameSpace: Smalltalk }"
+
ApplicationModel subclass:#ApplicationWithFileHistory
instanceVariableNames:''
classVariableNames:''
@@ -62,6 +64,8 @@
!ApplicationWithFileHistory class methodsFor:'file history support'!
addToFileHistory:aFilename
+ "remember a filename in this classes filehistory"
+
|fileHistory|
fileHistory := self fileHistory.
@@ -74,14 +78,19 @@
]
"Modified: / 09-11-2010 / 16:07:14 / cg"
+ "Modified (comment): / 29-10-2017 / 10:51:11 / cg"
!
directoryForFileHistory
+ "the filename where the history is made persistent"
+
^ Filename homeDirectory / '.smalltalk' / (self nameWithoutPrefix)
"
self directoryForFileHistory
"
+
+ "Modified (comment): / 29-10-2017 / 10:51:29 / cg"
!
fetchFileHistoryFromPersistentStore
@@ -117,6 +126,34 @@
^ fileHistory
!
+fileHistoryFilteredForStillExistingFilesDo:aBlock removeNonExisting:aBoolean
+ |history toRemove|
+
+ toRemove := OrderedCollection new.
+
+ history := self fileHistory.
+
+ history notEmptyOrNil ifTrue:[
+ history synchronized:[
+ history do:[:aFilename|
+ aFilename exists ifTrue:[
+ aBlock value:aFilename.
+ ] ifFalse:[
+ toRemove add:aFilename.
+ ]
+ ].
+ aBoolean ifTrue:[
+ "/ remove all non-existing history entries
+ toRemove do:[ : el |
+ fileHistory remove:el.
+ ].
+ ].
+ ].
+ ].
+
+ "Created: / 29-10-2017 / 10:55:46 / cg"
+!
+
fileHistorySize
"defines the number of remembered files in the history"
@@ -206,10 +243,10 @@
!ApplicationWithFileHistory class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/ApplicationWithFileHistory.st,v 1.1 2013-09-05 22:23:55 cg Exp $'
+ ^ '$Header$'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libview2/ApplicationWithFileHistory.st,v 1.1 2013-09-05 22:23:55 cg Exp $'
+ ^ '$Header$'
! !