diff -r 4782ef32a188 -r 34affbf84319 FindFileApplication.st --- a/FindFileApplication.st Thu Jan 12 01:58:48 2012 +0100 +++ b/FindFileApplication.st Thu Jan 12 02:01:48 2012 +0100 @@ -607,6 +607,7 @@ "Do not manually edit this!! If it is corrupted, the MenuEditor may not be able to read the specification." + " MenuEditor new openOnClass:FindFileApplication andSelector:#searchMenu (Menu new fromLiteralArrayEncoding:(FindFileApplication searchMenu)) startUp @@ -639,6 +640,7 @@ translateLabel: true isButton: true startGroup: right + isVisible: false labelImage: (ResourceRetriever ToolbarIconLibrary removeTabIcon) ) ) @@ -737,8 +739,7 @@ ! doSearch - |namePatterns excludedNamePatterns contentsPattern notContentsPattern dir fileToCompareAgainst thisSearchTask - ignoreCaseInName ignoreCaseInExcludedName ignoreCaseInContents| + |namePatterns excludedNamePatterns contentsPattern notContentsPattern dir fileToCompareAgainst ignoreCaseInName ignoreCaseInExcludedName ignoreCaseInContents| "/ self changeExtentToSeeSearchResult. @@ -756,14 +757,7 @@ LastSearchIgnoredCaseInExcludedFilename := ignoreCaseInExcludedName := self ignoreCaseInExcludedName value. LastSearchIgnoredCaseInContents := ignoreCaseInContents := self ignoreCaseInContents value. - searchTask notNil ifTrue:[ - (Dialog - confirm:(resources stringWithCRs:'There is already another find-file task running !!') - yesLabel:(resources string:'Stop other Task and Proceed') - noLabel:(resources string:'Cancel')) - ifFalse:[^ self]. - self stop. - ]. + self stopSearchTaskOrAbort. namePatterns := self namePatternsFor:(self namePatternHolder value) ignoringCase:ignoreCaseInName. excludedNamePatterns := self namePatternsFor:(self excludedNamePatternHolder value) ignoringCase:ignoreCaseInExcludedName. @@ -803,58 +797,27 @@ ]. ]. - searchTask := thisSearchTask := - [ - |message t| - - [ - (self stopSignal) catch:[ - self enableStop value:true. - self resultList removeAll. - self matchedFilesList removeAll. - self changeInformationTo:'Find File ' , '- searching ' toTab:true. - self notify:'Searching...'. - t := Time millisecondsToRun:[ + self + startSearchTask:[ + self changeInformationTo:'Find File ' , '- searching ' toTab:true. + self + doFindFileNamed:namePatterns + directories:(self searchDirectories value) + ignoreCaseInName:ignoreCaseInName + excludeFilesNamed:excludedNamePatterns + ignoreCaseInExcludedName:ignoreCaseInExcludedName + containingString:contentsPattern + ignoreCaseInContents:ignoreCaseInContents + notContainingString:notContentsPattern + ignoreCaseInNotContents:(self ignoreCaseInNotContents value) + sameContentsAsFile:fileToCompareAgainst + sameContentsAs:nil + in:(self searchDirectoryHolder value). - self - doFindFileNamed:namePatterns - directories:(self searchDirectories value) - ignoreCaseInName:ignoreCaseInName - excludeFilesNamed:excludedNamePatterns - ignoreCaseInExcludedName:ignoreCaseInExcludedName - containingString:contentsPattern - ignoreCaseInContents:ignoreCaseInContents - notContainingString:notContentsPattern - ignoreCaseInNotContents:(self ignoreCaseInNotContents value) - sameContentsAsFile:fileToCompareAgainst - sameContentsAs:nil - in:(self searchDirectoryHolder value). + ] + name:('FindFile[', self searchDirectoryHolder value asFilename baseName, ']') - ]. - 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:('FindFile[', self searchDirectoryHolder value asFilename baseName, ']'). - searchTask resume. - - "Modified: / 03-08-2011 / 18:20:34 / cg" + "Modified: / 12-01-2012 / 01:54:27 / cg" ! fileInInBrowser @@ -907,6 +870,51 @@ ] ifFalse:[ self shownListHolder valueHolder:(self resultList) ]. +! + +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" ! ! !FindFileApplication methodsFor:'aspects'! @@ -1679,6 +1687,15 @@ !FindFileApplication methodsFor:'startup & release'! +initialize + super initialize. + + self enableStop value:false. + self enableSearch value:true. + + "Created: / 12-01-2012 / 01:38:29 / cg" +! + item:anItem |file newPattern| @@ -1694,19 +1711,20 @@ newPattern := '*.', anItem suffix. ]. self namePatternHolder value:newPattern. - self enableStop value:false. - self enableSearch value:true. ^ true. + + "Modified: / 12-01-2012 / 01:38:14 / cg" ! postOpenWith:aBuilder - self masterApplication isNil ifTrue:[ self masterApplication:nil. ]. findFileView := aBuilder window. self windowGroup addPreEventHook:self. super postOpenWith:aBuilder. + + "Modified (format): / 12-01-2012 / 01:40:44 / cg" ! release @@ -1718,9 +1736,9 @@ !FindFileApplication class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.95 2012-01-11 22:34:09 cg Exp $' + ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.96 2012-01-12 01:01:48 cg Exp $' ! version_CVS - ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.95 2012-01-11 22:34:09 cg Exp $' + ^ '$Header: /cvs/stx/stx/libtool/FindFileApplication.st,v 1.96 2012-01-12 01:01:48 cg Exp $' ! !