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