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