author | penk |
Tue, 22 Oct 2002 18:05:06 +0200 | |
changeset 4027 | c662c75b6bf9 |
parent 4026 | 106ce16d1669 |
child 4033 | 3cc51124deaa |
permissions | -rw-r--r-- |
3906 | 1 |
"{ Package: 'stx:libtool' }" |
3887 | 2 |
|
3888 | 3 |
AbstractFileBrowser subclass:#DirectoryContentsBrowser |
4019 | 4 |
instanceVariableNames:'updateDirectoryContentsTask updateColumnsTask modificationTime |
5 |
directory columnDescriptors iconIndex fileDescriptionIndex |
|
6 |
iconExtent tableColumns previewIndex allItemsList |
|
7 |
updateToExternFileHolderLock inDropMode draggedItem canDropItem |
|
8 |
viewBrowserMenu updateContentsSelection selectionInFileList |
|
9 |
contentsBrowser browserItemList matchBlock updateContentsTask' |
|
10 |
classVariableNames:'' |
|
11 |
poolDictionaries:'' |
|
12 |
category:'Interface-Tools-File' |
|
3887 | 13 |
! |
14 |
||
15 |
Object subclass:#DirectoryContentsItem |
|
4019 | 16 |
instanceVariableNames:'fileName fileInfo icon fileType |
17 |
contentsBrowserChangeModificationTime suffix preview group owner |
|
18 |
timeAndDate mimeType iconKey mimeTypeForContents' |
|
19 |
classVariableNames:'LastUIDToUserNameMapping LastGIDToGroupNameMapping' |
|
20 |
poolDictionaries:'' |
|
21 |
privateIn:DirectoryContentsBrowser |
|
4017 | 22 |
! |
23 |
||
24 |
Object subclass:#DirectoryContentsUpdateTask |
|
4019 | 25 |
instanceVariableNames:'directoryBrowser updateProcess isBusy changeSema |
26 |
directoryChangeFlag directoryContentsChangeFlag filterChangeFlag |
|
27 |
sortBlockChangeFlag modificationTime filteredItems |
|
28 |
modificationTask directory' |
|
29 |
classVariableNames:'' |
|
30 |
poolDictionaries:'' |
|
31 |
privateIn:DirectoryContentsBrowser |
|
3887 | 32 |
! |
33 |
||
34 |
!DirectoryContentsBrowser class methodsFor:'documentation'! |
|
35 |
||
36 |
documentation |
|
37 |
||
38 |
" |
|
39 |
DirectoryContentsBrowser openIn:'/home/ca/work/stx/goodies/bitmaps/xpmBitmaps' |
|
40 |
DirectoryContentsBrowser openIn:'/home/ca/TEST' |
|
41 |
" |
|
42 |
! ! |
|
43 |
||
44 |
!DirectoryContentsBrowser class methodsFor:'instance creation'! |
|
45 |
||
46 |
openIn:aDirectory |
|
47 |
"opens a directory (standalone) for a directory |
|
48 |
" |
|
49 |
self openIn:aDirectory withDirectories:false |
|
50 |
||
51 |
" |
|
52 |
self openIn:(Filename currentDirectory construct:'.cvsignore') |
|
53 |
" |
|
54 |
! |
|
55 |
||
56 |
openIn:aDirectory withDirectories:withDirectoriesBoolean |
|
57 |
"opens a directory (standalone) for a directory |
|
58 |
" |
|
59 |
|browser| |
|
60 |
||
61 |
browser := DirectoryContentsBrowser new. |
|
62 |
browser open. |
|
63 |
aDirectory notNil ifTrue:[ |
|
64 |
browser currentFileNameHolder value:(OrderedCollection with:(aDirectory asFilename)) |
|
65 |
]. |
|
66 |
browser viewDirectoriesInDirectoryContentsBrowser value:withDirectoriesBoolean. |
|
67 |
^ browser |
|
68 |
||
69 |
" |
|
4007 | 70 |
self openIn:(Filename currentDirectory asAbsoluteFilename) withDirectories:true |
3887 | 71 |
" |
72 |
! ! |
|
73 |
||
74 |
!DirectoryContentsBrowser class methodsFor:'classAccess'! |
|
75 |
||
76 |
itemClass |
|
77 |
||
78 |
^ DirectoryContentsItem |
|
79 |
||
80 |
||
81 |
" |
|
82 |
self itemClass |
|
83 |
" |
|
84 |
! ! |
|
85 |
||
86 |
!DirectoryContentsBrowser class methodsFor:'constant'! |
|
87 |
||
88 |
updateTaskPriority |
|
89 |
"returns the priority of the update task |
|
90 |
" |
|
91 |
^ 8 |
|
92 |
! ! |
|
93 |
||
3980 | 94 |
!DirectoryContentsBrowser class methodsFor:'image specs'! |
95 |
||
4027 | 96 |
detailsMenuIconDown |
3980 | 97 |
"This resource specification was automatically generated |
98 |
by the ImageEditor of ST/X." |
|
99 |
||
100 |
"Do not manually edit this!! If it is corrupted, |
|
101 |
the ImageEditor may not be able to read the specification." |
|
102 |
||
103 |
" |
|
4027 | 104 |
self detailsMenuIconDown inspect |
105 |
ImageEditor openOnClass:self andSelector:#detailsMenuIconDown |
|
3980 | 106 |
Icon flushCachedIcons |
107 |
" |
|
108 |
||
109 |
<resource: #image> |
|
110 |
||
111 |
^Icon |
|
4027 | 112 |
constantNamed:#'DirectoryContentsBrowser class detailsMenuIconDown' |
113 |
ifAbsentPut:[(Depth1Image new) width: 7; height: 5; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 7; height: 5; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@A@(UJ(b') ; yourself); yourself] |
|
3980 | 114 |
! |
115 |
||
116 |
detailsMenuIconR |
|
117 |
"This resource specification was automatically generated |
|
118 |
by the ImageEditor of ST/X." |
|
119 |
||
120 |
"Do not manually edit this!! If it is corrupted, |
|
121 |
the ImageEditor may not be able to read the specification." |
|
122 |
||
123 |
" |
|
124 |
self detailsMenuIconR inspect |
|
125 |
ImageEditor openOnClass:self andSelector:#detailsMenuIconR |
|
126 |
Icon flushCachedIcons |
|
127 |
" |
|
128 |
||
129 |
<resource: #image> |
|
130 |
||
131 |
^Icon |
|
132 |
constantNamed:#'DirectoryContentsBrowser class detailsMenuIconR' |
|
133 |
ifAbsentPut:[(Depth1Image new) width: 5; height: 7; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 5; height: 7; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:' DB TJA@ @@a') ; yourself); yourself] |
|
4027 | 134 |
! |
135 |
||
136 |
detailsMenuIconUp |
|
3980 | 137 |
"This resource specification was automatically generated |
138 |
by the ImageEditor of ST/X." |
|
139 |
||
140 |
"Do not manually edit this!! If it is corrupted, |
|
141 |
the ImageEditor may not be able to read the specification." |
|
142 |
||
143 |
" |
|
4027 | 144 |
self detailsMenuIconUp inspect |
145 |
ImageEditor openOnClass:self andSelector:#detailsMenuIconUp |
|
3980 | 146 |
Icon flushCachedIcons |
147 |
" |
|
148 |
||
149 |
<resource: #image> |
|
150 |
||
151 |
^Icon |
|
4027 | 152 |
constantNamed:#'DirectoryContentsBrowser class detailsMenuIconUp' |
153 |
ifAbsentPut:[(Depth1Image new) width: 7; height: 5; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 7; height: 5; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'*%P(D@@b') ; yourself); yourself] |
|
154 |
! ! |
|
155 |
||
156 |
!DirectoryContentsBrowser class methodsFor:'interface specs'! |
|
3980 | 157 |
|
3887 | 158 |
tableColumns |
159 |
"This resource specification was automatically generated |
|
160 |
by the DataSetBuilder of ST/X." |
|
161 |
||
162 |
"Do not manually edit this!! If it is corrupted, |
|
163 |
the DataSetBuilder may not be able to read the specification." |
|
164 |
||
165 |
" |
|
166 |
DataSetBuilder new openOnClass:DirectoryContentsBrowser andSelector:#tableColumns |
|
167 |
" |
|
168 |
||
169 |
<resource: #tableColumns> |
|
170 |
||
171 |
^#( |
|
172 |
#(#DataSetColumnSpec |
|
4027 | 173 |
#label: '' |
174 |
#id: #icon |
|
3887 | 175 |
#labelButtonType: #Group |
3980 | 176 |
#labelActionSelector: #showDetailMenu |
3887 | 177 |
#width: 22 |
178 |
#minWidth: 22 |
|
179 |
#height: 16 |
|
180 |
#model: #icon |
|
181 |
#canSelect: false |
|
182 |
#showRowSeparator: false |
|
183 |
#showColSeparator: false |
|
184 |
) |
|
185 |
#(#DataSetColumnSpec |
|
186 |
#label: 'Filename' |
|
187 |
#id: #filename |
|
188 |
#labelAlignment: #left |
|
189 |
#labelButtonType: #Button |
|
3989 | 190 |
#labelActionSelector: #sortFileListsBy: |
3887 | 191 |
#labelActionArgument: 'baseName' |
192 |
#minWidth: 150 |
|
193 |
#model: #baseName |
|
194 |
#canSelect: false |
|
195 |
#showRowSeparator: false |
|
196 |
#showColSeparator: false |
|
197 |
) |
|
198 |
#(#DataSetColumnSpec |
|
199 |
#label: 'Suffix' |
|
200 |
#id: #suffix |
|
201 |
#labelAlignment: #left |
|
202 |
#labelButtonType: #Button |
|
3989 | 203 |
#labelActionSelector: #sortFileListsBy: |
3887 | 204 |
#labelActionArgument: 'suffix' |
205 |
#width: 40 |
|
206 |
#model: #suffix |
|
207 |
#canSelect: false |
|
208 |
#isResizeable: false |
|
209 |
#showRowSeparator: false |
|
210 |
#showColSeparator: false |
|
211 |
) |
|
212 |
#(#DataSetColumnSpec |
|
213 |
#label: 'Perm' |
|
214 |
#id: #perm |
|
215 |
#labelAlignment: #left |
|
216 |
#labelButtonType: #Button |
|
3989 | 217 |
#labelActionSelector: #sortFileListsBy: |
3887 | 218 |
#labelActionArgument: 'permissions' |
219 |
#width: 75 |
|
220 |
#model: #permissions |
|
221 |
#canSelect: false |
|
222 |
#isResizeable: false |
|
223 |
#showRowSeparator: false |
|
224 |
#showColSeparator: false |
|
225 |
) |
|
226 |
#(#DataSetColumnSpec |
|
227 |
#label: 'Owner' |
|
228 |
#id: #owner |
|
229 |
#labelAlignment: #left |
|
230 |
#labelButtonType: #Button |
|
3989 | 231 |
#labelActionSelector: #sortFileListsBy: |
3887 | 232 |
#labelActionArgument: 'owner' |
233 |
#usePreferredWidth: true |
|
234 |
#width: 50 |
|
235 |
#model: #owner |
|
236 |
#canSelect: false |
|
237 |
#showRowSeparator: false |
|
238 |
#showColSeparator: false |
|
239 |
) |
|
240 |
#(#DataSetColumnSpec |
|
241 |
#label: 'Group' |
|
242 |
#id: #group |
|
243 |
#labelAlignment: #left |
|
244 |
#labelButtonType: #Button |
|
3989 | 245 |
#labelActionSelector: #sortFileListsBy: |
3887 | 246 |
#labelActionArgument: 'group' |
247 |
#usePreferredWidth: true |
|
248 |
#width: 40 |
|
249 |
#model: #group |
|
250 |
#canSelect: false |
|
251 |
#showRowSeparator: false |
|
252 |
#showColSeparator: false |
|
253 |
) |
|
254 |
#(#DataSetColumnSpec |
|
255 |
#label: 'Size' |
|
256 |
#id: #size |
|
257 |
#translateLabel: true |
|
258 |
#labelAlignment: #right |
|
259 |
#labelButtonType: #Button |
|
3989 | 260 |
#labelActionSelector: #sortFileListsBy: |
3983 | 261 |
#labelActionArgument: 'fileSize' |
3887 | 262 |
#columnAlignment: #right |
263 |
#usePreferredWidth: true |
|
264 |
#model: #sizeString |
|
265 |
#canSelect: false |
|
266 |
#showRowSeparator: false |
|
267 |
#showColSeparator: false |
|
268 |
) |
|
269 |
#(#DataSetColumnSpec |
|
270 |
#label: 'Date & Time' |
|
3964 | 271 |
#id: #time |
3887 | 272 |
#labelAlignment: #right |
273 |
#labelButtonType: #Button |
|
3989 | 274 |
#labelActionSelector: #sortFileListsBy: |
3887 | 275 |
#labelActionArgument: 'modificationTime' |
276 |
#columnAlignment: #right |
|
277 |
#usePreferredWidth: true |
|
278 |
#width: 140 |
|
279 |
#model: #timeAndDate |
|
280 |
#writeSelector: #date: |
|
281 |
#canSelect: false |
|
282 |
#showRowSeparator: false |
|
283 |
#showColSeparator: false |
|
284 |
) |
|
285 |
#(#DataSetColumnSpec |
|
286 |
#label: 'File Info' |
|
287 |
#id: #fileInfo |
|
288 |
#labelAlignment: #left |
|
289 |
#labelButtonType: #Button |
|
3989 | 290 |
#labelActionSelector: #sortFileListsBy: |
3887 | 291 |
#labelActionArgument: 'fileType' |
292 |
#width: 250 |
|
293 |
#model: #fileInfoString |
|
294 |
#canSelect: false |
|
295 |
#showRowSeparator: false |
|
296 |
#showColSeparator: false |
|
297 |
) |
|
298 |
#(#DataSetColumnSpec |
|
299 |
#label: 'Pre +/-' |
|
300 |
#id: #preview |
|
301 |
#labelButtonType: #Button |
|
302 |
#labelActionSelector: #doResizeImage |
|
303 |
#labelActionArgument: '' |
|
304 |
#columnAlignment: #center |
|
305 |
#width: 45 |
|
306 |
#height: 16 |
|
307 |
#model: #preview |
|
308 |
#canSelect: false |
|
309 |
#showRowSeparator: false |
|
310 |
#showColSeparator: false |
|
311 |
) |
|
312 |
) |
|
313 |
! |
|
314 |
||
315 |
windowSpec |
|
316 |
"This resource specification was automatically generated |
|
317 |
by the UIPainter of ST/X." |
|
318 |
||
319 |
"Do not manually edit this!! If it is corrupted, |
|
320 |
the UIPainter may not be able to read the specification." |
|
321 |
||
322 |
" |
|
323 |
UIPainter new openOnClass:DirectoryContentsBrowser andSelector:#windowSpec |
|
324 |
DirectoryContentsBrowser new openInterface:#windowSpec |
|
325 |
DirectoryContentsBrowser open |
|
326 |
" |
|
327 |
||
328 |
<resource: #canvas> |
|
329 |
||
330 |
^ |
|
331 |
#(#FullSpec |
|
332 |
#name: #windowSpec |
|
333 |
#window: |
|
334 |
#(#WindowSpec |
|
335 |
#label: 'Directory ContentsBrowser' |
|
336 |
#name: 'Directory ContentsBrowser' |
|
337 |
#min: #(#Point 10 10) |
|
338 |
#max: #(#Point 1152 900) |
|
3953 | 339 |
#bounds: #(#Rectangle 16 42 604 520) |
3887 | 340 |
#menu: #menu |
341 |
) |
|
342 |
#component: |
|
343 |
#(#SpecCollection |
|
344 |
#collection: #( |
|
345 |
#(#DataSetSpec |
|
346 |
#name: 'browser' |
|
347 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
348 |
#model: #selectionInFileList |
|
349 |
#menu: #directoryContentsBrowserMenu |
|
350 |
#hasHorizontalScrollBar: true |
|
351 |
#hasVerticalScrollBar: true |
|
352 |
#miniScrollerHorizontal: false |
|
353 |
#miniScrollerVertical: false |
|
3983 | 354 |
#dataList: #browserItemList |
355 |
#useIndex: false |
|
3887 | 356 |
#has3Dsepartors: false |
357 |
#doubleClickSelector: #doubleClickedAt: |
|
358 |
#columnHolder: #tableColumns |
|
359 |
#multipleSelectOk: true |
|
360 |
#verticalSpacing: 0 |
|
361 |
#columns: |
|
362 |
#(#OrderedCollection |
|
363 |
||
364 |
#(#DataSetColumnSpec |
|
365 |
#labelButtonType: #Group |
|
366 |
#width: 22 |
|
367 |
#minWidth: 22 |
|
368 |
#height: 16 |
|
369 |
#model: #icon |
|
370 |
#canSelect: false |
|
371 |
#showRowSeparator: false |
|
372 |
#showColSeparator: false |
|
373 |
) |
|
374 |
#(#DataSetColumnSpec |
|
375 |
#label: 'file name' |
|
376 |
#labelAlignment: #left |
|
377 |
#labelButtonType: #Button |
|
378 |
#model: #baseName |
|
379 |
#canSelect: false |
|
380 |
#showRowSeparator: false |
|
381 |
#showColSeparator: false |
|
382 |
) |
|
383 |
||
384 |
#(#DataSetColumnSpec |
|
385 |
#label: '+/-' |
|
386 |
#labelButtonType: #Button |
|
387 |
#labelActionSelector: #doResizeImage |
|
388 |
#labelActionArgument: '' |
|
389 |
#columnAlignment: #center |
|
390 |
#width: 30 |
|
391 |
#height: 16 |
|
392 |
#model: #preview |
|
393 |
#canSelect: false |
|
394 |
#showRowSeparator: false |
|
395 |
#showSelectionHighLighted: false |
|
396 |
#showColSeparator: false |
|
397 |
) |
|
398 |
) |
|
399 |
#viewClassName: 'DirectoryContentsBrowser::Widget' |
|
400 |
#postBuildCallback: #postBuildBrowser: |
|
401 |
#properties: |
|
402 |
#(#PropertyListDictionary |
|
3983 | 403 |
#dropSelector: #doDrop: |
3953 | 404 |
#dragArgument: #contentsbrowser |
3887 | 405 |
#startDragSelector: #doStartDrag:in: |
406 |
#displayObjectSelector: #getDisplayObjects: |
|
407 |
#dropObjectSelector: #getDropObjects: |
|
408 |
#dropArgument: #browser |
|
3953 | 409 |
#canDropSelector: #canDrop: |
3887 | 410 |
#leaveSelector: #dropLeave: |
3983 | 411 |
#enterSelector: #dropEnter: |
3953 | 412 |
#overSelector: #dropOver: |
3887 | 413 |
) |
414 |
) |
|
415 |
) |
|
416 |
||
417 |
) |
|
418 |
) |
|
419 |
! ! |
|
420 |
||
421 |
!DirectoryContentsBrowser class methodsFor:'menu specs'! |
|
422 |
||
423 |
directoryContentsBrowserMenu |
|
424 |
"This resource specification was automatically generated |
|
425 |
by the MenuEditor of ST/X." |
|
426 |
||
427 |
"Do not manually edit this!! If it is corrupted, |
|
428 |
the MenuEditor may not be able to read the specification." |
|
429 |
||
430 |
" |
|
431 |
MenuEditor new openOnClass:DirectoryContentsBrowser andSelector:#directoryContentsBrowserMenu |
|
432 |
(Menu new fromLiteralArrayEncoding:(DirectoryContentsBrowser directoryContentsBrowserMenu)) startUp |
|
433 |
" |
|
434 |
||
435 |
<resource: #menu> |
|
436 |
||
437 |
^ |
|
438 |
#(#Menu |
|
439 |
#( |
|
440 |
#(#MenuItem |
|
441 |
#label: 'Copy' |
|
442 |
#translateLabel: true |
|
443 |
#value: #doCopy |
|
444 |
#shortcutKeyCharacter: #Copy |
|
445 |
) |
|
446 |
#(#MenuItem |
|
447 |
#label: 'Cut' |
|
448 |
#translateLabel: true |
|
449 |
#value: #doCut |
|
450 |
#shortcutKeyCharacter: #Cut |
|
451 |
) |
|
452 |
#(#MenuItem |
|
453 |
#label: 'Paste' |
|
454 |
#translateLabel: true |
|
455 |
#value: #pasteFiles |
|
456 |
#enabled: #canPaste |
|
457 |
#shortcutKeyCharacter: #Paste |
|
458 |
) |
|
459 |
#(#MenuItem |
|
460 |
#label: 'Delete' |
|
461 |
#translateLabel: true |
|
462 |
#nameKey: #delete |
|
463 |
#value: #doDelete |
|
464 |
#shortcutKeyCharacter: #Delete |
|
465 |
) |
|
466 |
#(#MenuItem |
|
3911 | 467 |
#label: 'Rename...' |
3887 | 468 |
#translateLabel: true |
469 |
#value: #renameSelection |
|
470 |
#enabled: #hasSelection |
|
471 |
#shortcutKeyCharacter: #Replace |
|
472 |
) |
|
473 |
#(#MenuItem |
|
474 |
#label: '-' |
|
475 |
) |
|
476 |
#(#MenuItem |
|
477 |
#label: 'View' |
|
478 |
#translateLabel: true |
|
479 |
#nameKey: #View |
|
480 |
#submenuChannel: #viewBrowserMenu |
|
481 |
) |
|
482 |
#(#MenuItem |
|
483 |
#label: 'Sort' |
|
484 |
#translateLabel: true |
|
485 |
#nameKey: #Sort |
|
486 |
#submenuChannel: #sortMenu |
|
487 |
) |
|
488 |
#(#MenuItem |
|
489 |
#label: '-' |
|
490 |
) |
|
491 |
#(#MenuItem |
|
492 |
#label: 'New' |
|
493 |
#translateLabel: true |
|
494 |
#submenuChannel: #newMenu |
|
495 |
) |
|
496 |
#(#MenuItem |
|
497 |
#label: 'Properties...' |
|
498 |
#translateLabel: true |
|
499 |
#value: #doShowProperties |
|
500 |
#enabled: #hasSelection |
|
501 |
) |
|
502 |
#(#MenuItem |
|
3980 | 503 |
#label: 'More' |
3907 | 504 |
#submenu: |
505 |
#(#Menu |
|
506 |
#( |
|
507 |
#(#MenuItem |
|
508 |
#label: 'File In' |
|
509 |
#translateLabel: true |
|
510 |
#value: #fileFileIn |
|
511 |
#enabled: #hasSelection |
|
512 |
#shortcutKeyCharacter: #Accept |
|
513 |
) |
|
514 |
#(#MenuItem |
|
515 |
#label: 'File in to NameSpace...' |
|
516 |
#translateLabel: true |
|
517 |
#value: #fileFileInToNameSpace |
|
518 |
#enabled: #hasSelection |
|
519 |
) |
|
520 |
#(#MenuItem |
|
3980 | 521 |
#label: '-' |
3907 | 522 |
) |
523 |
#(#MenuItem |
|
524 |
#label: 'Open in TextEditor' |
|
525 |
#translateLabel: true |
|
526 |
#value: #doShowFileContents |
|
527 |
#enabled: #hasSelection |
|
528 |
) |
|
529 |
#(#MenuItem |
|
3980 | 530 |
#label: '-' |
531 |
) |
|
532 |
#(#MenuItem |
|
3907 | 533 |
#label: 'Select All' |
534 |
#translateLabel: true |
|
3983 | 535 |
#value: #selectAll |
3907 | 536 |
) |
537 |
#(#MenuItem |
|
538 |
#label: 'Copy File List' |
|
539 |
#translateLabel: true |
|
540 |
#value: #copyFileList |
|
541 |
#enabled: #fileListIsNotEmpty |
|
542 |
) |
|
543 |
) |
|
544 |
nil |
|
545 |
nil |
|
546 |
) |
|
3887 | 547 |
) |
3980 | 548 |
#(#MenuItem |
549 |
#label: '-' |
|
550 |
) |
|
551 |
#(#MenuItem |
|
552 |
#label: 'Update' |
|
553 |
#translateLabel: true |
|
554 |
#value: #doUpdate |
|
555 |
) |
|
3887 | 556 |
) |
557 |
nil |
|
558 |
nil |
|
559 |
) |
|
560 |
! |
|
561 |
||
562 |
viewBrowserMenu |
|
563 |
"This resource specification was automatically generated |
|
564 |
by the MenuEditor of ST/X." |
|
565 |
||
566 |
"Do not manually edit this!! If it is corrupted, |
|
567 |
the MenuEditor may not be able to read the specification." |
|
568 |
||
569 |
" |
|
570 |
MenuEditor new openOnClass:DirectoryContentsBrowser andSelector:#viewBrowserMenu |
|
571 |
(Menu new fromLiteralArrayEncoding:(DirectoryContentsBrowser viewBrowserMenu)) startUp |
|
572 |
" |
|
573 |
||
574 |
<resource: #menu> |
|
575 |
||
3961 | 576 |
^ Menu new fromLiteralArrayEncoding:self viewBrowserMenuSpec |
577 |
! |
|
578 |
||
579 |
viewBrowserMenuSpec |
|
580 |
"This resource specification was automatically generated |
|
581 |
by the MenuEditor of ST/X." |
|
582 |
||
583 |
"Do not manually edit this!! If it is corrupted, |
|
584 |
the MenuEditor may not be able to read the specification." |
|
585 |
||
586 |
" |
|
587 |
MenuEditor new openOnClass:DirectoryContentsBrowser andSelector:#viewBrowserMenu |
|
588 |
(Menu new fromLiteralArrayEncoding:(DirectoryContentsBrowser viewBrowserMenu)) startUp |
|
589 |
" |
|
590 |
||
591 |
<resource: #menu> |
|
592 |
||
3887 | 593 |
^ |
594 |
#(#Menu |
|
595 |
#( |
|
596 |
#(#MenuItem |
|
597 |
#label: 'View Details' |
|
598 |
#translateLabel: true |
|
599 |
#hideMenuOnActivated: false |
|
600 |
#indication: #viewDetails |
|
601 |
) |
|
602 |
#(#MenuItem |
|
3984 | 603 |
#label: '-' |
604 |
) |
|
605 |
#(#MenuItem |
|
3887 | 606 |
#label: 'View Suffix' |
607 |
#translateLabel: true |
|
608 |
#hideMenuOnActivated: false |
|
609 |
#enabled: #viewDetails |
|
610 |
#indication: #viewType |
|
611 |
) |
|
612 |
#(#MenuItem |
|
613 |
#label: 'View Permissions' |
|
614 |
#translateLabel: true |
|
615 |
#hideMenuOnActivated: false |
|
616 |
#enabled: #viewDetails |
|
617 |
#indication: #viewPermissions |
|
618 |
) |
|
619 |
#(#MenuItem |
|
620 |
#label: 'View Owner' |
|
621 |
#translateLabel: true |
|
622 |
#hideMenuOnActivated: false |
|
623 |
#enabled: #viewDetails |
|
624 |
#indication: #viewOwner |
|
625 |
) |
|
626 |
#(#MenuItem |
|
627 |
#label: 'View Group' |
|
628 |
#translateLabel: true |
|
629 |
#hideMenuOnActivated: false |
|
630 |
#enabled: #viewDetails |
|
631 |
#indication: #viewGroup |
|
632 |
) |
|
633 |
#(#MenuItem |
|
634 |
#label: 'View Size' |
|
635 |
#translateLabel: true |
|
636 |
#hideMenuOnActivated: false |
|
637 |
#enabled: #viewDetails |
|
638 |
#indication: #viewSize |
|
639 |
) |
|
640 |
#(#MenuItem |
|
641 |
#label: 'View Date && Time' |
|
642 |
#translateLabel: true |
|
643 |
#hideMenuOnActivated: false |
|
644 |
#enabled: #viewDetails |
|
645 |
#indication: #viewTime |
|
646 |
) |
|
647 |
#(#MenuItem |
|
648 |
#label: 'View File Info' |
|
649 |
#translateLabel: true |
|
650 |
#hideMenuOnActivated: false |
|
651 |
#enabled: #viewDetails |
|
652 |
#indication: #viewDescription |
|
653 |
) |
|
654 |
#(#MenuItem |
|
655 |
#label: 'View Preview' |
|
656 |
#translateLabel: true |
|
657 |
#hideMenuOnActivated: false |
|
658 |
#enabled: #viewDetails |
|
659 |
#indication: #viewPreview |
|
660 |
) |
|
661 |
#(#MenuItem |
|
662 |
#label: '-' |
|
3980 | 663 |
#isVisible: false |
3887 | 664 |
) |
665 |
#(#MenuItem |
|
666 |
#label: 'Show Hidden Files' |
|
667 |
#translateLabel: true |
|
668 |
#indication: #showHiddenFiles |
|
3980 | 669 |
#isVisible: false |
670 |
) |
|
671 |
#(#MenuItem |
|
672 |
#label: 'Update' |
|
673 |
#translateLabel: true |
|
674 |
#value: #doUpdate |
|
675 |
#isVisible: false |
|
676 |
) |
|
677 |
) |
|
678 |
nil |
|
679 |
nil |
|
680 |
) |
|
3887 | 681 |
! ! |
682 |
||
683 |
!DirectoryContentsBrowser methodsFor:'accessing'! |
|
684 |
||
4017 | 685 |
allItemsList |
686 |
"return the value of the instance variable 'allItemsList' (automatically generated)" |
|
687 |
||
688 |
allItemsList isNil ifTrue:[ |
|
689 |
allItemsList := OrderedCollection new. |
|
690 |
]. |
|
691 |
^ allItemsList |
|
692 |
! |
|
693 |
||
694 |
allItemsList:something |
|
695 |
"set the value of the instance variable 'allItemsList' (automatically generated)" |
|
696 |
||
697 |
allItemsList := something. |
|
698 |
! |
|
699 |
||
3887 | 700 |
columnDescriptors |
701 |
"get the column description |
|
702 |
" |
|
703 |
^ columnDescriptors |
|
704 |
! |
|
705 |
||
706 |
columnDescriptors:aListOfColumns |
|
707 |
"set the column description |
|
708 |
" |
|
709 |
columnDescriptors = aListOfColumns ifTrue:[ |
|
710 |
^ self |
|
711 |
]. |
|
712 |
||
713 |
columnDescriptors := OrderedCollection new. |
|
714 |
previewIndex := 0. |
|
715 |
iconIndex := 0. |
|
716 |
fileDescriptionIndex := 0. |
|
717 |
iconExtent := nil. |
|
718 |
||
719 |
aListOfColumns keysAndValuesDo:[:anIndex :aDesc| |col| |
|
720 |
col := aDesc isSequenceable ifTrue:[DataSetColumnSpec new fromLiteralArrayEncoding:aDesc] |
|
721 |
ifFalse:[aDesc]. |
|
722 |
columnDescriptors add:col. |
|
723 |
||
724 |
col readSelector == #preview ifTrue:[ |
|
725 |
previewIndex := anIndex. |
|
726 |
iconExtent := Point x:(col width) y:(col height). |
|
727 |
] ifFalse:[ |
|
728 |
col readSelector == #fileInfoString ifTrue:[ |
|
729 |
fileDescriptionIndex := anIndex. |
|
730 |
] ifFalse:[ |
|
731 |
col readSelector == #icon ifTrue:[ |
|
732 |
iconIndex := anIndex. |
|
733 |
] |
|
734 |
] |
|
735 |
] |
|
736 |
]. |
|
737 |
||
738 |
! |
|
739 |
||
740 |
directory |
|
741 |
"returns the current directory or nil |
|
742 |
" |
|
743 |
^ directory |
|
744 |
||
745 |
! |
|
746 |
||
747 |
directory:aDirectory |
|
748 |
"change the current directory and read the items |
|
749 |
" |
|
750 |
directory := aDirectory. |
|
4017 | 751 |
updateContentsTask wakeUpForDirectoryChanged:aDirectory. |
752 |
! |
|
753 |
||
754 |
matchBlock |
|
755 |
"return the value of the instance variable 'matchBlock' (automatically generated)" |
|
756 |
||
757 |
^ matchBlock |
|
758 |
! |
|
759 |
||
760 |
matchBlock:filterBlock |
|
761 |
||
762 |
matchBlock := filterBlock. |
|
763 |
updateContentsTask wakeUpForFilterChanged. |
|
3887 | 764 |
! |
765 |
||
766 |
updateColumnsTask |
|
767 |
"return the value of the instance variable 'updateColumnsTask' (automatically generated)" |
|
768 |
||
769 |
^ updateColumnsTask |
|
770 |
! |
|
771 |
||
772 |
updateColumnsTask:something |
|
773 |
"set the value of the instance variable 'updateColumnsTask' (automatically generated)" |
|
774 |
||
775 |
updateColumnsTask := something. |
|
776 |
! |
|
777 |
||
3983 | 778 |
updateContentsSelection |
779 |
"return the value of the instance variable 'updateToExternFileHolder' (automatically generated)" |
|
780 |
||
781 |
updateContentsSelection isNil ifTrue:[ |
|
782 |
updateContentsSelection := self class newLock. |
|
783 |
]. |
|
784 |
^ updateContentsSelection |
|
785 |
! |
|
786 |
||
3887 | 787 |
updateDirectoryContentsTask |
788 |
"return the value of the instance variable 'updateDirectoryContentsTask' (automatically generated)" |
|
789 |
||
790 |
^ updateDirectoryContentsTask |
|
791 |
! |
|
792 |
||
793 |
updateDirectoryContentsTask:something |
|
794 |
"set the value of the instance variable 'updateDirectoryContentsTask' (automatically generated)" |
|
795 |
||
796 |
updateDirectoryContentsTask := something. |
|
797 |
! |
|
798 |
||
799 |
updateToExternFileHolderLock |
|
800 |
"return the value of the instance variable 'updateToExternFileHolder' (automatically generated)" |
|
801 |
||
802 |
updateToExternFileHolderLock isNil ifTrue:[ |
|
803 |
updateToExternFileHolderLock := self class newLock. |
|
804 |
]. |
|
805 |
^ updateToExternFileHolderLock |
|
806 |
! ! |
|
807 |
||
808 |
!DirectoryContentsBrowser methodsFor:'actions'! |
|
809 |
||
4017 | 810 |
allItems:allItems browserItemListAdd:addItemCol remove:remItemCol |
811 |
| browserList| |
|
812 |
||
813 |
self updateColumnsTaskStop. |
|
814 |
self allItemsList:allItems. |
|
815 |
browserList := self browserItemList copy. |
|
816 |
remItemCol notEmpty ifTrue:[ |
|
817 |
browserList removeAll:remItemCol |
|
818 |
]. |
|
819 |
addItemCol notEmpty ifTrue:[ |
|
820 |
browserList addAll:addItemCol |
|
821 |
]. |
|
822 |
browserList sort:self sortBlockHolder value. |
|
823 |
self browserItemList contents:browserList asList. |
|
824 |
self selectCurrentFiles. |
|
825 |
self updateColumnsTaskStart. |
|
826 |
! |
|
827 |
||
4027 | 828 |
currentSortOrderChanged |
829 |
||
830 |
self viewedColumnsChanged. |
|
831 |
! |
|
832 |
||
3887 | 833 |
doResizeImage |
834 |
|column w h| |
|
835 |
||
836 |
previewIndex == 0 ifTrue:[^ self]. |
|
837 |
||
838 |
||
839 |
column := columnDescriptors at:previewIndex. |
|
840 |
w := iconExtent x. |
|
841 |
h := iconExtent y. |
|
842 |
||
843 |
w == column width ifTrue:[ |
|
844 |
w := w * 2. |
|
845 |
h := h * 2. |
|
846 |
]. |
|
847 |
column width:w. |
|
848 |
column height:h. |
|
849 |
||
3990 | 850 |
"/Processor activeProcess ~~ self windowGroup process ifTrue:[self halt]. |
3887 | 851 |
self updateColumnsTaskStop. |
3983 | 852 |
browserItemList do:[:el| el resetImageFile ]. |
853 |
contentsBrowser columnDescriptors:columnDescriptors. |
|
3887 | 854 |
self updateColumnsTaskStart. |
855 |
! |
|
856 |
||
857 |
doUpdate |
|
858 |
||
4017 | 859 |
updateContentsTask wakeUpForDirectoryContentsChanged. |
3887 | 860 |
! |
861 |
||
3984 | 862 |
doubleClickedAt:anItemIndex |
3983 | 863 |
|
3906 | 864 |
self withWaitCursorDo:[ |
4013 | 865 |
self enterActionFor:(self browserItemList at:anItemIndex). "/ anItemIndex. |
3906 | 866 |
] |
3887 | 867 |
! |
868 |
||
869 |
enterActionFor:anItem |
|
870 |
| filename| |
|
871 |
||
872 |
filename := anItem fileName. |
|
3906 | 873 |
|
4014 | 874 |
filename baseName = '..' ifTrue:[ |
3887 | 875 |
self currentFileNameHolder value:(OrderedCollection with:(self directory directory)). |
876 |
^ self. |
|
877 |
]. |
|
4017 | 878 |
(anItem isDirectory) ifTrue:[ |
3887 | 879 |
self currentFileNameHolder value:(OrderedCollection with:filename). |
880 |
^ self. |
|
881 |
]. |
|
882 |
self openApplByFileItem:anItem. |
|
4017 | 883 |
! |
884 |
||
885 |
noOfAddedFiles:noOfAddedFiles noOfFiles:noOfFiles |
|
886 |
||
887 |
| filterBox clr| |
|
888 |
||
889 |
self shownFiles value:noOfAddedFiles asString,'/',noOfFiles asString. |
|
890 |
filterBox := self filterValueBox value. |
|
891 |
filterBox isNil ifTrue:[^ self ]. |
|
892 |
noOfAddedFiles ~= noOfFiles ifTrue:[ |
|
893 |
clr := Color red lightened lightened lightened. |
|
894 |
[ filterBox flash] fork. |
|
895 |
] ifFalse:[ |
|
896 |
clr := self filterBackgroundColor value. |
|
897 |
]. |
|
898 |
filterBox backgroundColor:clr. |
|
899 |
! |
|
900 |
||
901 |
setBrowserItemList:filteredItems allItemsList:allItems |
|
902 |
||
903 |
|showDir directoryUpItem locItems| |
|
904 |
||
905 |
self updateColumnsTaskStop. |
|
906 |
locItems := filteredItems copy. |
|
907 |
allItems notNil ifTrue:[ |
|
908 |
self allItemsList:allItems. |
|
909 |
]. |
|
910 |
showDir := self viewDirectoriesInDirectoryContentsBrowser value. |
|
911 |
(showDir and:[self directory notNil and:[self directory isRootDirectory not]]) ifTrue:[ |
|
912 |
directoryUpItem := DirectoryContentsBrowser itemClass fileName:(self directory construct:'..'). |
|
913 |
locItems addFirst:directoryUpItem. |
|
914 |
]. |
|
915 |
self browserItemList contents:locItems asList. |
|
916 |
self updateColumnsTaskStart. |
|
917 |
self selectCurrentFiles. |
|
3887 | 918 |
! ! |
919 |
||
920 |
!DirectoryContentsBrowser methodsFor:'aspects'! |
|
921 |
||
3983 | 922 |
browserItemList |
923 |
||
924 |
browserItemList isNil ifTrue:[ |
|
925 |
browserItemList := List new. |
|
926 |
]. |
|
927 |
^ browserItemList |
|
3887 | 928 |
! |
929 |
||
3983 | 930 |
selectionInFileList |
931 |
||
932 |
selectionInFileList isNil ifTrue:[ |
|
933 |
selectionInFileList := ValueHolder new. |
|
934 |
selectionInFileList addDependent:self. |
|
3887 | 935 |
]. |
3983 | 936 |
^ selectionInFileList |
3887 | 937 |
! |
938 |
||
939 |
tableColumns |
|
940 |
"automatically generated by UIPainter ..." |
|
941 |
||
942 |
"*** the code below creates a default model when invoked." |
|
943 |
"*** (which may not be the one you wanted)" |
|
944 |
"*** Please change as required and accept it in the browser." |
|
945 |
"*** (and replace this comment by something more useful ;-)" |
|
946 |
||
947 |
tableColumns isNil ifTrue:[ |
|
948 |
tableColumns := self class tableColumns asValue. |
|
949 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
950 |
"/ tableColumns addDependent:self. |
|
951 |
"/ tableColumns onChangeSend:#tableColumnsChanged to:self. |
|
952 |
]. |
|
953 |
^ tableColumns. |
|
954 |
! ! |
|
955 |
||
956 |
!DirectoryContentsBrowser methodsFor:'change & update'! |
|
957 |
||
3983 | 958 |
currentFileNameHolderChanged |
3887 | 959 |
"filename changed |
960 |
" |
|
3983 | 961 |
| newDir currentDir aColOfFiles| |
962 |
||
963 |
||
964 |
aColOfFiles := self currentFileNameHolder value. |
|
965 |
(aColOfFiles isEmpty or:[self currentFilesAreInSameDirectory not]) ifTrue:[ |
|
3887 | 966 |
self directory:nil. |
967 |
^ self |
|
968 |
]. |
|
3983 | 969 |
newDir := self currentDirectories value first. |
3887 | 970 |
currentDir := self directory. |
971 |
newDir = currentDir ifTrue:[ |
|
3983 | 972 |
self selectFiles:aColOfFiles. |
3887 | 973 |
^ self. |
974 |
] ifFalse:[ |
|
975 |
"/ change of the directory filename |
|
976 |
self directory:newDir. |
|
977 |
]. |
|
978 |
! |
|
979 |
||
3983 | 980 |
selectionChanged |
981 |
||
4004 | 982 |
| selection newCurrentFilename | |
3983 | 983 |
|
984 |
self directory isNil ifTrue:[^ self]. |
|
985 |
selection := self selectedFiles. |
|
986 |
selection isEmpty ifTrue:[ |
|
4004 | 987 |
newCurrentFilename := OrderedCollection with:self directory. |
3983 | 988 |
] ifFalse:[ |
4004 | 989 |
newCurrentFilename := selection. |
3983 | 990 |
]. |
4004 | 991 |
self currentFileNameHolder value ~= newCurrentFilename ifTrue:[ |
992 |
self currentFileNameHolder value:newCurrentFilename withoutNotifying:self |
|
993 |
] |
|
3983 | 994 |
! |
995 |
||
3887 | 996 |
update:something with:aParameter from:aModel |
997 |
"one of my models changed |
|
998 |
" |
|
3983 | 999 |
|
1000 |
aModel == self currentFileNameHolder ifTrue:[ |
|
4007 | 1001 |
super update:something with:aParameter from:aModel. |
3983 | 1002 |
self updateContentsSelection doIfUnLocked:[ |
4017 | 1003 |
self currentFileNameHolderChanged. |
3983 | 1004 |
]. |
4007 | 1005 |
^ self. |
3983 | 1006 |
]. |
1007 |
aModel == self selectionInFileList ifTrue:[ |
|
1008 |
self updateToExternFileHolderLock doIfUnLocked:[ |
|
1009 |
self updateContentsSelection doLocked:[ |
|
1010 |
self selectionChanged. |
|
1011 |
] |
|
1012 |
]. |
|
1013 |
^ self. |
|
1014 |
]. |
|
4027 | 1015 |
aModel == self currentSortOrder ifTrue:[ |
1016 |
self currentSortOrderChanged. |
|
1017 |
^ self. |
|
1018 |
]. |
|
4011 | 1019 |
aModel == self filterBlockHolder ifTrue:[ |
4017 | 1020 |
self matchBlock:self filterBlockHolder value. |
3887 | 1021 |
^ self. |
1022 |
]. |
|
1023 |
aModel == self sortBlockHolder ifTrue:[ |
|
4017 | 1024 |
updateContentsTask wakeUpForSortBlockChanged. |
3887 | 1025 |
^ self. |
1026 |
]. |
|
1027 |
aModel == self viewDirectoriesInDirectoryContentsBrowser ifTrue:[ |
|
4017 | 1028 |
updateContentsTask wakeUpForFilterChanged. |
3887 | 1029 |
^ self |
1030 |
]. |
|
1031 |
||
1032 |
super update:something with:aParameter from:aModel |
|
1033 |
! |
|
1034 |
||
1035 |
viewedColumnsChanged |
|
1036 |
||
4027 | 1037 |
| columns buffer currentSortOrder currentSortOrderColumn currentSortOrderReverse| |
3887 | 1038 |
|
1039 |
columns := OrderedCollection new. |
|
1040 |
self class tableColumns do:[:el| |
|
1041 |
columns add:(DataSetColumnSpec new fromLiteralArrayEncoding:el). |
|
1042 |
]. |
|
1043 |
buffer := columns copy. |
|
1044 |
self viewDetails value = false ifTrue:[ |
|
3983 | 1045 |
contentsBrowser showLabels:false. |
3887 | 1046 |
buffer do:[:col | |
1047 |
(col readSelector = #baseName or:[col readSelector = #icon]) ifFalse:[ |
|
1048 |
columns remove:col. |
|
1049 |
] |
|
1050 |
] |
|
1051 |
] ifFalse:[ |
|
3983 | 1052 |
contentsBrowser showLabels:true. |
4027 | 1053 |
currentSortOrder := self currentSortOrder value. |
1054 |
currentSortOrderColumn := currentSortOrder at:#column ifAbsent:nil. |
|
1055 |
currentSortOrderReverse := currentSortOrder at:#reverse ifAbsent:nil. |
|
3887 | 1056 |
buffer do:[:col | |
1057 |
| id | |
|
1058 |
id := col id. |
|
1059 |
id notNil ifTrue:[ |
|
4027 | 1060 |
(col labelActionArgument notNil and:[col labelActionArgument asSymbol == currentSortOrderColumn]) ifTrue:[ |
1061 |
| label icon| |
|
1062 |
label := col label. |
|
1063 |
icon := currentSortOrderReverse ifTrue:[self class detailsMenuIconDown] ifFalse:[self class detailsMenuIconUp]. |
|
1064 |
col label:(LabelAndIcon label:label icon:icon). |
|
1065 |
]. |
|
3887 | 1066 |
(id == #filename) ifTrue:[ |
4027 | 1067 |
self viewType value ifTrue:[ |
1068 |
col readSelector:#baseNameWithOutSuffix |
|
3887 | 1069 |
] ifFalse:[ |
4027 | 1070 |
col readSelector:#baseName |
1071 |
]. |
|
1072 |
] ifFalse:[ |
|
1073 |
(id == #suffix and:[self viewType value not]) ifTrue:[ |
|
1074 |
columns remove:col. |
|
1075 |
] ifFalse:[ |
|
1076 |
(id == #group and:[self viewGroup value not]) ifTrue:[ |
|
1077 |
columns remove:col. |
|
3887 | 1078 |
] ifFalse:[ |
4027 | 1079 |
(id == #owner and:[self viewOwner value not]) ifTrue:[ |
1080 |
columns remove:col. |
|
3887 | 1081 |
] ifFalse:[ |
4027 | 1082 |
(id == #perm and:[self viewPermissions value not]) ifTrue:[ |
3887 | 1083 |
columns remove:col. |
1084 |
] ifFalse:[ |
|
4027 | 1085 |
(id == #preview and:[self viewPreview value not]) ifTrue:[ |
3887 | 1086 |
columns remove:col. |
1087 |
] ifFalse:[ |
|
4027 | 1088 |
(id == #size and:[self viewSize value not]) ifTrue:[ |
3887 | 1089 |
columns remove:col. |
1090 |
] ifFalse:[ |
|
4027 | 1091 |
(id == #time and:[self viewTime value not]) ifTrue:[ |
3887 | 1092 |
columns remove:col. |
1093 |
] ifFalse:[ |
|
4027 | 1094 |
(id == #fileInfo and:[self viewDescription value not]) ifTrue:[ |
3887 | 1095 |
columns remove:col. |
4027 | 1096 |
] |
1097 |
] |
|
3887 | 1098 |
] |
1099 |
] |
|
1100 |
] |
|
1101 |
] |
|
1102 |
] |
|
1103 |
] |
|
1104 |
] |
|
1105 |
] |
|
1106 |
] |
|
1107 |
]. |
|
1108 |
self tableColumns value:columns. |
|
1109 |
self columnDescriptors:(self tableColumns value). |
|
1110 |
! ! |
|
1111 |
||
1112 |
!DirectoryContentsBrowser methodsFor:'drag & drop'! |
|
1113 |
||
3953 | 1114 |
canDrop:aContext |
3887 | 1115 |
|
3953 | 1116 |
^ canDropItem |
3887 | 1117 |
! |
1118 |
||
3953 | 1119 |
doDrop:aContext |
3887 | 1120 |
|
3953 | 1121 |
|col destinationPath receiver| |
3887 | 1122 |
|
3953 | 1123 |
draggedItem isNil ifTrue:[ |
3887 | 1124 |
destinationPath := self directory. |
1125 |
] ifFalse:[ |
|
3953 | 1126 |
destinationPath := self getDirWithoutFileName:(draggedItem fileName). |
4014 | 1127 |
destinationPath baseName = '..' ifTrue:[ |
3953 | 1128 |
destinationPath := self directory directory. |
1129 |
] |
|
3887 | 1130 |
]. |
3953 | 1131 |
self dropLeave:aContext. |
1132 |
aContext dropSource argument == #archivApplication ifTrue:[ |
|
1133 |
receiver := aContext dropSource receiver. |
|
3887 | 1134 |
receiver extractSelectedFilesTo:destinationPath askForExtractOptions:true. |
1135 |
^ true. |
|
1136 |
]. |
|
1137 |
col := OrderedCollection new. |
|
1138 |
aContext dropObjects do:[:obj| |
|
1139 |
col add:(obj theObject). |
|
1140 |
]. |
|
3953 | 1141 |
self copyOrMoveFiles:col to:destinationPath. |
1142 |
^ true. |
|
3887 | 1143 |
! |
1144 |
||
1145 |
doStartDrag:aDropSource in:aView |
|
1146 |
"set the cursors before starting the drag & drop operation |
|
1147 |
" |
|
3983 | 1148 |
|selectedFiles| |
1149 |
||
1150 |
selectedFiles := self selectedFiles. |
|
4014 | 1151 |
(selectedFiles isEmpty) ifTrue:[ |
3887 | 1152 |
^ self. |
1153 |
]. |
|
3953 | 1154 |
^ super doStartDrag:aDropSource in:aView |
1155 |
! |
|
1156 |
||
1157 |
dropEnter:aContext |
|
1158 |
||
1159 |
|dropedObjects| |
|
1160 |
||
1161 |
self dropTargetItemChangedTo:nil in:aContext. |
|
1162 |
inDropMode := false. |
|
1163 |
||
1164 |
self directory isNil ifTrue:[^ self]. |
|
1165 |
dropedObjects := aContext dropObjects. |
|
1166 |
||
1167 |
dropedObjects do:[:aObject| |
|
1168 |
|checkObject checkObjectString| |
|
1169 |
aObject isFileObject ifFalse:[^ self]. |
|
1170 |
checkObject := aObject theObject. |
|
1171 |
checkObject isFilename not ifTrue:[^ self]. |
|
1172 |
((aContext dropSource argument == #archivApplication) not) ifTrue:[ |
|
1173 |
checkObject isSpecialFile ifTrue:[^ self]. |
|
1174 |
checkObject isReadable ifFalse:[^ self]. |
|
1175 |
]. |
|
1176 |
]. |
|
1177 |
inDropMode := true. |
|
3887 | 1178 |
! |
1179 |
||
1180 |
dropLeave:aDropContext |
|
1181 |
||
3953 | 1182 |
inDropMode ifTrue:[ |
1183 |
self dropTargetItemChangedTo:nil in:aDropContext. |
|
1184 |
inDropMode := false. |
|
1185 |
]. |
|
3887 | 1186 |
! |
1187 |
||
3953 | 1188 |
dropOver:aContext |
1189 |
"send the last time, when leaving the widget |
|
1190 |
" |
|
1191 |
|lineNr newDest destinationFile| |
|
1192 |
||
1193 |
inDropMode ifFalse:[^ self]. |
|
1194 |
||
1195 |
lineNr := self getLineNumberFor:aContext. |
|
1196 |
||
1197 |
lineNr notNil ifTrue:[ |
|
3983 | 1198 |
newDest := browserItemList at:lineNr. |
3953 | 1199 |
(newDest notNil and:[newDest isDirectory]) ifTrue:[ |
1200 |
destinationFile := newDest fileName. |
|
4014 | 1201 |
destinationFile baseName = '..' ifTrue:[ |
3953 | 1202 |
destinationFile := self directory directory. |
1203 |
] |
|
1204 |
]. |
|
1205 |
]. |
|
1206 |
newDest == draggedItem ifTrue:[^ self]. |
|
1207 |
||
1208 |
destinationFile isNil ifTrue:[ |
|
1209 |
destinationFile := self directory. |
|
1210 |
]. |
|
3887 | 1211 |
|
3953 | 1212 |
newDest ~~ draggedItem ifTrue:[ |
1213 |
aContext dropSource argument == #archivApplication ifTrue:[ |
|
1214 |
canDropItem := true. |
|
1215 |
] ifFalse:[ |
|
1216 |
canDropItem := self canDropFiles:(aContext dropObjects) for:destinationFile. |
|
1217 |
]. |
|
1218 |
]. |
|
1219 |
self dropTargetItemChangedTo:newDest in:aContext. |
|
1220 |
! |
|
1221 |
||
1222 |
dropTargetItemChangedTo:anItem in:aDropContext |
|
1223 |
||
1224 |
| current | |
|
1225 |
||
1226 |
||
1227 |
"/ (anItem notNil and:[anItem isDirectory]) ifTrue:[ self halt]. |
|
1228 |
current := draggedItem. |
|
3967 | 1229 |
"/ Transcript showCR:'current:', (current isNil ifTrue:['nil'] ifFalse:[current fileName baseName]). |
1230 |
"/ Transcript showCR:'anItem:', (anItem isNil ifTrue:['nil'] ifFalse:[anItem fileName baseName]). |
|
3953 | 1231 |
current == anItem ifTrue:[^ self]. |
1232 |
draggedItem := anItem. |
|
1233 |
||
1234 |
aDropContext contentsWillChange. |
|
1235 |
||
1236 |
current ifNotNil:[ |
|
1237 |
current isDirectory ifTrue:[ |
|
1238 |
current icon:(self getIconFor:current). |
|
1239 |
]. |
|
1240 |
]. |
|
1241 |
||
1242 |
anItem ifNotNil:[ |
|
1243 |
anItem isDirectory ifTrue:[ |
|
1244 |
anItem icon:(FileBrowser iconForKeyMatching:#directoryOpenGray). |
|
1245 |
]. |
|
1246 |
]. |
|
3983 | 1247 |
contentsBrowser shown ifTrue:[ |
1248 |
contentsBrowser invalidateVisibleRow:current colAt:iconIndex. |
|
1249 |
contentsBrowser invalidateVisibleRow:anItem colAt:iconIndex. |
|
1250 |
contentsBrowser repairDamage. |
|
3953 | 1251 |
]. |
3887 | 1252 |
! |
1253 |
||
1254 |
getDisplayObjects:anArgument |
|
1255 |
||
3983 | 1256 |
| selectedFiles string fnName stream| |
1257 |
selectedFiles := self selectedFiles. |
|
1258 |
selectedFiles isEmpty ifTrue:[ ^ '']. |
|
3887 | 1259 |
stream := WriteStream on:''. |
3983 | 1260 |
|
1261 |
stream nextPutAll:(selectedFiles first baseName). |
|
1262 |
selectedFiles size == 1 ifTrue:[ |
|
3887 | 1263 |
fnName := 'ui_menuitem.xpm'. |
1264 |
] ifFalse:[ |
|
1265 |
fnName := 'ui_submenu_open.xpm'. |
|
1266 |
stream nextPutAll:' ... '. |
|
3983 | 1267 |
stream nextPutAll:(selectedFiles last baseName). |
3887 | 1268 |
]. |
1269 |
string := stream contents. |
|
1270 |
stream close. |
|
1271 |
^ Array with:(LabelAndIcon icon:(Image fromFile:fnName) |
|
1272 |
string:(Text string:string emphasis:#bold) |
|
1273 |
) |
|
1274 |
! |
|
1275 |
||
1276 |
getDropObjects:anArgument |
|
1277 |
||
3983 | 1278 |
^ self selectedFiles collect:[:file| DropObject newFile:file]. |
3887 | 1279 |
! |
1280 |
||
1281 |
getLineNumberFor:aDropContext |
|
1282 |
| yVisible| |
|
1283 |
||
1284 |
yVisible := (aDropContext targetPoint y). |
|
3983 | 1285 |
^ contentsBrowser yVisibleToRowNr:yVisible. |
3887 | 1286 |
! ! |
1287 |
||
1288 |
!DirectoryContentsBrowser methodsFor:'event handling'! |
|
1289 |
||
1290 |
processEvent:anEvent |
|
1291 |
"filter keyboard events. |
|
1292 |
Return true, if I have eaten the event" |
|
1293 |
||
1294 |
|focusView key rawKey| |
|
1295 |
||
1296 |
anEvent isKeyPressEvent ifTrue:[ |
|
1297 |
focusView := anEvent targetView. |
|
1298 |
key := anEvent key. |
|
1299 |
rawKey := anEvent rawKey. |
|
1300 |
||
3983 | 1301 |
(focusView == contentsBrowser) ifTrue:[ |
3887 | 1302 |
"/ (key ~= #'Alt_L') ifTrue:[self halt.]. |
1303 |
key == #Paste ifTrue:[ |
|
1304 |
self pasteFiles. |
|
1305 |
^ true. |
|
1306 |
]. |
|
3983 | 1307 |
(key == #CursorLeft) ifTrue:[ |
1308 |
self doGoDirectoryUp. |
|
1309 |
^ true |
|
1310 |
]. |
|
1311 |
(key == #CursorRight) ifTrue:[ |
|
1312 |
self doBack. |
|
1313 |
^ true |
|
1314 |
]. |
|
1315 |
browserItemList size == 0 ifTrue:[ |
|
3887 | 1316 |
^ false |
1317 |
]. |
|
1318 |
key == #Copy ifTrue:[ |
|
1319 |
self doCopy. |
|
1320 |
^ true. |
|
1321 |
]. |
|
1322 |
(key == #Return) ifTrue:[ |
|
1323 |
self doOpenSelectedFile. |
|
1324 |
^ true. |
|
1325 |
]. |
|
1326 |
key == #Delete ifTrue:[ |
|
1327 |
self doDelete. |
|
1328 |
^ true. |
|
1329 |
]. |
|
1330 |
key == #Cut ifTrue:[ |
|
1331 |
self doCut. |
|
1332 |
^ true. |
|
1333 |
]. |
|
1334 |
] |
|
1335 |
]. |
|
1336 |
^ false |
|
1337 |
! ! |
|
1338 |
||
1339 |
!DirectoryContentsBrowser methodsFor:'file actions'! |
|
1340 |
||
1341 |
doCopy |
|
1342 |
"copy current selected files/directories |
|
1343 |
" |
|
1344 |
||
3983 | 1345 |
self copyFilesToClipBoard:(self selectedFiles). |
3887 | 1346 |
! |
1347 |
||
1348 |
doCut |
|
1349 |
"cut current selected files/directories |
|
1350 |
" |
|
1351 |
||
3983 | 1352 |
self cutFilesToClipBoard:(self selectedFiles). |
3887 | 1353 |
! |
1354 |
||
1355 |
doDelete |
|
1356 |
"delete current selected files/directories |
|
1357 |
" |
|
3983 | 1358 |
self deleteFiles:(self selectedFiles). |
3887 | 1359 |
! ! |
1360 |
||
1361 |
!DirectoryContentsBrowser methodsFor:'menu accessing'! |
|
1362 |
||
1363 |
viewBrowserMenu |
|
1364 |
||
1365 |
<resource: #programMenu > |
|
1366 |
||
1367 |
|menu| |
|
1368 |
||
3961 | 1369 |
viewBrowserMenu isNil ifTrue:[ |
1370 |
viewBrowserMenu := self class viewBrowserMenu. |
|
1371 |
]. |
|
1372 |
viewBrowserMenu ifNil:[ ^ nil ]. |
|
1373 |
menu := viewBrowserMenu. |
|
3887 | 1374 |
menu receiver:self. |
1375 |
^ menu |
|
1376 |
! ! |
|
1377 |
||
1378 |
!DirectoryContentsBrowser methodsFor:'menu actions'! |
|
1379 |
||
1380 |
doOpenSelectedFile |
|
1381 |
||
4017 | 1382 |
| selectedItems| |
1383 |
||
1384 |
selectedItems := self selectedItems. |
|
1385 |
(selectedItems size == 1) ifTrue:[ |
|
1386 |
self enterActionFor:(selectedItems first). |
|
3887 | 1387 |
]. |
1388 |
! |
|
1389 |
||
1390 |
doShowFileContents |
|
1391 |
||
3983 | 1392 |
| selectedFileItems| |
1393 |
||
1394 |
selectedFileItems := self selectedFileItems. |
|
1395 |
(selectedFileItems size == 1) ifTrue:[ |
|
1396 |
self openTextEditorOn:(selectedFileItems first). |
|
3887 | 1397 |
]. |
1398 |
! ! |
|
1399 |
||
1400 |
!DirectoryContentsBrowser methodsFor:'queries'! |
|
1401 |
||
1402 |
allItemsOfCurrentDirectory |
|
1403 |
||
3983 | 1404 |
| list | |
1405 |
list := browserItemList copy. |
|
1406 |
self viewDirectoriesInDirectoryContentsBrowser value ifTrue:[ |
|
1407 |
list removeIdentical:(browserItemList first) ifAbsent:[nil] |
|
1408 |
]. |
|
1409 |
^ list. |
|
3887 | 1410 |
! |
1411 |
||
1412 |
fileListIsEmpty |
|
1413 |
||
3983 | 1414 |
^ browserItemList isEmpty |
3887 | 1415 |
! |
1416 |
||
1417 |
getAllFilesAsStringCollection |
|
1418 |
|files items| |
|
1419 |
||
3983 | 1420 |
items := browserItemList. |
3887 | 1421 |
files := OrderedCollection new. |
1422 |
items isEmpty ifTrue:[ |
|
1423 |
^ files |
|
1424 |
]. |
|
1425 |
items do:[:aItem | |
|
1426 |
aItem isDirectory not ifTrue:[ |
|
1427 |
files add:aItem fileName asString |
|
1428 |
]. |
|
1429 |
]. |
|
1430 |
^ files. |
|
4004 | 1431 |
! |
1432 |
||
1433 |
hasFilesFiltered |
|
4017 | 1434 |
^ allItemsList size ~~ browserItemList size |
3983 | 1435 |
! ! |
1436 |
||
1437 |
!DirectoryContentsBrowser methodsFor:'selection'! |
|
1438 |
||
1439 |
firstSelectedItem |
|
1440 |
||
1441 |
^ self selectedItems first. |
|
3887 | 1442 |
! |
1443 |
||
3983 | 1444 |
selectAll |
1445 |
||
1446 |
| sel| |
|
1447 |
||
1448 |
sel := browserItemList copy. |
|
4013 | 1449 |
self viewDirectoriesInDirectoryContentsBrowser value ifTrue:[ |
1450 |
sel removeIdentical:(browserItemList first) ifAbsent:[nil] |
|
3887 | 1451 |
]. |
3983 | 1452 |
self selectionInFileList value:sel. |
3887 | 1453 |
! |
1454 |
||
4017 | 1455 |
selectCurrentFiles |
1456 |
||
1457 |
|currentSelection| |
|
1458 |
||
1459 |
((currentSelection := self currentFileNameHolder value select:[:file| file isDirectory not]) notEmpty) ifTrue:[ |
|
1460 |
self selectFiles:currentSelection. |
|
1461 |
]. |
|
1462 |
! |
|
1463 |
||
3983 | 1464 |
selectFiles:aColOfFilenames |
1465 |
| curSel newSel| |
|
1466 |
||
1467 |
curSel := self selectedFiles. |
|
1468 |
aColOfFilenames size = curSel size ifTrue:[ |
|
1469 |
| index | |
|
1470 |
index := curSel findFirst:[:file| (aColOfFilenames includes:file) not]. |
|
1471 |
index == 0 ifTrue:[ ^ self]. |
|
3887 | 1472 |
]. |
3983 | 1473 |
newSel := OrderedCollection new. |
1474 |
browserItemList do:[: item| |
|
1475 |
(aColOfFilenames includes:(item fileName)) ifTrue:[ |
|
1476 |
newSel add:item. |
|
1477 |
]. |
|
3887 | 1478 |
]. |
4017 | 1479 |
self updateToExternFileHolderLock doLocked:[ |
1480 |
self selectionInFileList value:newSel. |
|
1481 |
]. |
|
3983 | 1482 |
! |
1483 |
||
1484 |
selectedFileItems |
|
1485 |
||
1486 |
| sel | |
|
1487 |
||
3985 | 1488 |
sel := self selectedItems select:[:item | item isDirectory not]. |
3987 | 1489 |
^ sel |
1490 |
! |
|
1491 |
||
1492 |
selectedFileNames |
|
1493 |
^ self selectedFileItems collect:[:item| item fileName]. |
|
3887 | 1494 |
! |
1495 |
||
3983 | 1496 |
selectedFiles |
1497 |
||
1498 |
^ self selectedItems collect:[: item| item fileName]. |
|
1499 |
! |
|
1500 |
||
1501 |
selectedItems |
|
1502 |
||
1503 |
| sel | |
|
1504 |
sel := self selectionInFileList value copy. |
|
1505 |
sel isNil ifTrue:[ ^ #()]. |
|
4017 | 1506 |
(self viewDirectoriesInDirectoryContentsBrowser value and:[browserItemList notEmpty]) ifTrue:[ |
3983 | 1507 |
sel removeIdentical:(browserItemList first) ifAbsent:[nil] |
3887 | 1508 |
]. |
4013 | 1509 |
^ sel. |
3887 | 1510 |
! ! |
1511 |
||
1512 |
!DirectoryContentsBrowser methodsFor:'startup / release'! |
|
1513 |
||
1514 |
makeDependent |
|
1515 |
||
4007 | 1516 |
super makeDependent. |
3887 | 1517 |
self currentFileNameHolder addDependent:self. |
4027 | 1518 |
self currentSortOrder addDependent:self. |
3887 | 1519 |
self viewDirectoriesInDirectoryContentsBrowser addDependent:self. |
4011 | 1520 |
self filterBlockHolder addDependent:self. |
3887 | 1521 |
self sortBlockHolder addDependent:self. |
1522 |
self viewDescription onChangeSend:#viewedColumnsChanged to:self. |
|
1523 |
self viewDetails onChangeSend:#viewedColumnsChanged to:self. |
|
1524 |
self viewGroup onChangeSend:#viewedColumnsChanged to:self. |
|
1525 |
self viewOwner onChangeSend:#viewedColumnsChanged to:self. |
|
1526 |
self viewPermissions onChangeSend:#viewedColumnsChanged to:self. |
|
1527 |
self viewPreview onChangeSend:#viewedColumnsChanged to:self. |
|
1528 |
self viewSize onChangeSend:#viewedColumnsChanged to:self. |
|
1529 |
self viewTime onChangeSend:#viewedColumnsChanged to:self. |
|
1530 |
self viewType onChangeSend:#viewedColumnsChanged to:self. |
|
1531 |
! |
|
1532 |
||
1533 |
postBuildBrowser:aWidget |
|
1534 |
||
3983 | 1535 |
contentsBrowser := aWidget scrolledView. |
1536 |
contentsBrowser wantsFocusWithPointerEnter. |
|
3887 | 1537 |
"/ dont register icons anymore |
1538 |
"/ FileBrowser icons keysAndValuesDo:[:aKey :anIcon| |
|
1539 |
"/ browser registerImage:anIcon key:aKey. |
|
1540 |
"/ ]. |
|
1541 |
self columnDescriptors:(self class tableColumns). |
|
1542 |
! |
|
1543 |
||
1544 |
postBuildWith:aBuilder |
|
1545 |
||
4017 | 1546 |
updateContentsTask := DirectoryContentsUpdateTask new startWith:self. |
3887 | 1547 |
self viewedColumnsChanged. |
4017 | 1548 |
self filterBlockHolder changed. |
3887 | 1549 |
^ super postBuildWith:aBuilder. |
1550 |
! |
|
1551 |
||
1552 |
postOpenAsSubcanvasWith:aBuilder |
|
1553 |
||
1554 |
self windowGroup addPreEventHook:self. |
|
1555 |
^ super postOpenAsSubcanvasWith:aBuilder. |
|
1556 |
! |
|
1557 |
||
1558 |
postOpenWith:aBuilder |
|
1559 |
||
1560 |
" |
|
1561 |
only invoked if the application not started from a master |
|
1562 |
" |
|
4017 | 1563 |
updateContentsTask := DirectoryContentsUpdateTask new startWith:self. |
1564 |
self viewedColumnsChanged. |
|
1565 |
self filterBlockHolder changed. |
|
3887 | 1566 |
self currentFileNameHolder changed. |
1567 |
self windowGroup addPreEventHook:self. |
|
1568 |
^ super postOpenWith:aBuilder. |
|
1569 |
! |
|
1570 |
||
1571 |
preBuildWith:aBuilder |
|
1572 |
||
1573 |
self masterApplication isNil ifTrue:[ |
|
1574 |
self masterApplication:nil. |
|
1575 |
]. |
|
1576 |
^ super preBuildWith:aBuilder. |
|
1577 |
! |
|
1578 |
||
1579 |
release |
|
1580 |
"release my resources |
|
1581 |
" |
|
1582 |
self updateColumnsTaskStop. |
|
1583 |
self updateDirectoryContentsTaskStop. |
|
4017 | 1584 |
updateContentsTask stop. |
3887 | 1585 |
super release. |
1586 |
! |
|
1587 |
||
1588 |
releaseAsSubCanvas |
|
1589 |
||
1590 |
self updateColumnsTaskStop. |
|
1591 |
self updateDirectoryContentsTaskStop. |
|
1592 |
^ super releaseAsSubCanvas. |
|
1593 |
! ! |
|
1594 |
||
1595 |
!DirectoryContentsBrowser methodsFor:'task update columns'! |
|
1596 |
||
4017 | 1597 |
findNextItemFor:aBlock |
1598 |
||
1599 |
^ allItemsList detect:aBlock ifNone:[nil]. |
|
1600 |
! |
|
1601 |
||
1602 |
findNextVisibleItemFor:aConditionBlock |
|
3983 | 1603 |
|vis idx stillSearching | |
1604 |
||
1605 |
vis := contentsBrowser indexOfFirstRowShown. |
|
3887 | 1606 |
vis = 0 ifTrue:[vis := 1]. |
3983 | 1607 |
|
1608 |
idx := vis. |
|
1609 |
stillSearching := true. |
|
1610 |
[ stillSearching ] whileTrue:[ |
|
1611 |
((idx <= browserItemList size) and:[ (contentsBrowser isRowVisible:idx) ]) ifFalse:[ |
|
1612 |
stillSearching := false. |
|
1613 |
idx := nil. |
|
1614 |
] ifTrue:[ |
|
1615 |
(aConditionBlock value:(browserItemList at:idx)) ifTrue:[ |
|
1616 |
"/ found a one |
|
1617 |
stillSearching := false. |
|
1618 |
] ifFalse:[ |
|
1619 |
idx := idx + 1. |
|
1620 |
] |
|
1621 |
]. |
|
3887 | 1622 |
]. |
3983 | 1623 |
idx isNil ifTrue:[^ nil]. |
1624 |
^ browserItemList at:idx ifAbsent:nil |
|
3887 | 1625 |
! |
1626 |
||
1627 |
getFileInfoFor:aItem |
|
1628 |
||
1629 |
| type| |
|
1630 |
||
1631 |
type := aItem fileName fileType. |
|
1632 |
aItem fileType:type. |
|
1633 |
^ type |
|
1634 |
! |
|
1635 |
||
1636 |
getIconFor:aItem |
|
1637 |
||
1638 |
| key icon| |
|
3906 | 1639 |
|
3887 | 1640 |
key := aItem iconKey. |
1641 |
icon := FileBrowser iconForKeyMatching:key. |
|
3906 | 1642 |
aItem isRemoteDirectory ifTrue:[ |
1643 |
^ icon "/ do not query attributes |
|
1644 |
]. |
|
3887 | 1645 |
^ FileBrowser addOnIconsFor:(aItem fileName) to:icon. |
1646 |
! |
|
1647 |
||
1648 |
getIconForMimeTypeByContents:aItem |
|
1649 |
||
1650 |
| currentIcon newIcon icon| |
|
1651 |
newIcon := FileBrowser iconForKeyMatching:(aItem mimeTypeForContents). |
|
1652 |
currentIcon := aItem icon. |
|
1653 |
(currentIcon class == MultiImage) ifTrue:[ |
|
1654 |
| images | |
|
1655 |
images := currentIcon images. |
|
1656 |
images removeFirst. |
|
1657 |
images addFirst:newIcon. |
|
1658 |
icon := currentIcon. |
|
1659 |
] ifFalse:[ |
|
1660 |
icon := newIcon. |
|
1661 |
]. |
|
1662 |
^ icon |
|
1663 |
! |
|
1664 |
||
1665 |
getPreviewFor:aItem |
|
1666 |
||
1667 |
| column icon| |
|
1668 |
||
3983 | 1669 |
column := contentsBrowser columnAt:previewIndex. |
3887 | 1670 |
column isNil ifTrue:[ |
1671 |
previewIndex := 0. |
|
1672 |
] ifFalse:[ |
|
1673 |
(aItem hasMimeType and:[aItem mimeType isImage]) ifTrue:[ |
|
1674 |
Exception handle:[:ex| |
|
1675 |
icon := nil. |
|
1676 |
] do:[ |scale extent w h | |
|
3983 | 1677 |
icon := Image fromFile:(aItem fileName pathName). |
3887 | 1678 |
icon notNil ifTrue:[ |
1679 |
extent := icon extent. |
|
1680 |
w := column width - 4. |
|
1681 |
h := column height. |
|
1682 |
||
1683 |
(extent x > w or:[extent y > h]) ifTrue:[ |
|
1684 |
scale := extent / (w@h). |
|
1685 |
scale := scale x max:(scale y). |
|
1686 |
icon := icon magnifiedTo:((extent / scale max:8.0) asInteger). |
|
1687 |
]. |
|
3983 | 1688 |
icon := icon onDevice:(contentsBrowser device). |
3887 | 1689 |
icon clearMaskedPixels. |
1690 |
] |
|
1691 |
] |
|
1692 |
] ifFalse:[ icon := nil]. |
|
1693 |
aItem preview:(icon ? ''). |
|
1694 |
]. |
|
1695 |
^ icon |
|
1696 |
! |
|
1697 |
||
1698 |
updateChangesFor:aItem |
|
1699 |
||
3983 | 1700 |
aItem resetItemForChanges. |
3887 | 1701 |
! |
1702 |
||
1703 |
updateColumnsTaskCycle |
|
1704 |
||
1705 |
" update items in the foolowing order |
|
1706 |
- update item if item properties are changed |
|
1707 |
- update icon for visible items by suffix |
|
1708 |
- update icon for visible items by contents |
|
1709 |
- update file info for visible items if file info column is shown |
|
1710 |
- update preview for visible items if preview column is shown |
|
1711 |
||
1712 |
- update icon for invisible items by suffix |
|
1713 |
- update icon for invisible items by contents |
|
1714 |
- update file info for invisible items if file info column is shown |
|
1715 |
- update preview for invisible items if preview column is shown |
|
1716 |
- update file info for invisible items if file info column is not shown |
|
1717 |
" |
|
1718 |
||
1719 |
|desc icon type preview| |
|
1720 |
||
4017 | 1721 |
browserItemList notEmpty ifTrue:[ |
3887 | 1722 |
"/ update item if item properties are changed |
4017 | 1723 |
desc := self findNextVisibleItemFor:[:n| n hasBeenModified ]. |
3887 | 1724 |
|
1725 |
desc notNil ifTrue:[ |
|
3983 | 1726 |
contentsBrowser invalidateVisibleRow:desc. |
3887 | 1727 |
self updateChangesFor:desc. |
1728 |
^ true. |
|
1729 |
]. |
|
1730 |
"/ update icon for visible items by suffix |
|
4017 | 1731 |
desc := self findNextVisibleItemFor:[:n| n icon isNil ]. |
3967 | 1732 |
desc notNil ifTrue:[ |
3887 | 1733 |
icon := self getIconFor:desc. |
1734 |
desc icon:icon. |
|
1735 |
(icon notNil and:[iconIndex ~~ 0]) ifTrue:[ |
|
3983 | 1736 |
contentsBrowser invalidateVisibleRow:desc colAt:iconIndex |
3887 | 1737 |
]. |
1738 |
^ true |
|
1739 |
]. |
|
1740 |
"/ update icon for visible items by contents |
|
4017 | 1741 |
desc := self findNextVisibleItemFor:[:n| |
3967 | 1742 |
(n iconKey == #file |
1743 |
and:[n mimeTypeForContents asSymbol ~= #unknown]) |
|
1744 |
]. |
|
1745 |
desc notNil ifTrue:[ |
|
1746 |
icon := self getIconForMimeTypeByContents:desc. |
|
1747 |
desc icon:icon. |
|
1748 |
(icon notNil and:[iconIndex ~~ 0]) ifTrue:[ |
|
3983 | 1749 |
contentsBrowser invalidateVisibleRow:desc colAt:iconIndex |
3967 | 1750 |
]. |
1751 |
^ true |
|
1752 |
]. |
|
3887 | 1753 |
"/ update file info for visible items if file info column is shown |
1754 |
fileDescriptionIndex ~~ 0 ifTrue:[ |
|
4017 | 1755 |
desc := self findNextVisibleItemFor:[:n| n fileType isNil ]. |
3887 | 1756 |
desc notNil ifTrue:[ |
1757 |
type := self getFileInfoFor:desc. |
|
3983 | 1758 |
type notNil ifTrue:[contentsBrowser invalidateVisibleRow:desc colAt:fileDescriptionIndex]. |
3887 | 1759 |
^ true |
1760 |
] |
|
1761 |
]. |
|
1762 |
"/ update preview for visible items if preview column is shown |
|
1763 |
previewIndex ~~ 0 ifTrue:[ |
|
4017 | 1764 |
desc := self findNextVisibleItemFor:[:n| n preview isNil ]. |
3887 | 1765 |
desc notNil ifTrue:[ |
1766 |
preview := self getPreviewFor:desc. |
|
1767 |
preview notNil ifTrue:[ |
|
3983 | 1768 |
contentsBrowser invalidateVisibleRow:desc colAt:previewIndex |
3887 | 1769 |
]. |
1770 |
^ true |
|
1771 |
] |
|
1772 |
]. |
|
1773 |
]. |
|
1774 |
||
1775 |
"/ may we want to see the other items later make this items to |
|
1776 |
allItemsList notEmpty ifTrue:[ |
|
1777 |
"/ update icon for invisible items by suffix |
|
1778 |
desc := self findNextItemFor:[:n| n icon isNil ]. |
|
1779 |
desc notNil ifTrue:[ |
|
1780 |
icon := self getIconFor:desc. |
|
1781 |
desc icon:icon. |
|
1782 |
^ true |
|
1783 |
]. |
|
1784 |
"/ update icon for invisible items by contents |
|
1785 |
desc := self findNextItemFor:[:n| (n iconKey == #file and:[n mimeTypeForContents ~= #unknown])]. |
|
1786 |
desc notNil ifTrue:[ |
|
1787 |
icon := self getIconForMimeTypeByContents:desc. |
|
1788 |
desc icon:icon. |
|
1789 |
^ true |
|
1790 |
]. |
|
1791 |
"/ update file info for invisible items if file info column is shown |
|
1792 |
fileDescriptionIndex ~~ 0 ifTrue:[ |
|
1793 |
desc := self findNextItemFor:[:n| n fileType isNil ]. |
|
1794 |
desc notNil ifTrue:[ |
|
1795 |
self getFileInfoFor:desc. |
|
1796 |
^ true |
|
1797 |
]. |
|
1798 |
]. |
|
1799 |
"/ update preview for invisible items if preview column is shown |
|
1800 |
previewIndex ~~ 0 ifTrue:[ |
|
1801 |
desc := self findNextItemFor:[:n| n preview isNil ]. |
|
1802 |
desc notNil ifTrue:[ |
|
1803 |
self getPreviewFor:desc. |
|
1804 |
^ true |
|
1805 |
]. |
|
1806 |
]. |
|
1807 |
"/ update file info for invisible items if file info column is not shown |
|
1808 |
desc := self findNextItemFor:[:n| n fileType isNil ]. |
|
1809 |
desc notNil ifTrue:[ |
|
1810 |
self getFileInfoFor:desc. |
|
1811 |
^ true |
|
1812 |
]. |
|
1813 |
]. |
|
1814 |
^ false |
|
1815 |
! |
|
1816 |
||
1817 |
updateColumnsTaskStart |
|
1818 |
||
4017 | 1819 |
| somethigToDo process| |
1820 |
||
3887 | 1821 |
self directory notNil ifTrue:[ |
4017 | 1822 |
process := [ |
3887 | 1823 |
[ |
1824 |
[true] whileTrue:[ |
|
1825 |
somethigToDo := false. |
|
4017 | 1826 |
(self directory notNil) ifTrue:[ |
3887 | 1827 |
somethigToDo := self updateColumnsTaskCycle. |
1828 |
Processor yield. |
|
1829 |
]. |
|
1830 |
somethigToDo ifFalse:[ |
|
1831 |
Delay waitForSeconds:1.0 |
|
4017 | 1832 |
]. |
3887 | 1833 |
] |
1834 |
] valueNowOrOnUnwindDo:[ |
|
1835 |
self updateColumnsTask:nil. |
|
1836 |
] |
|
1837 |
] newProcess. |
|
3983 | 1838 |
"/ p priority:(Processor systemBackgroundPriority). |
4017 | 1839 |
process priorityRange:(Processor userBackgroundPriority to:Processor activePriority). |
1840 |
||
1841 |
self updateColumnsTask: process. |
|
3887 | 1842 |
self updateColumnsTask name:('DirectoryContentsBrowser update columns[', self directory baseName, ']'). |
1843 |
self updateColumnsTask resume. |
|
1844 |
] |
|
1845 |
! |
|
1846 |
||
1847 |
updateColumnsTaskStop |
|
1848 |
|task| |
|
1849 |
||
1850 |
(task := self updateColumnsTask) notNil ifTrue:[ |
|
1851 |
self updateColumnsTask:nil. |
|
1852 |
||
1853 |
Object errorSignal handle:[:ex| |
|
1854 |
Dialog warn:ex description. |
|
1855 |
]do:[ |
|
1856 |
task isDead ifFalse:[ |
|
3919 | 1857 |
task terminateWithAllSubprocessesInGroup. |
3887 | 1858 |
task waitUntilTerminated. |
1859 |
] |
|
1860 |
] |
|
1861 |
]. |
|
1862 |
! ! |
|
1863 |
||
4017 | 1864 |
!DirectoryContentsBrowser methodsFor:'task update contents'! |
3887 | 1865 |
|
1866 |
updateDirectoryContentsTaskCycle |
|
1867 |
||
1868 |
| contents| |
|
1869 |
||
4017 | 1870 |
"/ DIRECTORY CONTENTS HAVE CHANGED |
3887 | 1871 |
(modificationTime ~= self directory modificationTime) ifTrue:[ |
1872 |
modificationTime := self directory modificationTime. |
|
1873 |
contents := self directory directoryContentsAsFilenames. |
|
1874 |
contents size == 0 ifTrue:[ |
|
1875 |
allItemsList removeAll. |
|
1876 |
] ifFalse:[ |
|
1877 |
"/ MERGE WITH CURRENT CONTENTS |
|
1878 |
allItemsList reverseDo:[:aDesc| |
|
1879 |
"/ remove no longer valid files |
|
1880 |
(contents detect:[:f| aDesc fileName = f] ifNone:nil) isNil ifTrue:[ |
|
1881 |
allItemsList removeIdentical:aDesc |
|
1882 |
] |
|
1883 |
]. |
|
1884 |
allItemsList size ~~ contents size ifTrue:[ |
|
1885 |
"/ add new files |
|
1886 |
| addedFiles | |
|
1887 |
addedFiles := OrderedCollection new. |
|
1888 |
contents reverseDo:[:aFile| |
|
3983 | 1889 |
(allItemsList contains:[:item| item fileName = aFile]) ifTrue:[ |
1890 |
addedFiles add:(DirectoryContentsItem fileName:aFile) |
|
3887 | 1891 |
] |
1892 |
]. |
|
1893 |
allItemsList addAll:addedFiles. |
|
1894 |
] |
|
1895 |
]. |
|
4017 | 1896 |
"/ because this can be invoked by a background task, |
1897 |
"/ ensure that we syncronize this operation with the main browsers GUI |
|
1898 |
"/ (i.e. avoid changing the list, while the main process loops over it in |
|
1899 |
"/ a redraw, select etc.) |
|
1900 |
self enqueueMessage:#value for:[self evaluateItems] arguments:nil. |
|
3887 | 1901 |
]. |
1902 |
! |
|
1903 |
||
1904 |
updateDirectoryContentsTaskStart |
|
1905 |
|p| |
|
1906 |
||
1907 |
self directory notNil ifTrue:[ |
|
1908 |
p := [ |
|
1909 |
[ |
|
1910 |
[true] whileTrue:[ |
|
3983 | 1911 |
(contentsBrowser shown and:[self directory notNil]) ifTrue:[ |
3887 | 1912 |
self updateDirectoryContentsTaskCycle. |
1913 |
Processor yield. |
|
1914 |
]. |
|
1915 |
Delay waitForSeconds:1.0 |
|
1916 |
] |
|
1917 |
] valueNowOrOnUnwindDo:[ |
|
1918 |
self updateDirectoryContentsTask:nil. |
|
1919 |
self updateColumnsTaskStop. |
|
1920 |
] |
|
1921 |
] newProcess. |
|
1922 |
||
3983 | 1923 |
"/ p priority:(Processor systemBackgroundPriority). |
1924 |
p priorityRange:(Processor userBackgroundPriority to:Processor activePriority). |
|
3887 | 1925 |
self updateDirectoryContentsTask:p. |
1926 |
||
1927 |
p name:('DirectoryContentsBrowser update contents[', self directory baseName, ']'). |
|
1928 |
p resume. |
|
1929 |
] |
|
1930 |
! |
|
1931 |
||
1932 |
updateDirectoryContentsTaskStop |
|
1933 |
|task| |
|
1934 |
||
1935 |
(task := self updateDirectoryContentsTask) notNil ifTrue:[ |
|
1936 |
self updateDirectoryContentsTask:nil. |
|
1937 |
||
1938 |
Object errorSignal handle:[:ex| |
|
1939 |
Dialog warn:ex description. |
|
1940 |
]do:[ |
|
1941 |
task isDead ifFalse:[ |
|
3919 | 1942 |
task terminateWithAllSubprocessesInGroup. |
3887 | 1943 |
task waitUntilTerminated. |
1944 |
] |
|
1945 |
] |
|
1946 |
]. |
|
1947 |
! ! |
|
1948 |
||
1949 |
!DirectoryContentsBrowser::DirectoryContentsItem class methodsFor:'instance creation'! |
|
1950 |
||
3983 | 1951 |
fileName:aFilename |
1952 |
||
3999
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
1953 |
| instance fileItem| |
3983 | 1954 |
instance := self new. |
1955 |
aFilename asString = '..' ifTrue:[ |
|
1956 |
instance fileName:aFilename. |
|
1957 |
^ instance. |
|
1958 |
]. |
|
3999
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
1959 |
fileItem := DirectoryContents contentsItemForFileName:aFilename. |
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
1960 |
fileItem notNil ifTrue:[^ self forInfoItem:fileItem]. |
3983 | 1961 |
^ nil |
3999
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
1962 |
|
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
1963 |
" |
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
1964 |
DirectoryContentsItem fileName:'..' |
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
1965 |
" |
3983 | 1966 |
! |
1967 |
||
1968 |
forInfoItem:anItem |
|
3887 | 1969 |
| instance | |
1970 |
instance := self new. |
|
3983 | 1971 |
instance fileName:anItem fileName. |
1972 |
anItem isRemoteDirectory ifTrue:[ |
|
1973 |
instance beRemoteDirectory. |
|
1974 |
] ifFalse:[ |
|
1975 |
instance fileInfo:anItem info. |
|
1976 |
]. |
|
3906 | 1977 |
^ instance |
3887 | 1978 |
! ! |
1979 |
||
1980 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'accessing'! |
|
1981 |
||
3983 | 1982 |
fileInfo:something |
1983 |
"set the value of the instance variable 'fileInfo' (automatically generated)" |
|
1984 |
||
1985 |
fileInfo := something. |
|
1986 |
! |
|
1987 |
||
3887 | 1988 |
fileName |
1989 |
"returns the fileName |
|
1990 |
" |
|
1991 |
^ fileName |
|
4023 | 1992 |
|
1993 |
||
3887 | 1994 |
! |
1995 |
||
1996 |
fileName:aFilename |
|
1997 |
"set fileName for instance |
|
1998 |
" |
|
1999 |
fileName := aFilename. |
|
2000 |
! |
|
2001 |
||
2002 |
fileType |
|
2003 |
"returns the type of the file |
|
2004 |
" |
|
2005 |
||
2006 |
^ fileType |
|
2007 |
! |
|
2008 |
||
2009 |
fileType:aType |
|
2010 |
"returns the type of the file |
|
2011 |
" |
|
2012 |
||
2013 |
fileType := aType. |
|
2014 |
! |
|
2015 |
||
2016 |
icon |
|
2017 |
"returns the icon assigned to the file |
|
2018 |
" |
|
2019 |
^ icon |
|
2020 |
||
2021 |
||
2022 |
! |
|
2023 |
||
2024 |
icon:anIcon |
|
2025 |
||
2026 |
icon := anIcon. |
|
2027 |
! |
|
2028 |
||
2029 |
iconKey |
|
2030 |
"return the value of the instance variable 'iconKey' (automatically generated)" |
|
2031 |
||
2032 |
iconKey isNil ifTrue:[ |
|
3906 | 2033 |
self isRemoteDirectory ifTrue:[ |
2034 |
iconKey := FileBrowser iconKeyForRemoteDirectory:fileName. |
|
2035 |
] ifFalse:[ |
|
2036 |
iconKey := FileBrowser iconKeyForFile:fileName. |
|
2037 |
] |
|
3887 | 2038 |
]. |
2039 |
^ iconKey |
|
2040 |
! |
|
2041 |
||
2042 |
isDirectory |
|
3967 | 2043 |
self isRemoteDirectory ifTrue:[^ true]. |
2044 |
||
2045 |
self getFileInfo. |
|
2046 |
fileInfo isNil ifTrue:[^ false]. |
|
2047 |
^ fileInfo isDirectory |
|
2048 |
! |
|
3887 | 2049 |
|
3967 | 2050 |
isSymbolicLink |
2051 |
self isRemoteDirectory ifTrue:[^ false]. |
|
2052 |
||
2053 |
self getFileInfo. |
|
2054 |
fileInfo isNil ifTrue:[^ false]. |
|
2055 |
^ fileInfo isSymbolicLink |
|
3887 | 2056 |
! |
2057 |
||
2058 |
lastButOneSuffix |
|
2059 |
"returns the suffix of the file |
|
2060 |
" |
|
2061 |
||
2062 |
^ self suffixes at:2 |
|
2063 |
! |
|
2064 |
||
2065 |
lastSuffix |
|
2066 |
"returns the suffix of the file |
|
2067 |
" |
|
2068 |
||
2069 |
^ self suffixes at:1 |
|
2070 |
! |
|
2071 |
||
2072 |
mimeType |
|
2073 |
"return the value of the instance variable 'mimeType' (automatically generated)" |
|
2074 |
||
2075 |
mimeType isNil ifTrue:[ |
|
2076 |
mimeType := MIMETypes mimeTypeForFilename:(self fileName). |
|
2077 |
mimeType isNil ifTrue:[ |
|
2078 |
mimeType := #unknown |
|
2079 |
] |
|
2080 |
]. |
|
2081 |
^ mimeType |
|
2082 |
! |
|
2083 |
||
2084 |
preview |
|
2085 |
||
2086 |
^ preview |
|
2087 |
! |
|
2088 |
||
2089 |
preview:aLabel |
|
2090 |
||
2091 |
preview := aLabel. |
|
2092 |
! |
|
2093 |
||
2094 |
suffix |
|
2095 |
"returns the suffix of the file |
|
2096 |
" |
|
4017 | 2097 |
self isDirectory ifTrue:[^'']. |
3887 | 2098 |
suffix isNil ifTrue:[ |
2099 |
(OperatingSystem isUNIXlike and:[(self baseName at:1) == $.]) ifTrue:[ |
|
2100 |
suffix := ''. |
|
2101 |
] ifFalse:[ |
|
2102 |
suffix := fileName suffix. |
|
2103 |
] |
|
2104 |
]. |
|
2105 |
^ suffix |
|
2106 |
! |
|
2107 |
||
2108 |
suffixes |
|
2109 |
||
2110 |
| lastSuff lastButOneSuff| |
|
2111 |
||
3967 | 2112 |
(fileName name occurrencesOf:$.) <= 1 ifTrue:[ |
2113 |
^ Array with:(self suffix) with:nil. |
|
2114 |
]. |
|
2115 |
(fileName baseName occurrencesOf:$.) <= 1 ifTrue:[ |
|
2116 |
^ Array with:(self suffix) with:nil. |
|
2117 |
]. |
|
3887 | 2118 |
|
3967 | 2119 |
((lastSuff := self suffix) isEmpty) ifTrue:[ |
2120 |
lastSuff := nil. |
|
2121 |
] ifFalse:[ |
|
2122 |
lastSuff := lastSuff asLowercase. |
|
2123 |
]. |
|
2124 |
||
2125 |
((lastButOneSuff := fileName withoutSuffix suffix) isEmpty) ifTrue:[ |
|
2126 |
lastButOneSuff := nil. |
|
2127 |
] ifFalse:[ |
|
2128 |
lastButOneSuff := lastButOneSuff asLowercase. |
|
2129 |
]. |
|
2130 |
||
2131 |
(lastSuff notNil and:[lastButOneSuff notNil]) ifTrue:[ |
|
2132 |
(lastSuff = 'bak' or:[lastSuff = 'sav']) ifTrue:[ |
|
2133 |
lastSuff := lastButOneSuff. |
|
3887 | 2134 |
lastButOneSuff := nil. |
3967 | 2135 |
] |
3887 | 2136 |
]. |
3967 | 2137 |
^ Array with:lastSuff with:lastButOneSuff |
3887 | 2138 |
! |
2139 |
||
2140 |
type |
|
2141 |
"returns the type of the file |
|
2142 |
" |
|
2143 |
^ self valueAt:#type |
|
2144 |
||
2145 |
! ! |
|
2146 |
||
2147 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'actions'! |
|
2148 |
||
2149 |
resetImageFile |
|
2150 |
||
2151 |
" if the image preview extent is changed the icon will set to nil to force the update task to reload the image " |
|
2152 |
||
2153 |
(mimeType notNil and:[ mimeType isImage]) ifTrue:[ |
|
2154 |
preview := nil |
|
2155 |
] |
|
2156 |
! |
|
2157 |
||
3983 | 2158 |
resetItemForChanges |
3887 | 2159 |
|
2160 |
" dont know what someone else is doing with the file - read all item properties new " |
|
2161 |
fileInfo := nil. |
|
2162 |
icon := nil. |
|
2163 |
fileType := nil. |
|
2164 |
preview := nil. |
|
2165 |
owner := nil. |
|
2166 |
group := nil. |
|
2167 |
! ! |
|
2168 |
||
2169 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'change queries'! |
|
2170 |
||
3967 | 2171 |
hasBeenModified |
3887 | 2172 |
|
2173 |
"check if item modification time is changed |
|
2174 |
" |
|
2175 |
| time info| |
|
2176 |
||
3906 | 2177 |
self isRemoteDirectory ifTrue:[^ false]. |
2178 |
||
3967 | 2179 |
info := fileName info. |
3887 | 2180 |
info isNil ifTrue:[ ^ false]. |
3962
3906b10c42fd
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
3961
diff
changeset
|
2181 |
time := info modificationTime. |
3967 | 2182 |
|
3887 | 2183 |
contentsBrowserChangeModificationTime isNil ifTrue:[ |
2184 |
contentsBrowserChangeModificationTime := time. |
|
3967 | 2185 |
fileInfo := nil. |
3887 | 2186 |
^ false. |
2187 |
]. |
|
2188 |
((contentsBrowserChangeModificationTime = time) not) ifTrue:[ |
|
2189 |
contentsBrowserChangeModificationTime := time. |
|
3967 | 2190 |
fileInfo := nil. |
3887 | 2191 |
^ true |
2192 |
]. |
|
2193 |
^ false |
|
2194 |
! ! |
|
2195 |
||
2196 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'compare'! |
|
2197 |
||
2198 |
= aItem |
|
2199 |
||
2200 |
"/ Transcript showCR:(aItem species == self species). |
|
2201 |
aItem species == self species ifFalse:[ ^ false]. |
|
2202 |
aItem isNil ifTrue:[ ^ false]. |
|
2203 |
^ (self fileName = aItem fileName) |
|
2204 |
! |
|
2205 |
||
2206 |
hash |
|
2207 |
^ fileName hash |
|
2208 |
! ! |
|
2209 |
||
2210 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'presentation'! |
|
2211 |
||
2212 |
baseName |
|
2213 |
"returns the baseName of the file |
|
2214 |
" |
|
3967 | 2215 |
^ fileName baseName. |
3887 | 2216 |
! |
2217 |
||
2218 |
baseNameWithOutSuffix |
|
2219 |
"returns the baseName of the file |
|
2220 |
" |
|
2221 |
| baseNameWithOutSuff | |
|
2222 |
||
4017 | 2223 |
self isDirectory ifTrue:[^ self baseName]. |
3887 | 2224 |
baseNameWithOutSuff := self baseName asFilename withoutSuffix asString. |
4017 | 2225 |
(baseNameWithOutSuff isEmpty or:[baseNameWithOutSuff = '.']) ifTrue:[ |
3887 | 2226 |
^ self baseName |
2227 |
]. |
|
2228 |
^ baseNameWithOutSuff. |
|
2229 |
! |
|
2230 |
||
2231 |
date |
|
3967 | 2232 |
"returns the modTimeString |
3887 | 2233 |
" |
2234 |
| modTime | |
|
2235 |
||
3967 | 2236 |
modTime := self modificationTime. |
2237 |
modTime isNil ifTrue:[ |
|
2238 |
^ '???' |
|
3887 | 2239 |
]. |
3967 | 2240 |
^ modTime asDate printString. |
3887 | 2241 |
! |
2242 |
||
2243 |
fileInfoString |
|
2244 |
"get stat info on selected file - return a string which can be |
|
2245 |
shown in a box" |
|
2246 |
||
2247 |
| afileType | |
|
2248 |
||
2249 |
fileName isNil ifTrue:[^ nil]. |
|
2250 |
afileType := self fileType. |
|
2251 |
afileType isNil ifTrue:[ |
|
2252 |
^ ''. |
|
2253 |
]. |
|
2254 |
^ afileType |
|
2255 |
! |
|
2256 |
||
3967 | 2257 |
fileSize |
2258 |
"returns the fileSize |
|
2259 |
" |
|
2260 |
self getFileInfo. |
|
2261 |
fileInfo isNil ifTrue:[^ nil]. |
|
2262 |
||
2263 |
^ fileInfo fileSize |
|
2264 |
! |
|
2265 |
||
3887 | 2266 |
group |
2267 |
"returns the printable group |
|
2268 |
" |
|
2269 |
|gid| |
|
2270 |
||
2271 |
group isNil ifTrue:[ |
|
3967 | 2272 |
self getFileInfo. |
2273 |
fileInfo isNil ifTrue:[^ '???']. |
|
2274 |
||
2275 |
gid := fileInfo gid. |
|
2276 |
(LastGIDToGroupNameMapping notNil and:[gid == LastGIDToGroupNameMapping key]) ifTrue:[ |
|
2277 |
group := LastGIDToGroupNameMapping value |
|
2278 |
] ifFalse:[ |
|
2279 |
group := OperatingSystem getGroupNameFromID:gid. |
|
2280 |
LastGIDToGroupNameMapping := gid -> group. |
|
2281 |
] |
|
3887 | 2282 |
]. |
2283 |
^ group |
|
2284 |
! |
|
2285 |
||
2286 |
modificationTime |
|
2287 |
"returns the absolute time of modification |
|
2288 |
" |
|
3967 | 2289 |
self getFileInfo. |
2290 |
fileInfo isNil ifTrue:[^ nil]. |
|
2291 |
||
2292 |
^ fileInfo modificationTime |
|
3887 | 2293 |
! |
2294 |
||
2295 |
owner |
|
2296 |
"returns the printable owner |
|
2297 |
" |
|
2298 |
|uid| |
|
2299 |
||
2300 |
owner isNil ifTrue:[ |
|
3967 | 2301 |
self getFileInfo. |
2302 |
fileInfo isNil ifTrue:[^ '???']. |
|
2303 |
||
2304 |
uid := fileInfo uid. |
|
2305 |
(LastUIDToUserNameMapping notNil and:[uid == LastUIDToUserNameMapping key]) ifTrue:[ |
|
2306 |
owner := LastUIDToUserNameMapping value |
|
2307 |
] ifFalse:[ |
|
2308 |
owner := OperatingSystem getUserNameFromID:uid. |
|
2309 |
LastUIDToUserNameMapping := uid -> owner. |
|
2310 |
] |
|
3887 | 2311 |
]. |
2312 |
^ owner |
|
2313 |
! |
|
2314 |
||
2315 |
permissions |
|
2316 |
"returns the permissions as printable string |
|
2317 |
" |
|
3967 | 2318 |
|mode permissionString| |
3887 | 2319 |
|
3967 | 2320 |
self getFileInfo. |
2321 |
fileInfo isNil ifTrue:[^ '???'.]. |
|
3887 | 2322 |
|
3967 | 2323 |
mode := fileInfo mode. |
2324 |
permissionString := String new:9 withAll:$-. |
|
2325 |
||
2326 |
1 to:9 by:3 do:[:i| |
|
2327 |
(mode bitAt:i ) == 1 ifTrue:[permissionString at:10 - i put:$x]. |
|
2328 |
(mode bitAt:i + 1) == 1 ifTrue:[permissionString at:9 - i put:$w]. |
|
2329 |
(mode bitAt:i + 2) == 1 ifTrue:[permissionString at:8 - i put:$r]. |
|
3887 | 2330 |
]. |
3967 | 2331 |
^ permissionString |
3887 | 2332 |
! |
2333 |
||
2334 |
printString |
|
3983 | 2335 |
|
2336 |
^ 'a DirectoryContentsItem [', fileName asString, ']' |
|
3887 | 2337 |
! |
2338 |
||
2339 |
sizeString |
|
2340 |
"returns the size of the file |
|
2341 |
" |
|
2342 |
| unitString n locSize| |
|
2343 |
||
3967 | 2344 |
unitString := ''. |
2345 |
locSize := self fileSize. |
|
2346 |
locSize isNil ifTrue:[^ '???']. |
|
2347 |
||
2348 |
locSize < (500 * 1024) ifTrue:[ |
|
2349 |
locSize < 1024 ifTrue:[ |
|
2350 |
n := locSize |
|
3887 | 2351 |
] ifFalse:[ |
3967 | 2352 |
n := (locSize * 10 // 1024 / 10.0). |
2353 |
unitString := ' Kb' |
|
2354 |
] |
|
2355 |
] ifFalse:[ |
|
2356 |
n := (locSize * 10 // 1024 // 1024 / 10.0). |
|
2357 |
unitString := ' Mb' |
|
3887 | 2358 |
]. |
3967 | 2359 |
^ (n printStringLeftPaddedTo:5) , unitString. |
3887 | 2360 |
! |
2361 |
||
2362 |
timeAndDate |
|
2363 |
"returns the date |
|
2364 |
" |
|
3967 | 2365 |
|modTime| |
3887 | 2366 |
|
3967 | 2367 |
modTime := self modificationTime. |
2368 |
modTime isNil ifTrue:[ |
|
2369 |
^ '???' |
|
3887 | 2370 |
]. |
3967 | 2371 |
Smalltalk languageTerritory == #us ifTrue:[ |
2372 |
^ modTime printStringFormat:'%(ShortMonthName), %(dayPadded) %(yearOrTime)'. |
|
2373 |
]. |
|
2374 |
^ modTime printStringFormat:'%(day)-%(ShortMonthName) %(yearOrTime)'. |
|
2375 |
||
2376 |
"/ ^ modTime printStringFormat:'%(year)-%(mon)-%(day) %h:%m:%s'. |
|
3887 | 2377 |
! ! |
2378 |
||
2379 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'private'! |
|
2380 |
||
3967 | 2381 |
getFileInfo |
3887 | 2382 |
fileInfo isNil ifTrue:[ |
3906 | 2383 |
self isRemoteDirectory ifTrue:[ |
2384 |
"/ do not access, to avoid automount |
|
3887 | 2385 |
] ifFalse:[ |
3967 | 2386 |
fileInfo := fileName linkInfo. |
2387 |
fileInfo isNil ifTrue:[ |
|
2388 |
fileInfo := fileName info. |
|
3906 | 2389 |
]. |
3967 | 2390 |
]. |
2391 |
]. |
|
2392 |
^ fileInfo |
|
3887 | 2393 |
! ! |
2394 |
||
2395 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'queries'! |
|
2396 |
||
3906 | 2397 |
beRemoteDirectory |
2398 |
fileType := #remoteDirectory. |
|
2399 |
! |
|
2400 |
||
3887 | 2401 |
exists |
2402 |
"returns the fileName |
|
2403 |
" |
|
2404 |
^ fileName exists |
|
2405 |
! |
|
2406 |
||
2407 |
hasMimeType |
|
2408 |
||
2409 |
^ (self mimeType ~= #unknown) |
|
2410 |
! |
|
2411 |
||
3906 | 2412 |
isRemoteDirectory |
2413 |
^ fileType == #remoteDirectory |
|
2414 |
! |
|
2415 |
||
3887 | 2416 |
mimeTypeForContents |
2417 |
||
2418 |
mimeTypeForContents isNil ifTrue:[ |
|
2419 |
mimeTypeForContents := MIMETypes mimeTypeOfContents:(self fileName). |
|
2420 |
mimeTypeForContents isNil ifTrue:[ |
|
2421 |
mimeTypeForContents := #unknown |
|
2422 |
] ifFalse:[ |
|
2423 |
" set mimeType to mimeType of contents if a better mimeType is found " |
|
2424 |
mimeType := mimeTypeForContents. |
|
2425 |
iconKey := mimeTypeForContents. |
|
2426 |
] |
|
2427 |
]. |
|
2428 |
^ mimeTypeForContents |
|
2429 |
! ! |
|
2430 |
||
4017 | 2431 |
!DirectoryContentsBrowser::DirectoryContentsUpdateTask class methodsFor:'defaults'! |
2432 |
||
2433 |
debug |
|
2434 |
||
2435 |
^ false |
|
2436 |
! ! |
|
2437 |
||
2438 |
!DirectoryContentsBrowser::DirectoryContentsUpdateTask methodsFor:'accessing'! |
|
2439 |
||
2440 |
changeSema |
|
2441 |
"return the value of the instance variable 'changeSema' (automatically generated)" |
|
2442 |
changeSema isNil ifTrue:[ |
|
2443 |
changeSema := Semaphore new. |
|
2444 |
]. |
|
2445 |
^ changeSema |
|
2446 |
! |
|
2447 |
||
2448 |
directoryChangeFlag |
|
2449 |
"return the value of the instance variable 'directoryChangeFlag' (automatically generated)" |
|
2450 |
||
2451 |
directoryChangeFlag isNil ifTrue:[ |
|
2452 |
directoryChangeFlag := false. |
|
2453 |
]. |
|
2454 |
^ directoryChangeFlag |
|
2455 |
! |
|
2456 |
||
2457 |
directoryChangeFlag:something |
|
2458 |
"set the value of the instance variable 'directoryChangeFlag' (automatically generated)" |
|
2459 |
||
2460 |
directoryChangeFlag := something. |
|
2461 |
! |
|
2462 |
||
2463 |
directoryContentsChangeFlag |
|
2464 |
"return the value of the instance variable 'directoryContentsChangeFlag' (automatically generated)" |
|
2465 |
||
2466 |
directoryContentsChangeFlag isNil ifTrue:[ |
|
2467 |
directoryContentsChangeFlag := false. |
|
2468 |
]. |
|
2469 |
^ directoryContentsChangeFlag |
|
2470 |
! |
|
2471 |
||
2472 |
directoryContentsChangeFlag:something |
|
2473 |
"set the value of the instance variable 'directoryContentsChangeFlag' (automatically generated)" |
|
2474 |
||
2475 |
directoryContentsChangeFlag := something. |
|
2476 |
! |
|
2477 |
||
2478 |
filterChangeFlag |
|
2479 |
"return the value of the instance variable 'filterChangeFlag' (automatically generated)" |
|
2480 |
||
2481 |
filterChangeFlag isNil ifTrue:[ |
|
2482 |
filterChangeFlag := false. |
|
2483 |
]. |
|
2484 |
^ filterChangeFlag |
|
2485 |
! |
|
2486 |
||
2487 |
filterChangeFlag:something |
|
2488 |
"set the value of the instance variable 'filterChangeFlag' (automatically generated)" |
|
2489 |
||
2490 |
filterChangeFlag := something. |
|
2491 |
! |
|
2492 |
||
2493 |
isBusy |
|
2494 |
"return the value of the instance variable 'isBusy' (automatically generated)" |
|
2495 |
||
2496 |
isBusy isNil ifTrue:[ |
|
2497 |
isBusy := false. |
|
2498 |
]. |
|
2499 |
^ isBusy |
|
2500 |
! |
|
2501 |
||
2502 |
isBusy:something |
|
2503 |
"set the value of the instance variable 'isBusy' (automatically generated)" |
|
2504 |
||
2505 |
isBusy := something. |
|
2506 |
! |
|
2507 |
||
2508 |
sortBlockChangeFlag |
|
2509 |
"return the value of the instance variable 'sortBlockChangeFlag' (automatically generated)" |
|
2510 |
||
2511 |
sortBlockChangeFlag isNil ifTrue:[ |
|
2512 |
sortBlockChangeFlag := false. |
|
2513 |
]. |
|
2514 |
^ sortBlockChangeFlag |
|
2515 |
! |
|
2516 |
||
2517 |
sortBlockChangeFlag:something |
|
2518 |
"set the value of the instance variable 'sortBlockChangeFlag' (automatically generated)" |
|
2519 |
||
2520 |
sortBlockChangeFlag := something. |
|
2521 |
! ! |
|
2522 |
||
2523 |
!DirectoryContentsBrowser::DirectoryContentsUpdateTask methodsFor:'actions'! |
|
2524 |
||
2525 |
debugMessage:aString |
|
2526 |
||
2527 |
self class debug ifTrue:[ |
|
2528 |
Transcript showCR:aString |
|
2529 |
]. |
|
2530 |
! |
|
2531 |
||
2532 |
wakeUpForDirectoryChanged:aDirectory |
|
2533 |
||
2534 |
self modificationTaskStop. |
|
2535 |
directory := aDirectory. |
|
2536 |
self isBusy ifTrue:[ |
|
2537 |
updateProcess interruptWith:[AbortSignal raise]. |
|
2538 |
]. |
|
2539 |
self directoryChangeFlag:true. |
|
2540 |
self changeSema signal. |
|
2541 |
! |
|
2542 |
||
2543 |
wakeUpForDirectoryContentsChanged |
|
2544 |
||
2545 |
self directoryContentsChangeFlag:true. |
|
2546 |
self changeSema signal. |
|
4019 | 2547 |
self modificationTaskStop. |
4017 | 2548 |
! |
2549 |
||
2550 |
wakeUpForFilterChanged |
|
2551 |
||
2552 |
self filterChangeFlag:true. |
|
2553 |
self sortBlockChangeFlag ifTrue:[ |
|
2554 |
updateProcess interruptWith:[AbortSignal raise]. |
|
2555 |
]. |
|
2556 |
self changeSema signal. |
|
2557 |
! |
|
2558 |
||
2559 |
wakeUpForSortBlockChanged |
|
2560 |
||
2561 |
self sortBlockChangeFlag:true. |
|
2562 |
self changeSema signal. |
|
2563 |
! ! |
|
2564 |
||
2565 |
!DirectoryContentsBrowser::DirectoryContentsUpdateTask methodsFor:'instance creation'! |
|
2566 |
||
2567 |
startWith:aDirectoryBrowser |
|
2568 |
||
2569 |
| processLoop | |
|
2570 |
||
2571 |
directoryBrowser := aDirectoryBrowser. |
|
2572 |
processLoop := self updateLoop. |
|
2573 |
updateProcess := processLoop newProcess. |
|
2574 |
updateProcess name:'DCB updateTask'. |
|
2575 |
updateProcess priorityRange:(Processor userBackgroundPriority to:Processor activePriority). |
|
2576 |
updateProcess resume. |
|
2577 |
! |
|
2578 |
||
2579 |
stop |
|
2580 |
||
2581 |
updateProcess terminate. |
|
2582 |
self modificationTaskStop. |
|
2583 |
! |
|
2584 |
||
2585 |
updateLoop |
|
2586 |
||
2587 |
^ [ |
|
2588 |
[true] whileTrue:[ |
|
2589 |
AbortSignal handle:[ |
|
2590 |
self debugMessage:'get an abort signal'. |
|
2591 |
] do:[ |
|
2592 |
self debugMessage:'sema wait'. |
|
2593 |
self changeSema wait. |
|
2594 |
self debugMessage:'sema signal'. |
|
2595 |
self isBusy:true. |
|
2596 |
[ |
|
2597 |
self directoryChangeFlag ifTrue:[ |
|
4026 | 2598 |
self directoryChangeFlag:false. |
2599 |
self debugMessage:'directoryChanged'. |
|
2600 |
self directoryChanged. |
|
4017 | 2601 |
]. |
2602 |
self directoryContentsChangeFlag ifTrue:[ |
|
4026 | 2603 |
self directoryContentsChangeFlag:false. |
2604 |
self debugMessage:'directoryContentsChanged'. |
|
2605 |
self directoryContentsChanged. |
|
4017 | 2606 |
]. |
2607 |
self filterChangeFlag ifTrue:[ |
|
4026 | 2608 |
self filterChangeFlag:false. |
2609 |
self debugMessage:'filterChanged'. |
|
2610 |
self filterChanged. |
|
4017 | 2611 |
]. |
2612 |
self sortBlockChangeFlag ifTrue:[ |
|
4026 | 2613 |
self sortBlockChangeFlag:false. |
2614 |
self debugMessage:'sortBlockChanged'. |
|
2615 |
self sortBlockChanged. |
|
4017 | 2616 |
] |
2617 |
] ensure:[ |
|
2618 |
self isBusy:false. |
|
2619 |
] |
|
2620 |
] |
|
2621 |
] |
|
2622 |
] |
|
2623 |
! ! |
|
2624 |
||
2625 |
!DirectoryContentsBrowser::DirectoryContentsUpdateTask methodsFor:'modification task'! |
|
2626 |
||
2627 |
modificationTaskStart |
|
2628 |
||
2629 |
modificationTask := [ |
|
2630 |
[ |
|
2631 |
(directory notNil) ifTrue:[ |
|
2632 |
[directory notNil and:[modificationTime = directory modificationTime]] whileTrue:[ |
|
2633 |
Processor yield. |
|
2634 |
Delay waitForSeconds:1.0 |
|
2635 |
]. |
|
2636 |
]. |
|
2637 |
modificationTime := directory modificationTime. |
|
2638 |
self wakeUpForDirectoryContentsChanged. |
|
2639 |
] valueNowOrOnUnwindDo:[ |
|
2640 |
modificationTask := nil. |
|
2641 |
] |
|
2642 |
] newProcess. |
|
2643 |
||
2644 |
"/ modificationTask priority:(Processor systemBackgroundPriority). |
|
2645 |
modificationTask priorityRange:(Processor userBackgroundPriority to:Processor activePriority). |
|
2646 |
||
2647 |
modificationTask name:('DirectoryContentsBrowser update contents[', directory baseName, ']'). |
|
2648 |
modificationTask resume. |
|
2649 |
! |
|
2650 |
||
2651 |
modificationTaskStop |
|
2652 |
||
2653 |
|task| |
|
2654 |
||
2655 |
(task := modificationTask) notNil ifTrue:[ |
|
2656 |
modificationTask := nil. |
|
2657 |
||
2658 |
Object errorSignal handle:[:ex| |
|
2659 |
Dialog warn:ex description. |
|
2660 |
]do:[ |
|
2661 |
task isDead ifFalse:[ |
|
2662 |
task terminate. |
|
2663 |
task waitUntilTerminated. |
|
2664 |
] |
|
2665 |
] |
|
2666 |
]. |
|
2667 |
! ! |
|
2668 |
||
2669 |
!DirectoryContentsBrowser::DirectoryContentsUpdateTask methodsFor:'private - actions'! |
|
2670 |
||
2671 |
directoryChanged |
|
2672 |
||
2673 |
| allItems | |
|
2674 |
||
2675 |
self modificationTaskStop. |
|
4023 | 2676 |
directory notNil ifTrue:[ |
2677 |
modificationTime := directory modificationTime. |
|
2678 |
allItems := self readDirectoryItems. |
|
2679 |
filteredItems := self evaluateFilter:allItems. |
|
2680 |
filteredItems sort:directoryBrowser sortBlockHolder value. |
|
2681 |
self modificationTaskStart. |
|
2682 |
] ifFalse:[ |
|
2683 |
allItems := OrderedCollection new. |
|
2684 |
filteredItems := OrderedCollection new. |
|
2685 |
]. |
|
4017 | 2686 |
directoryBrowser |
2687 |
enqueueMessage:#value |
|
2688 |
for:[ |
|
2689 |
directoryBrowser setBrowserItemList:filteredItems allItemsList:allItems |
|
2690 |
] |
|
2691 |
arguments:#(). |
|
2692 |
! |
|
2693 |
||
2694 |
directoryContentsChanged |
|
2695 |
||
2696 |
|allItems oldItems addItems remItems newItems| |
|
2697 |
||
2698 |
modificationTime := directory modificationTime. |
|
2699 |
allItems := self readDirectoryItems. |
|
2700 |
oldItems := filteredItems copy. |
|
2701 |
newItems := self evaluateFilter:allItems. |
|
2702 |
addItems := OrderedCollection new. |
|
2703 |
remItems := OrderedCollection new. |
|
2704 |
filteredItems size == 0 ifTrue:[ |
|
2705 |
remItems := oldItems. |
|
2706 |
] ifFalse:[ |
|
2707 |
"/ MERGE WITH CURRENT CONTENTS |
|
2708 |
oldItems reverseDo:[:anOldItem| |
|
2709 |
"/ remove no longer valid files |
|
2710 |
(newItems detectLast:[:aNewItem| aNewItem = anOldItem] ifNone:false) ifFalse:[ |
|
2711 |
remItems add:anOldItem. |
|
2712 |
oldItems removeIdentical:anOldItem |
|
2713 |
] |
|
2714 |
]. |
|
2715 |
"/ add new files |
|
2716 |
newItems do:[:aNewItem| |
|
2717 |
(oldItems detect:[:anOldItem| anOldItem = aNewItem] ifNone:false) ifFalse:[ |
|
2718 |
addItems add:aNewItem. |
|
2719 |
] |
|
2720 |
]. |
|
2721 |
]. |
|
2722 |
directoryBrowser |
|
2723 |
enqueueMessage:#value |
|
2724 |
for:[ |
|
2725 |
directoryBrowser allItems:allItems browserItemListAdd:addItems remove:remItems. |
|
2726 |
] |
|
2727 |
arguments:#(). |
|
2728 |
filteredItems := newItems. |
|
2729 |
self modificationTaskStart. |
|
2730 |
! |
|
2731 |
||
2732 |
evaluateFilter:aItemsList |
|
2733 |
||
2734 |
|showDir filterBlock newItemList noOfAddedFiles noOfFiles| |
|
2735 |
||
2736 |
newItemList := OrderedCollection new. |
|
2737 |
noOfFiles := 0. |
|
2738 |
noOfAddedFiles := 0. |
|
2739 |
showDir := directoryBrowser viewDirectoriesInDirectoryContentsBrowser value. |
|
2740 |
filterBlock := directoryBrowser matchBlock. |
|
2741 |
aItemsList size ~~ 0 ifTrue:[ |
|
2742 |
aItemsList do:[:aItem | |isDir| |
|
2743 |
isDir := aItem isDirectory. |
|
2744 |
isDir not ifTrue:[noOfFiles := noOfFiles + 1]. |
|
2745 |
((isDir and:[showDir]) or:[isDir not and:[filterBlock value:aItem baseName]]) ifTrue:[ |
|
2746 |
isDir not ifTrue:[noOfAddedFiles := noOfAddedFiles + 1]. |
|
2747 |
newItemList add:aItem |
|
2748 |
] |
|
2749 |
]. |
|
2750 |
]. |
|
2751 |
directoryBrowser noOfAddedFiles:noOfAddedFiles noOfFiles:noOfFiles. |
|
2752 |
^ newItemList |
|
2753 |
! |
|
2754 |
||
2755 |
filterChanged |
|
2756 |
||
2757 |
filteredItems := self evaluateFilter:directoryBrowser allItemsList copy. |
|
2758 |
filteredItems sort:directoryBrowser sortBlockHolder value. |
|
2759 |
directoryBrowser |
|
2760 |
enqueueMessage:#value |
|
2761 |
for:[ |
|
2762 |
directoryBrowser setBrowserItemList:filteredItems allItemsList:nil |
|
2763 |
] |
|
2764 |
arguments:nil. |
|
2765 |
! |
|
2766 |
||
2767 |
mergeItems:newItems with:oldItems |
|
2768 |
||
2769 |
| changeDict | |
|
2770 |
||
2771 |
changeDict := Dictionary new. |
|
2772 |
changeDict at:#removeItems put:OrderedCollection new. |
|
2773 |
changeDict at:#addItems put:OrderedCollection new. |
|
2774 |
newItems size == 0 ifTrue:[ |
|
2775 |
changeDict at:#removeItems put:oldItems. |
|
2776 |
] ifFalse:[ |
|
2777 |
"/ MERGE WITH CURRENT CONTENTS |
|
2778 |
oldItems reverseDo:[:anOldItem| |
|
2779 |
"/ remove no longer valid files |
|
2780 |
(newItems detect:[:aNewItem| aNewItem = anOldItem] ifNone:nil) isNil ifTrue:[ |
|
2781 |
(changeDict at:#removeItems) add:anOldItem |
|
2782 |
] |
|
2783 |
]. |
|
2784 |
"/ add new files |
|
2785 |
newItems reverseDo:[:aNewItem| |
|
2786 |
(oldItems contains:[:anOldItem| anOldItem = aNewItem]) not ifTrue:[ |
|
2787 |
(changeDict at:#addItems) add:aNewItem. |
|
2788 |
] |
|
2789 |
]. |
|
2790 |
]. |
|
2791 |
^ changeDict |
|
2792 |
! |
|
2793 |
||
2794 |
readDirectoryItems |
|
2795 |
| list mountPoints contents| |
|
2796 |
||
2797 |
mountPoints := OperatingSystem mountPoints. |
|
2798 |
||
2799 |
list := OrderedCollection new. |
|
2800 |
directory notNil ifTrue:[ |
|
2801 |
contents := DirectoryContents directoryNamed:directory. |
|
2802 |
contents itemsDo:[:aItem| |
|
2803 |
list add:(DirectoryContentsBrowser itemClass forInfoItem:aItem). |
|
2804 |
]. |
|
2805 |
]. |
|
2806 |
^ list |
|
2807 |
! |
|
2808 |
||
2809 |
sortBlockChanged |
|
2810 |
||
2811 |
filteredItems sort:directoryBrowser sortBlockHolder value. |
|
2812 |
directoryBrowser |
|
2813 |
enqueueMessage:#value |
|
2814 |
for:[ |
|
2815 |
directoryBrowser setBrowserItemList:filteredItems allItemsList:nil |
|
2816 |
] |
|
2817 |
arguments:nil. |
|
2818 |
! ! |
|
2819 |
||
3887 | 2820 |
!DirectoryContentsBrowser class methodsFor:'documentation'! |
2821 |
||
2822 |
version |
|
4027 | 2823 |
^ '$Header: /cvs/stx/stx/libtool/DirectoryContentsBrowser.st,v 1.34 2002-10-22 16:05:06 penk Exp $' |
3887 | 2824 |
! ! |