AbstractFileFinderApplicationComponent.st
author mawalch
Wed, 27 Jan 2016 16:52:52 +0100
changeset 16083 58a6d244e081
parent 15590 9723cf906e2c
child 16093 a0705d7461fd
child 16199 e2b5484e3467
permissions -rw-r--r--
typo
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
     1
"
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
     2
 COPYRIGHT (c) 2002 by eXept Software AG
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
     3
              All Rights Reserved
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
     4
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
     5
 This software is furnished under a license and may be used
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
     6
 only in accordance with the terms of that license and with the
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
     8
 be provided or otherwise made available to, or used by, any
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
     9
 other person.  No title to or ownership of the software is
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    10
 hereby transferred.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    11
"
11087
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libtool' }"
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
15213
755820fee87e class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 13579
diff changeset
    14
"{ NameSpace: Smalltalk }"
755820fee87e class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 13579
diff changeset
    15
11087
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
AbstractFileApplicationNoteBookComponent subclass:#AbstractFileFinderApplicationComponent
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:'findFileView searchResultTable resultList enableStop enableSearch
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
		stopSignal accessLock searchTask expanded searchRecursively
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
		selectionHolder hasListEntries targetApplication matchedFilesList
15216
142df293a6c2 class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15213
diff changeset
    20
		shownListHolder autoSelectInBrowserHolder filesSearchedCount'
11087
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	classVariableNames:''
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	poolDictionaries:''
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
	category:'Interface-Tools-File'
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    26
!AbstractFileFinderApplicationComponent class methodsFor:'documentation'!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    27
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    28
copyright
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    29
"
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    30
 COPYRIGHT (c) 2002 by eXept Software AG
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    31
              All Rights Reserved
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    32
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    33
 This software is furnished under a license and may be used
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    34
 only in accordance with the terms of that license and with the
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    35
 inclusion of the above copyright notice.   This software may not
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    36
 be provided or otherwise made available to, or used by, any
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    37
 other person.  No title to or ownership of the software is
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    38
 hereby transferred.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    39
"
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    40
! !
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    41
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    42
!AbstractFileFinderApplicationComponent methodsFor:'accessing'!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    43
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    44
accessLock
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    45
    ^ accessLock
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    46
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    47
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    48
stopSignal
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    49
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    50
    stopSignal isNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    51
        stopSignal := Signal new.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    52
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    53
    ^ stopSignal
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    54
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    55
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    56
targetApplication:anApplication
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    57
    targetApplication := anApplication.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    58
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    59
    "Modified (format): / 11-01-2012 / 22:41:01 / cg"
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    60
! !
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    61
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    62
!AbstractFileFinderApplicationComponent methodsFor:'actions'!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    63
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    64
changeInformationTo:aString
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    65
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    66
    self changeInformationTo:aString toTab:false
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    67
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    68
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    69
changeInformationTo:aString toTab:aBoolean
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    70
    masterApplication isNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    71
        findFileView label:aString
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    72
    ] ifFalse:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    73
        aBoolean ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    74
            masterApplication tabStringChangeTo:aString for:self
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    75
        ] ifFalse:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    76
            masterApplication notify:aString.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    77
        ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    78
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    79
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    80
    "Modified: / 03-08-2011 / 17:56:21 / cg"
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    81
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    82
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    83
clearShownList
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    84
    self shownList removeAll.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    85
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    86
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    87
copySelectedFileNamesToClipboard
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    88
    |sel list stream|
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    89
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    90
    sel := self selectionHolder value.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    91
    list := self shownList.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    92
    (sel notEmptyOrNil) ifTrue:[
15590
9723cf906e2c class: AbstractFileFinderApplicationComponent
Stefan Vogel <sv@exept.de>
parents: 15464
diff changeset
    93
        stream := CharacterWriteStream new.
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    94
        sel do:[: key |
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    95
            stream nextPutAll:(list at:key).
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    96
            stream cr.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    97
        ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    98
        self window setClipboardText:stream contents.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
    99
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   100
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   101
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   102
openInNewBrowser
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   103
    |sel|
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   104
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   105
    sel := self selectionHolder value.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   106
    (sel notEmptyOrNil) ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   107
        FileBrowserV2 openOn:(self shownList at:sel first) asFilename
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   108
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   109
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   110
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   111
selectInBrowser
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   112
    |sel entry application|
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   113
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   114
    sel := self selectionHolder value.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   115
    (sel notEmptyOrNil) ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   116
        entry := self shownList at:sel first.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   117
        entry asFilename exists ifFalse:[ ^ self].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   118
        application := targetApplication ? self masterApplication.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   119
        application notNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   120
            application gotoFile:(entry asFilename).
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   121
        ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   122
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   123
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   124
11102
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   125
startSearchTask:aBlock name:taskName
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   126
    |thisSearchTask|
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   127
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   128
    searchTask := thisSearchTask :=
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   129
        [
15224
cb081e8c2abf class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15216
diff changeset
   130
            |message time nFound|
11102
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   131
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   132
            [    
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   133
                (self stopSignal) catch:[
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   134
                    self enableStop value:true.
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   135
                    self resultList removeAll.
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   136
                    self matchedFilesList removeAll.
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   137
                    self notify:'Searching...'.
15216
142df293a6c2 class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15213
diff changeset
   138
                    filesSearchedCount := 0.
11102
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   139
15216
142df293a6c2 class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15213
diff changeset
   140
                    "/ self changeInformationTo:'Find File ' , '- searching ' toTab:true.
142df293a6c2 class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15213
diff changeset
   141
                    time := Time millisecondsToRun:[
11102
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   142
                        aBlock value.
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   143
                    ].
15216
142df293a6c2 class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15213
diff changeset
   144
                    time > 100 ifTrue:[
142df293a6c2 class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15213
diff changeset
   145
                        time := ((time / 1000) asFixedPoint:2) printString , ' s'
11102
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   146
                    ] ifFalse:[
15216
142df293a6c2 class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15213
diff changeset
   147
                        time := time printString , ' ms'
11102
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   148
                    ].
15224
cb081e8c2abf class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15216
diff changeset
   149
                    nFound := resultList size.
15216
142df293a6c2 class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15213
diff changeset
   150
                    message := resources 
15224
cb081e8c2abf class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15216
diff changeset
   151
                                    string:((nFound == filesSearchedCount) 
cb081e8c2abf class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15216
diff changeset
   152
                                            ifTrue:['Found %1 file%2 in %3.'] 
cb081e8c2abf class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15216
diff changeset
   153
                                            ifFalse:['Found %1 file%2 in %3 (%4 files visited).']) 
cb081e8c2abf class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15216
diff changeset
   154
                                    with:nFound 
cb081e8c2abf class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15216
diff changeset
   155
                                    with:(nFound == 1 ifTrue:'' ifFalse:'s') 
15216
142df293a6c2 class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15213
diff changeset
   156
                                    with:time
142df293a6c2 class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15213
diff changeset
   157
                                    with:filesSearchedCount.
11102
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   158
                    self enableStop value:false.
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   159
                    self enableSearch value:true.
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   160
                    self changeInformationTo:'Find File ' , '- done.' toTab:true.
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   161
                ].
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   162
            ] ensure:[
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   163
                thisSearchTask == searchTask ifTrue:[
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   164
                    searchTask := nil.
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   165
                    self enableStop value:false.
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   166
                    self notify:message.
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   167
                ].
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   168
            ]
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   169
        ] newProcess.
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   170
15464
55f42d7909ef class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15410
diff changeset
   171
    searchTask priorityRange:(Processor userBackgroundPriority to:Processor userSchedulingPriority).
11102
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   172
    searchTask name:taskName.
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   173
    searchTask resume.
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   174
    ^ searchTask
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   175
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   176
    "Created: / 12-01-2012 / 01:52:17 / cg"
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   177
!
4a79fb29bdd1 added: #startSearchTask:name:
Claus Gittinger <cg@exept.de>
parents: 11100
diff changeset
   178
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   179
stop
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   180
    searchTask notNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   181
        accessLock critical:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   182
            searchTask interruptWith:[stopSignal raiseRequest].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   183
        ]
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   184
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   185
    self enableStop value:false.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   186
    self enableSearch value:true.
12338
2b456eb16d5d class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 12112
diff changeset
   187
    self changeInformationTo:'Find File ' , '- search stopped.' toTab:true.
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   188
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   189
    "Modified: / 11-01-2012 / 22:42:07 / cg"
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   190
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   191
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   192
stopSearchTask
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   193
    |task|
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   194
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   195
    (task := searchTask) notNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   196
        searchTask := nil.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   197
12724
941f46a7d28d exception access
Claus Gittinger <cg@exept.de>
parents: 12565
diff changeset
   198
        Error handle:[:ex|
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   199
            Dialog warn:ex description.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   200
        ]do:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   201
            task isDead ifFalse:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   202
                task terminateWithAllSubprocessesInGroup.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   203
                task waitUntilTerminated.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   204
            ]
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   205
        ]
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   206
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   207
! !
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   208
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   209
!AbstractFileFinderApplicationComponent methodsFor:'aspects'!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   210
11118
6d72314eb4df added: #autoSelectInBrowser
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   211
autoSelectInBrowser
6d72314eb4df added: #autoSelectInBrowser
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   212
    ^ self autoSelectInBrowserHolder value.
6d72314eb4df added: #autoSelectInBrowser
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   213
!
6d72314eb4df added: #autoSelectInBrowser
Claus Gittinger <cg@exept.de>
parents: 11107
diff changeset
   214
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   215
autoSelectInBrowserHolder
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   216
    autoSelectInBrowserHolder isNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   217
        autoSelectInBrowserHolder := false asValue.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   218
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   219
    ^ autoSelectInBrowserHolder.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   220
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   221
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   222
enableSearch
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   223
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   224
    enableSearch isNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   225
        enableSearch := true asValue.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   226
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   227
    ^ enableSearch.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   228
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   229
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   230
enableStop
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   231
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   232
    enableStop isNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   233
        enableStop := true asValue.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   234
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   235
    ^ enableStop.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   236
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   237
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   238
hasListEntries
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   239
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   240
    hasListEntries isNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   241
        hasListEntries := false asValue.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   242
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   243
    ^ hasListEntries.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   244
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   245
11107
17342ca15467 added: #matchedFilesList
Claus Gittinger <cg@exept.de>
parents: 11102
diff changeset
   246
matchedFilesList
17342ca15467 added: #matchedFilesList
Claus Gittinger <cg@exept.de>
parents: 11102
diff changeset
   247
17342ca15467 added: #matchedFilesList
Claus Gittinger <cg@exept.de>
parents: 11102
diff changeset
   248
    matchedFilesList isNil ifTrue:[
17342ca15467 added: #matchedFilesList
Claus Gittinger <cg@exept.de>
parents: 11102
diff changeset
   249
        matchedFilesList := List new.
17342ca15467 added: #matchedFilesList
Claus Gittinger <cg@exept.de>
parents: 11102
diff changeset
   250
        matchedFilesList addDependent:self.
17342ca15467 added: #matchedFilesList
Claus Gittinger <cg@exept.de>
parents: 11102
diff changeset
   251
    ].
17342ca15467 added: #matchedFilesList
Claus Gittinger <cg@exept.de>
parents: 11102
diff changeset
   252
    ^ matchedFilesList.
17342ca15467 added: #matchedFilesList
Claus Gittinger <cg@exept.de>
parents: 11102
diff changeset
   253
!
17342ca15467 added: #matchedFilesList
Claus Gittinger <cg@exept.de>
parents: 11102
diff changeset
   254
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   255
resultList
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   256
    resultList isNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   257
        resultList := List new.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   258
        resultList addDependent:self.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   259
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   260
    ^ resultList.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   261
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   262
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   263
searchRecursively
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   264
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   265
    searchRecursively isNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   266
        searchRecursively := true asValue.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   267
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   268
    ^ searchRecursively.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   269
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   270
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   271
searchResultTable
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   272
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   273
    searchResultTable isNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   274
        searchResultTable := self class searchResultTable asValue.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   275
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   276
    ^ searchResultTable.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   277
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   278
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   279
selectionHolder
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   280
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   281
    selectionHolder isNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   282
        selectionHolder := ValueHolder new.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   283
        selectionHolder addDependent:self.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   284
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   285
    ^ selectionHolder
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   286
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   287
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   288
shownList
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   289
    ^ self shownListHolder valueHolder.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   290
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   291
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   292
shownListHolder
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   293
    shownListHolder isNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   294
        shownListHolder := IndirectValue for:(self resultList).
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   295
        shownListHolder addDependent:self.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   296
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   297
    ^ shownListHolder.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   298
! !
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   299
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   300
!AbstractFileFinderApplicationComponent methodsFor:'change & update'!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   301
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   302
update:something with:aParameter from:changedObject
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   303
    changedObject == self shownListHolder ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   304
        self hasListEntries value:(changedObject valueHolder notEmpty).
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   305
        ^ self
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   306
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   307
    changedObject == self selectionHolder ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   308
        self autoSelectInBrowser ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   309
            self selectInBrowser.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   310
        ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   311
        ^ self
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   312
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   313
    super update:something with:aParameter from:changedObject
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   314
! !
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   315
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   316
!AbstractFileFinderApplicationComponent methodsFor:'drag & drop'!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   317
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   318
getDisplayObjects:anArgument
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   319
    "retrieve the objects displayed during a drag"
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   320
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   321
    | sel string size fnName stream|
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   322
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   323
    sel := self selectionHolder value.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   324
    size := sel size.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   325
    size == 0  ifTrue:[^ ''].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   326
15590
9723cf906e2c class: AbstractFileFinderApplicationComponent
Stefan Vogel <sv@exept.de>
parents: 15464
diff changeset
   327
    stream := CharacterWriteStream with:((resultList at:sel first) asFilename baseName asString).
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   328
    size == 1 ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   329
        fnName := 'ui_menuitem.xpm'.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   330
    ] ifFalse:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   331
        fnName := 'ui_submenu_open.xpm'.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   332
        stream nextPutAll:' ... '.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   333
        stream nextPutAll:((resultList at:sel last) asFilename baseName asString).
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   334
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   335
    string := stream contents.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   336
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   337
    ^ Array with:(LabelAndIcon 
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   338
                    icon:(Image fromFile:fnName)
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   339
                    string:(Text string:string emphasis:#bold))
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   340
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   341
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   342
getDropObjects:anArgument
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   343
    "common code, used in subclasses"
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   344
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   345
    |sel|
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   346
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   347
    sel := self selectionHolder value.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   348
    ^ sel 
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   349
        collect:[:idx|
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   350
            |el|
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   351
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   352
            el := resultList at:idx.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   353
            DropObject newFile:(el asFilename) 
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   354
        ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   355
! !
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   356
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   357
!AbstractFileFinderApplicationComponent methodsFor:'event handling'!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   358
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   359
fileDoubleClick:entries
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   360
    |file fn app openedAppl contentsPattern|
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   361
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   362
    file := self shownList at:entries first.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   363
    fn := file asFilename.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   364
    fn exists ifFalse:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   365
        Dialog warn:('File %1 does not (no longer ?) exist.' bindWith:file allBold).
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   366
        ^ self
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   367
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   368
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   369
    app := targetApplication ? self masterApplication.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   370
    file asFilename isDirectory ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   371
        app gotoFile:(file asFilename).
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   372
        ^ self.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   373
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   374
    app notNil ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   375
        openedAppl := app openApplForFile:file.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   376
        (openedAppl notNil and:[openedAppl isTextEditor]) ifTrue:[
15410
45582dc314d5 class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 15224
diff changeset
   377
            openedAppl window assignKeyboardFocusToFirstKeyboardConsumer.    "/ should this be done in openApplForFile?
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   378
            contentsPattern := self contentsPatternHolder value.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   379
            (contentsPattern notNil and:[ contentsPattern notEmpty and:[contentsPattern ~= '*']]) ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   380
                openedAppl searchForPattern:contentsPattern ignoreCase:(self ignoreCaseInContents value).
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   381
            ]        
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   382
        ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   383
    ] ifFalse:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   384
        self openInNewBrowser.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   385
    ]
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   386
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   387
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   388
fileSelected:entries
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   389
    |file fn|
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   390
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   391
    entries isEmptyOrNil ifTrue:[^ self].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   392
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   393
    file := self shownList at:entries first.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   394
    file isText ifTrue:[^ self].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   395
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   396
    fn := file asFilename.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   397
    fn exists ifFalse:[
16083
mawalch
parents: 15590
diff changeset
   398
        self notify:('%1 does not (no longer ?) exist or is not accessible.' bindWith:file allBold).
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   399
        ^ self
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   400
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   401
    fn isDirectory ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   402
        self notify:nil.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   403
        ^ self.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   404
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   405
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   406
    self notify:('%1: %2.' bindWith:fn baseName allBold with:(UnitConverter fileSizeStringFor:fn fileSize)).
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   407
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   408
    "Created: / 04-07-2006 / 11:35:38 / cg"
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   409
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   410
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   411
processEvent:anEvent
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   412
    "filter keyboard events.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   413
     Return true, if I have eaten the event"
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   414
12112
0012158092fb changed: #processEvent:
Claus Gittinger <cg@exept.de>
parents: 11118
diff changeset
   415
    <resource: #keyboard (#Return )>
0012158092fb changed: #processEvent:
Claus Gittinger <cg@exept.de>
parents: 11118
diff changeset
   416
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   417
    |focusView key rawKey|
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   418
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   419
    anEvent isKeyPressEvent ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   420
        focusView := anEvent targetView.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   421
        key := anEvent key.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   422
        rawKey := anEvent rawKey.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   423
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   424
        (focusView isSameOrComponentOf:self window) ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   425
            (key == #Return) ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   426
                (focusView name ~= 'selectionInListView') ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   427
                    self doSearch.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   428
                ] ifFalse:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   429
                    self hasOneFileSelected ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   430
                        self fileDoubleClick:(self selectionHolder value)
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   431
"/                        self isEmbeddedApplication ifTrue:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   432
"/                            self selectInBrowser.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   433
"/                        ] ifFalse:[
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   434
"/                            self openInNewBrowser.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   435
"/                        ]
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   436
                    ]
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   437
                ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   438
                ^ true
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   439
            ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   440
        ]
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   441
    ].
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   442
    ^ false
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   443
! !
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   444
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   445
!AbstractFileFinderApplicationComponent methodsFor:'initialization'!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   446
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   447
initialize
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   448
    super initialize.
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   449
    accessLock := Semaphore forMutualExclusion name:'accessLock'.
11100
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   450
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   451
    self enableStop value:false.
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   452
    self enableSearch value:true.
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   453
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   454
    "Modified: / 12-01-2012 / 01:39:27 / cg"
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   455
! !
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   456
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   457
!AbstractFileFinderApplicationComponent methodsFor:'queries'!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   458
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   459
hasOneFileSelected
15213
755820fee87e class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 13579
diff changeset
   460
    ^ self selectionHolder value size == 1
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   461
!
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   462
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   463
hasSelectionInResultList
15213
755820fee87e class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 13579
diff changeset
   464
    ^ self selectionHolder value notEmptyOrNil
755820fee87e class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 13579
diff changeset
   465
!
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   466
15213
755820fee87e class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 13579
diff changeset
   467
hasTwoFilesSelected
755820fee87e class: AbstractFileFinderApplicationComponent
Claus Gittinger <cg@exept.de>
parents: 13579
diff changeset
   468
    ^ self selectionHolder value size == 2
11095
5bdf656a8a2a refactored
Claus Gittinger <cg@exept.de>
parents: 11087
diff changeset
   469
! !
11087
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
11100
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   471
!AbstractFileFinderApplicationComponent methodsFor:'tasks'!
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   472
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   473
stopSearchTaskOrAbort
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   474
    searchTask isNil ifTrue:[ ^ self ].
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   475
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   476
    (Dialog 
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   477
            confirm:(resources stringWithCRs:'There is already another find-file task running !!')
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   478
            yesLabel:(resources string:'Stop other Task and Proceed')
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   479
            noLabel:(resources string:'Cancel'))
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   480
        ifFalse:[AbortSignal raise].
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   481
    self stop.
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   482
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   483
    "Created: / 12-01-2012 / 01:48:42 / cg"
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   484
! !
4782ef32a188 refactored for better reuse in directory-diff
Claus Gittinger <cg@exept.de>
parents: 11095
diff changeset
   485
11087
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
!AbstractFileFinderApplicationComponent class methodsFor:'documentation'!
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
version
16083
mawalch
parents: 15590
diff changeset
   489
    ^ '$Header$'
11087
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
!
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
version_CVS
16083
mawalch
parents: 15590
diff changeset
   493
    ^ '$Header$'
11087
4abf0b5e0109 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
! !
12112
0012158092fb changed: #processEvent:
Claus Gittinger <cg@exept.de>
parents: 11118
diff changeset
   495