AbstractFileFinderApplicationComponent.st
branchjv
changeset 15566 184cea584be5
parent 13617 54baaac742d6
parent 15464 55f42d7909ef
child 15596 c11cc9c2974d
equal deleted inserted replaced
13752:25c2a13f00c5 15566:184cea584be5
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 2002 by eXept Software AG
     4  COPYRIGHT (c) 2002 by eXept Software AG
     3               All Rights Reserved
     5               All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
     9  other person.  No title to or ownership of the software is
    11  other person.  No title to or ownership of the software is
    10  hereby transferred.
    12  hereby transferred.
    11 "
    13 "
    12 "{ Package: 'stx:libtool' }"
    14 "{ Package: 'stx:libtool' }"
    13 
    15 
       
    16 "{ NameSpace: Smalltalk }"
       
    17 
    14 AbstractFileApplicationNoteBookComponent subclass:#AbstractFileFinderApplicationComponent
    18 AbstractFileApplicationNoteBookComponent subclass:#AbstractFileFinderApplicationComponent
    15 	instanceVariableNames:'findFileView searchResultTable resultList enableStop enableSearch
    19 	instanceVariableNames:'findFileView searchResultTable resultList enableStop enableSearch
    16 		stopSignal accessLock searchTask expanded searchRecursively
    20 		stopSignal accessLock searchTask expanded searchRecursively
    17 		selectionHolder hasListEntries targetApplication matchedFilesList
    21 		selectionHolder hasListEntries targetApplication matchedFilesList
    18 		shownListHolder autoSelectInBrowserHolder'
    22 		shownListHolder autoSelectInBrowserHolder filesSearchedCount'
    19 	classVariableNames:''
    23 	classVariableNames:''
    20 	poolDictionaries:''
    24 	poolDictionaries:''
    21 	category:'Interface-Tools-File'
    25 	category:'Interface-Tools-File'
    22 !
    26 !
    23 
    27 
   124 startSearchTask:aBlock name:taskName
   128 startSearchTask:aBlock name:taskName
   125     |thisSearchTask|
   129     |thisSearchTask|
   126 
   130 
   127     searchTask := thisSearchTask :=
   131     searchTask := thisSearchTask :=
   128         [
   132         [
   129             |message t|
   133             |message time nFound|
   130 
   134 
   131             [    
   135             [    
   132                 (self stopSignal) catch:[
   136                 (self stopSignal) catch:[
   133                     self enableStop value:true.
   137                     self enableStop value:true.
   134                     self resultList removeAll.
   138                     self resultList removeAll.
   135                     self matchedFilesList removeAll.
   139                     self matchedFilesList removeAll.
   136                     self notify:'Searching...'.
   140                     self notify:'Searching...'.
   137 
   141                     filesSearchedCount := 0.
   138 "/                    self changeInformationTo:'Find File ' , '- searching ' toTab:true.
   142 
   139                     t := Time millisecondsToRun:[
   143                     "/ self changeInformationTo:'Find File ' , '- searching ' toTab:true.
       
   144                     time := Time millisecondsToRun:[
   140                         aBlock value.
   145                         aBlock value.
   141                     ].
   146                     ].
   142                     t > 100 ifTrue:[
   147                     time > 100 ifTrue:[
   143                         t := ((t / 1000) asFixedPoint:2) printString , ' s'
   148                         time := ((time / 1000) asFixedPoint:2) printString , ' s'
   144                     ] ifFalse:[
   149                     ] ifFalse:[
   145                         t := t printString , ' ms'
   150                         time := time printString , ' ms'
   146                     ].
   151                     ].
   147                     message := 'Found %1 file%2 in %3.' bindWith:(resultList size) with:(resultList size == 1 ifTrue:'' ifFalse:'s') with:t.
   152                     nFound := resultList size.
       
   153                     message := resources 
       
   154                                     string:((nFound == filesSearchedCount) 
       
   155                                             ifTrue:['Found %1 file%2 in %3.'] 
       
   156                                             ifFalse:['Found %1 file%2 in %3 (%4 files visited).']) 
       
   157                                     with:nFound 
       
   158                                     with:(nFound == 1 ifTrue:'' ifFalse:'s') 
       
   159                                     with:time
       
   160                                     with:filesSearchedCount.
   148                     self enableStop value:false.
   161                     self enableStop value:false.
   149                     self enableSearch value:true.
   162                     self enableSearch value:true.
   150                     self changeInformationTo:'Find File ' , '- done.' toTab:true.
   163                     self changeInformationTo:'Find File ' , '- done.' toTab:true.
   151                 ].
   164                 ].
   152             ] ensure:[
   165             ] ensure:[
   156                     self notify:message.
   169                     self notify:message.
   157                 ].
   170                 ].
   158             ]
   171             ]
   159         ] newProcess.
   172         ] newProcess.
   160 
   173 
   161     searchTask priorityRange:(Processor systemBackgroundPriority to:Processor userSchedulingPriority).
   174     searchTask priorityRange:(Processor userBackgroundPriority to:Processor userSchedulingPriority).
   162     searchTask name:taskName.
   175     searchTask name:taskName.
   163     searchTask resume.
   176     searchTask resume.
   164     ^ searchTask
   177     ^ searchTask
   165 
   178 
   166     "Created: / 12-01-2012 / 01:52:17 / cg"
   179     "Created: / 12-01-2012 / 01:52:17 / cg"
   363         ^ self.
   376         ^ self.
   364     ].
   377     ].
   365     app notNil ifTrue:[
   378     app notNil ifTrue:[
   366         openedAppl := app openApplForFile:file.
   379         openedAppl := app openApplForFile:file.
   367         (openedAppl notNil and:[openedAppl isTextEditor]) ifTrue:[
   380         (openedAppl notNil and:[openedAppl isTextEditor]) ifTrue:[
   368             openedAppl window assignKeyboardFocusToFirstInputField.    "/ should this be done in openApplForFile?
   381             openedAppl window assignKeyboardFocusToFirstKeyboardConsumer.    "/ should this be done in openApplForFile?
   369             contentsPattern := self contentsPatternHolder value.
   382             contentsPattern := self contentsPatternHolder value.
   370             (contentsPattern notNil and:[ contentsPattern notEmpty and:[contentsPattern ~= '*']]) ifTrue:[
   383             (contentsPattern notNil and:[ contentsPattern notEmpty and:[contentsPattern ~= '*']]) ifTrue:[
   371                 openedAppl searchForPattern:contentsPattern ignoreCase:(self ignoreCaseInContents value).
   384                 openedAppl searchForPattern:contentsPattern ignoreCase:(self ignoreCaseInContents value).
   372             ]        
   385             ]        
   373         ].
   386         ].
   446 ! !
   459 ! !
   447 
   460 
   448 !AbstractFileFinderApplicationComponent methodsFor:'queries'!
   461 !AbstractFileFinderApplicationComponent methodsFor:'queries'!
   449 
   462 
   450 hasOneFileSelected
   463 hasOneFileSelected
   451     | sel |
   464     ^ self selectionHolder value size == 1
   452 
       
   453     sel := self selectionHolder value.
       
   454     ^ sel size == 1
       
   455 !
   465 !
   456 
   466 
   457 hasSelectionInResultList
   467 hasSelectionInResultList
   458     | sel |
   468     ^ self selectionHolder value notEmptyOrNil
   459 
   469 !
   460     sel := self selectionHolder value.
   470 
   461     ^ sel notEmptyOrNil
   471 hasTwoFilesSelected
       
   472     ^ self selectionHolder value size == 2
   462 ! !
   473 ! !
   463 
   474 
   464 !AbstractFileFinderApplicationComponent methodsFor:'tasks'!
   475 !AbstractFileFinderApplicationComponent methodsFor:'tasks'!
   465 
   476 
   466 stopSearchTaskOrAbort
   477 stopSearchTaskOrAbort
   477 ! !
   488 ! !
   478 
   489 
   479 !AbstractFileFinderApplicationComponent class methodsFor:'documentation'!
   490 !AbstractFileFinderApplicationComponent class methodsFor:'documentation'!
   480 
   491 
   481 version
   492 version
   482     ^ '$Header: /cvs/stx/stx/libtool/AbstractFileFinderApplicationComponent.st,v 1.11 2013-09-24 20:13:11 cg Exp $'
   493     ^ '$Header: /cvs/stx/stx/libtool/AbstractFileFinderApplicationComponent.st,v 1.16 2015-02-27 23:11:37 cg Exp $'
   483 !
   494 !
   484 
   495 
   485 version_CVS
   496 version_CVS
   486     ^ '$Header: /cvs/stx/stx/libtool/AbstractFileFinderApplicationComponent.st,v 1.11 2013-09-24 20:13:11 cg Exp $'
   497     ^ '$Header: /cvs/stx/stx/libtool/AbstractFileFinderApplicationComponent.st,v 1.16 2015-02-27 23:11:37 cg Exp $'
   487 !
   498 ! !
   488 
   499 
   489 version_HG
       
   490 
       
   491     ^ '$Changeset: <not expanded> $'
       
   492 !
       
   493 
       
   494 version_SVN
       
   495     ^ '$Id: AbstractFileFinderApplicationComponent.st 7854 2012-01-30 17:49:41Z vranyj1 $'
       
   496 ! !
       
   497