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