AbstractFileFinderApplicationComponent.st
changeset 11102 4a79fb29bdd1
parent 11100 4782ef32a188
child 11107 17342ca15467
--- a/AbstractFileFinderApplicationComponent.st	Thu Jan 12 02:01:48 2012 +0100
+++ b/AbstractFileFinderApplicationComponent.st	Thu Jan 12 02:07:34 2012 +0100
@@ -121,6 +121,51 @@
     ].
 !
 
+startSearchTask:aBlock name:taskName
+    |thisSearchTask|
+
+    searchTask := thisSearchTask :=
+        [
+            |message t|
+
+            [    
+                (self stopSignal) catch:[
+                    self enableStop value:true.
+                    self resultList removeAll.
+                    self matchedFilesList removeAll.
+                    self notify:'Searching...'.
+
+"/                    self changeInformationTo:'Find File ' , '- searching ' toTab:true.
+                    t := Time millisecondsToRun:[
+                        aBlock value.
+                    ].
+                    t > 100 ifTrue:[
+                        t := ((t / 1000) asFixedPoint:2) printString , ' s'
+                    ] ifFalse:[
+                        t := t printString , ' ms'
+                    ].
+                    message := 'Found %1 file%2 in %3' bindWith:(resultList size) with:(resultList size == 1 ifTrue:'' ifFalse:'s') with:t.
+                    self enableStop value:false.
+                    self enableSearch value:true.
+                    self changeInformationTo:'Find File ' , '- done.' toTab:true.
+                ].
+            ] ensure:[
+                thisSearchTask == searchTask ifTrue:[
+                    searchTask := nil.
+                    self enableStop value:false.
+                    self notify:message.
+                ].
+            ]
+        ] newProcess.
+
+    searchTask priorityRange:(Processor systemBackgroundPriority to:Processor userSchedulingPriority).
+    searchTask name:taskName.
+    searchTask resume.
+    ^ searchTask
+
+    "Created: / 12-01-2012 / 01:52:17 / cg"
+!
+
 stop
     searchTask notNil ifTrue:[
         accessLock critical:[
@@ -417,9 +462,9 @@
 !AbstractFileFinderApplicationComponent class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileFinderApplicationComponent.st,v 1.3 2012-01-12 00:58:48 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileFinderApplicationComponent.st,v 1.4 2012-01-12 01:07:34 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileFinderApplicationComponent.st,v 1.3 2012-01-12 00:58:48 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileFinderApplicationComponent.st,v 1.4 2012-01-12 01:07:34 cg Exp $'
 ! !