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 |
|
|
14 |
AbstractFileApplicationNoteBookComponent subclass:#AbstractFileFinderApplicationComponent
|
|
15 |
instanceVariableNames:'findFileView searchResultTable resultList enableStop enableSearch
|
|
16 |
stopSignal accessLock searchTask expanded searchRecursively
|
|
17 |
selectionHolder hasListEntries targetApplication matchedFilesList
|
|
18 |
shownListHolder autoSelectInBrowserHolder'
|
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Interface-Tools-File'
|
|
22 |
!
|
|
23 |
|
11095
|
24 |
!AbstractFileFinderApplicationComponent class methodsFor:'documentation'!
|
|
25 |
|
|
26 |
copyright
|
|
27 |
"
|
|
28 |
COPYRIGHT (c) 2002 by eXept Software AG
|
|
29 |
All Rights Reserved
|
|
30 |
|
|
31 |
This software is furnished under a license and may be used
|
|
32 |
only in accordance with the terms of that license and with the
|
|
33 |
inclusion of the above copyright notice. This software may not
|
|
34 |
be provided or otherwise made available to, or used by, any
|
|
35 |
other person. No title to or ownership of the software is
|
|
36 |
hereby transferred.
|
|
37 |
"
|
|
38 |
! !
|
|
39 |
|
|
40 |
!AbstractFileFinderApplicationComponent methodsFor:'accessing'!
|
|
41 |
|
|
42 |
accessLock
|
|
43 |
^ accessLock
|
|
44 |
!
|
|
45 |
|
|
46 |
stopSignal
|
|
47 |
|
|
48 |
stopSignal isNil ifTrue:[
|
|
49 |
stopSignal := Signal new.
|
|
50 |
].
|
|
51 |
^ stopSignal
|
|
52 |
!
|
|
53 |
|
|
54 |
targetApplication:anApplication
|
|
55 |
targetApplication := anApplication.
|
|
56 |
|
|
57 |
"Modified (format): / 11-01-2012 / 22:41:01 / cg"
|
|
58 |
! !
|
|
59 |
|
|
60 |
!AbstractFileFinderApplicationComponent methodsFor:'actions'!
|
|
61 |
|
|
62 |
changeInformationTo:aString
|
|
63 |
|
|
64 |
self changeInformationTo:aString toTab:false
|
|
65 |
!
|
|
66 |
|
|
67 |
changeInformationTo:aString toTab:aBoolean
|
|
68 |
masterApplication isNil ifTrue:[
|
|
69 |
findFileView label:aString
|
|
70 |
] ifFalse:[
|
|
71 |
aBoolean ifTrue:[
|
|
72 |
masterApplication tabStringChangeTo:aString for:self
|
|
73 |
] ifFalse:[
|
|
74 |
masterApplication notify:aString.
|
|
75 |
].
|
|
76 |
].
|
|
77 |
|
|
78 |
"Modified: / 03-08-2011 / 17:56:21 / cg"
|
|
79 |
!
|
|
80 |
|
|
81 |
clearShownList
|
|
82 |
self shownList removeAll.
|
|
83 |
!
|
|
84 |
|
|
85 |
copySelectedFileNamesToClipboard
|
|
86 |
|sel list stream|
|
|
87 |
|
|
88 |
sel := self selectionHolder value.
|
|
89 |
list := self shownList.
|
|
90 |
(sel notEmptyOrNil) ifTrue:[
|
|
91 |
stream := WriteStream on:''.
|
|
92 |
sel do:[: key |
|
|
93 |
stream nextPutAll:(list at:key).
|
|
94 |
stream cr.
|
|
95 |
].
|
|
96 |
self window setClipboardText:stream contents.
|
|
97 |
stream close.
|
|
98 |
].
|
|
99 |
!
|
|
100 |
|
|
101 |
openInNewBrowser
|
|
102 |
|sel|
|
|
103 |
|
|
104 |
sel := self selectionHolder value.
|
|
105 |
(sel notEmptyOrNil) ifTrue:[
|
|
106 |
FileBrowserV2 openOn:(self shownList at:sel first) asFilename
|
|
107 |
].
|
|
108 |
!
|
|
109 |
|
|
110 |
selectInBrowser
|
|
111 |
|sel entry application|
|
|
112 |
|
|
113 |
sel := self selectionHolder value.
|
|
114 |
(sel notEmptyOrNil) ifTrue:[
|
|
115 |
entry := self shownList at:sel first.
|
|
116 |
entry asFilename exists ifFalse:[ ^ self].
|
|
117 |
application := targetApplication ? self masterApplication.
|
|
118 |
application notNil ifTrue:[
|
|
119 |
application gotoFile:(entry asFilename).
|
|
120 |
].
|
|
121 |
].
|
|
122 |
!
|
|
123 |
|
|
124 |
stop
|
|
125 |
searchTask notNil ifTrue:[
|
|
126 |
accessLock critical:[
|
|
127 |
searchTask interruptWith:[stopSignal raiseRequest].
|
|
128 |
]
|
|
129 |
].
|
|
130 |
self enableStop value:false.
|
|
131 |
self enableSearch value:true.
|
|
132 |
self changeInformationTo:'Find File ' , '- search stopped' toTab:true.
|
|
133 |
|
|
134 |
"Modified: / 11-01-2012 / 22:42:07 / cg"
|
|
135 |
!
|
|
136 |
|
|
137 |
stopSearchTask
|
|
138 |
|task|
|
|
139 |
|
|
140 |
(task := searchTask) notNil ifTrue:[
|
|
141 |
searchTask := nil.
|
|
142 |
|
|
143 |
Object errorSignal handle:[:ex|
|
|
144 |
Dialog warn:ex description.
|
|
145 |
]do:[
|
|
146 |
task isDead ifFalse:[
|
|
147 |
task terminateWithAllSubprocessesInGroup.
|
|
148 |
task waitUntilTerminated.
|
|
149 |
]
|
|
150 |
]
|
|
151 |
].
|
|
152 |
! !
|
|
153 |
|
|
154 |
!AbstractFileFinderApplicationComponent methodsFor:'aspects'!
|
|
155 |
|
|
156 |
autoSelectInBrowserHolder
|
|
157 |
autoSelectInBrowserHolder isNil ifTrue:[
|
|
158 |
autoSelectInBrowserHolder := false asValue.
|
|
159 |
].
|
|
160 |
^ autoSelectInBrowserHolder.
|
|
161 |
!
|
|
162 |
|
|
163 |
enableSearch
|
|
164 |
|
|
165 |
enableSearch isNil ifTrue:[
|
|
166 |
enableSearch := true asValue.
|
|
167 |
].
|
|
168 |
^ enableSearch.
|
|
169 |
!
|
|
170 |
|
|
171 |
enableStop
|
|
172 |
|
|
173 |
enableStop isNil ifTrue:[
|
|
174 |
enableStop := true asValue.
|
|
175 |
].
|
|
176 |
^ enableStop.
|
|
177 |
!
|
|
178 |
|
|
179 |
hasListEntries
|
|
180 |
|
|
181 |
hasListEntries isNil ifTrue:[
|
|
182 |
hasListEntries := false asValue.
|
|
183 |
].
|
|
184 |
^ hasListEntries.
|
|
185 |
!
|
|
186 |
|
|
187 |
resultList
|
|
188 |
resultList isNil ifTrue:[
|
|
189 |
resultList := List new.
|
|
190 |
resultList addDependent:self.
|
|
191 |
].
|
|
192 |
^ resultList.
|
|
193 |
!
|
|
194 |
|
|
195 |
searchRecursively
|
|
196 |
|
|
197 |
searchRecursively isNil ifTrue:[
|
|
198 |
searchRecursively := true asValue.
|
|
199 |
].
|
|
200 |
^ searchRecursively.
|
|
201 |
!
|
|
202 |
|
|
203 |
searchResultTable
|
|
204 |
|
|
205 |
searchResultTable isNil ifTrue:[
|
|
206 |
searchResultTable := self class searchResultTable asValue.
|
|
207 |
].
|
|
208 |
^ searchResultTable.
|
|
209 |
!
|
|
210 |
|
|
211 |
selectionHolder
|
|
212 |
|
|
213 |
selectionHolder isNil ifTrue:[
|
|
214 |
selectionHolder := ValueHolder new.
|
|
215 |
selectionHolder addDependent:self.
|
|
216 |
].
|
|
217 |
^ selectionHolder
|
|
218 |
!
|
|
219 |
|
|
220 |
shownList
|
|
221 |
^ self shownListHolder valueHolder.
|
|
222 |
!
|
|
223 |
|
|
224 |
shownListHolder
|
|
225 |
shownListHolder isNil ifTrue:[
|
|
226 |
shownListHolder := IndirectValue for:(self resultList).
|
|
227 |
shownListHolder addDependent:self.
|
|
228 |
].
|
|
229 |
^ shownListHolder.
|
|
230 |
! !
|
|
231 |
|
|
232 |
!AbstractFileFinderApplicationComponent methodsFor:'change & update'!
|
|
233 |
|
|
234 |
update:something with:aParameter from:changedObject
|
|
235 |
changedObject == self shownListHolder ifTrue:[
|
|
236 |
self hasListEntries value:(changedObject valueHolder notEmpty).
|
|
237 |
^ self
|
|
238 |
].
|
|
239 |
changedObject == self selectionHolder ifTrue:[
|
|
240 |
self autoSelectInBrowser ifTrue:[
|
|
241 |
self selectInBrowser.
|
|
242 |
].
|
|
243 |
^ self
|
|
244 |
].
|
|
245 |
super update:something with:aParameter from:changedObject
|
|
246 |
! !
|
|
247 |
|
|
248 |
!AbstractFileFinderApplicationComponent methodsFor:'drag & drop'!
|
|
249 |
|
|
250 |
getDisplayObjects:anArgument
|
|
251 |
"retrieve the objects displayed during a drag"
|
|
252 |
|
|
253 |
| sel string size fnName stream|
|
|
254 |
|
|
255 |
sel := self selectionHolder value.
|
|
256 |
size := sel size.
|
|
257 |
size == 0 ifTrue:[^ ''].
|
|
258 |
|
|
259 |
stream := WriteStream on:''.
|
|
260 |
stream nextPutAll:((resultList at:sel first) asFilename baseName asString).
|
|
261 |
size == 1 ifTrue:[
|
|
262 |
fnName := 'ui_menuitem.xpm'.
|
|
263 |
] ifFalse:[
|
|
264 |
fnName := 'ui_submenu_open.xpm'.
|
|
265 |
stream nextPutAll:' ... '.
|
|
266 |
stream nextPutAll:((resultList at:sel last) asFilename baseName asString).
|
|
267 |
].
|
|
268 |
string := stream contents.
|
|
269 |
|
|
270 |
^ Array with:(LabelAndIcon
|
|
271 |
icon:(Image fromFile:fnName)
|
|
272 |
string:(Text string:string emphasis:#bold))
|
|
273 |
!
|
|
274 |
|
|
275 |
getDropObjects:anArgument
|
|
276 |
"common code, used in subclasses"
|
|
277 |
|
|
278 |
|sel|
|
|
279 |
|
|
280 |
sel := self selectionHolder value.
|
|
281 |
^ sel
|
|
282 |
collect:[:idx|
|
|
283 |
|el|
|
|
284 |
|
|
285 |
el := resultList at:idx.
|
|
286 |
DropObject newFile:(el asFilename)
|
|
287 |
].
|
|
288 |
! !
|
|
289 |
|
|
290 |
!AbstractFileFinderApplicationComponent methodsFor:'event handling'!
|
|
291 |
|
|
292 |
fileDoubleClick:entries
|
|
293 |
|file fn app openedAppl contentsPattern|
|
|
294 |
|
|
295 |
file := self shownList at:entries first.
|
|
296 |
fn := file asFilename.
|
|
297 |
fn exists ifFalse:[
|
|
298 |
Dialog warn:('File %1 does not (no longer ?) exist.' bindWith:file allBold).
|
|
299 |
^ self
|
|
300 |
].
|
|
301 |
|
|
302 |
app := targetApplication ? self masterApplication.
|
|
303 |
file asFilename isDirectory ifTrue:[
|
|
304 |
app gotoFile:(file asFilename).
|
|
305 |
^ self.
|
|
306 |
].
|
|
307 |
app notNil ifTrue:[
|
|
308 |
openedAppl := app openApplForFile:file.
|
|
309 |
(openedAppl notNil and:[openedAppl isTextEditor]) ifTrue:[
|
|
310 |
contentsPattern := self contentsPatternHolder value.
|
|
311 |
(contentsPattern notNil and:[ contentsPattern notEmpty and:[contentsPattern ~= '*']]) ifTrue:[
|
|
312 |
openedAppl searchForPattern:contentsPattern ignoreCase:(self ignoreCaseInContents value).
|
|
313 |
]
|
|
314 |
].
|
|
315 |
] ifFalse:[
|
|
316 |
self openInNewBrowser.
|
|
317 |
]
|
|
318 |
!
|
|
319 |
|
|
320 |
fileSelected:entries
|
|
321 |
|file fn|
|
|
322 |
|
|
323 |
entries isEmptyOrNil ifTrue:[^ self].
|
|
324 |
|
|
325 |
file := self shownList at:entries first.
|
|
326 |
file isText ifTrue:[^ self].
|
|
327 |
|
|
328 |
fn := file asFilename.
|
|
329 |
fn exists ifFalse:[
|
|
330 |
self notify:('%1 does not (no longer ?) exist or is not accessable.' bindWith:file allBold).
|
|
331 |
^ self
|
|
332 |
].
|
|
333 |
fn isDirectory ifTrue:[
|
|
334 |
self notify:nil.
|
|
335 |
^ self.
|
|
336 |
].
|
|
337 |
|
|
338 |
self notify:('%1: %2.' bindWith:fn baseName allBold with:(UnitConverter fileSizeStringFor:fn fileSize)).
|
|
339 |
|
|
340 |
"Created: / 04-07-2006 / 11:35:38 / cg"
|
|
341 |
!
|
|
342 |
|
|
343 |
processEvent:anEvent
|
|
344 |
"filter keyboard events.
|
|
345 |
Return true, if I have eaten the event"
|
|
346 |
|
|
347 |
|focusView key rawKey|
|
|
348 |
|
|
349 |
anEvent isKeyPressEvent ifTrue:[
|
|
350 |
focusView := anEvent targetView.
|
|
351 |
key := anEvent key.
|
|
352 |
rawKey := anEvent rawKey.
|
|
353 |
|
|
354 |
(focusView isSameOrComponentOf:self window) ifTrue:[
|
|
355 |
(key == #Return) ifTrue:[
|
|
356 |
(focusView name ~= 'selectionInListView') ifTrue:[
|
|
357 |
self doSearch.
|
|
358 |
] ifFalse:[
|
|
359 |
self hasOneFileSelected ifTrue:[
|
|
360 |
self fileDoubleClick:(self selectionHolder value)
|
|
361 |
"/ self isEmbeddedApplication ifTrue:[
|
|
362 |
"/ self selectInBrowser.
|
|
363 |
"/ ] ifFalse:[
|
|
364 |
"/ self openInNewBrowser.
|
|
365 |
"/ ]
|
|
366 |
]
|
|
367 |
].
|
|
368 |
^ true
|
|
369 |
].
|
|
370 |
]
|
|
371 |
].
|
|
372 |
^ false
|
|
373 |
! !
|
|
374 |
|
|
375 |
!AbstractFileFinderApplicationComponent methodsFor:'initialization'!
|
|
376 |
|
|
377 |
initialize
|
|
378 |
super initialize.
|
|
379 |
accessLock := Semaphore forMutualExclusion name:'accessLock'.
|
|
380 |
! !
|
|
381 |
|
|
382 |
!AbstractFileFinderApplicationComponent methodsFor:'queries'!
|
|
383 |
|
|
384 |
hasOneFileSelected
|
|
385 |
| sel |
|
|
386 |
sel := self selectionHolder value.
|
|
387 |
^ (sel notNil and:[sel notEmpty and:[sel size = 1]])
|
|
388 |
!
|
|
389 |
|
|
390 |
hasSelectionInResultList
|
|
391 |
| sel |
|
|
392 |
|
|
393 |
sel := self selectionHolder value.
|
|
394 |
^ sel notEmptyOrNil
|
|
395 |
! !
|
11087
|
396 |
|
|
397 |
!AbstractFileFinderApplicationComponent class methodsFor:'documentation'!
|
|
398 |
|
|
399 |
version
|
11095
|
400 |
^ '$Header: /cvs/stx/stx/libtool/AbstractFileFinderApplicationComponent.st,v 1.2 2012-01-11 21:53:39 cg Exp $'
|
11087
|
401 |
!
|
|
402 |
|
|
403 |
version_CVS
|
11095
|
404 |
^ '$Header: /cvs/stx/stx/libtool/AbstractFileFinderApplicationComponent.st,v 1.2 2012-01-11 21:53:39 cg Exp $'
|
11087
|
405 |
! !
|