--- a/AbstractFileFinderApplicationComponent.st Fri Aug 09 10:52:46 2019 +0200
+++ b/AbstractFileFinderApplicationComponent.st Fri Aug 09 17:22:07 2019 +0200
@@ -118,6 +118,39 @@
].
!
+generateResultStringForTimeElapsed:timeDuration
+ "at the end of a search, generate a nice informative summary string.
+ This can be redefined by different search tabs"
+
+ |timeMillis timeString nFound|
+
+ timeMillis := timeDuration asMilliseconds.
+"/ OLD:
+"/ timeMillis > 100 ifTrue:[
+"/ timeString := ((timeMillis / 1000) asFixedPoint:2) printString , ' s'
+"/ ] ifFalse:[
+"/ timeString := timeMillis printString , ' ms'
+"/ ].
+"/ NEW:
+ timeString := timeDuration printStringForApproximation.
+
+ nFound := resultList size.
+ ^ resources
+ string:((nFound == filesSearchedCount)
+ ifTrue:['Found %1 file%2 in %3 (%6 files/s)']
+ ifFalse:[
+ "/ 'Found %1 file%2 in %3 (%4 files visited)'
+ "/ 'Found %1 file%2 in %3 (%4 files visited; scanrate: %5/s)'
+ 'Found %1 file%2 in %3 (%4 files visited; %6 files/s)'
+ ])
+ with:nFound
+ with:(nFound == 1 ifTrue:'' ifFalse:'s')
+ with:timeString
+ with:filesSearchedCount
+ with:(UnitConverter fileSizeSIStringFor:(bytesSearchedCount * 1000 / (timeMillis max:1)))
+ with:((filesSearchedCount * 1000 / (timeMillis max:1)) asFixedPoint:1).
+!
+
openInNewBrowser
|sel|
@@ -149,7 +182,7 @@
searchTask := thisSearchTask :=
[
- |message timeMillis timeString nFound|
+ |message timeElapsed|
[
(self stopSignal) catch:[
@@ -160,32 +193,15 @@
filesSearchedCount := bytesSearchedCount := 0.
"/ self changeInformationTo:'Find File ' , '- searching ' toTab:true.
- timeMillis := Time millisecondsToRun:[
+ timeElapsed := TimeDuration toRun:[
aBlock value.
].
- timeMillis > 100 ifTrue:[
- timeString := ((timeMillis / 1000) asFixedPoint:2) printString , ' s'
- ] ifFalse:[
- timeString := timeMillis printString , ' ms'
- ].
- nFound := resultList size.
- message := resources
- string:((nFound == filesSearchedCount)
- ifTrue:['Found %1 file%2 in %3.']
- ifFalse:[
- "/ 'Found %1 file%2 in %3 (%4 files visited).'
- "/ 'Found %1 file%2 in %3 (%4 files visited; scanrate: %5/s).'
- 'Found %1 file%2 in %3 (%4 files visited; %6 files/s).'
- ])
- with:nFound
- with:(nFound == 1 ifTrue:'' ifFalse:'s')
- with:timeString
- with:filesSearchedCount
- with:(UnitConverter fileSizeSIStringFor:(bytesSearchedCount * 1000 / (timeMillis max:1)))
- with:((filesSearchedCount * 1000 / (timeMillis max:1)) asFixedPoint:1).
+
self enableStop value:false.
self enableSearch value:true.
self changeInformationTo:'Find File ' , '- done.' toTab:true.
+
+ message := self generateResultStringForTimeElapsed:timeElapsed.
].
] ensure:[
thisSearchTask == searchTask ifTrue:[