author | penk |
Fri, 25 Oct 2002 13:11:24 +0200 | |
changeset 4057 | 73bc66a13c39 |
parent 4049 | ae431a5de755 |
child 4071 | f923c8257818 |
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 |
]. |
|
4039 | 915 |
self updateToExternFileHolderLock doLocked:[ |
916 |
self browserItemList contents:locItems asList. |
|
917 |
]. |
|
4017 | 918 |
self updateColumnsTaskStart. |
919 |
self selectCurrentFiles. |
|
3887 | 920 |
! ! |
921 |
||
922 |
!DirectoryContentsBrowser methodsFor:'aspects'! |
|
923 |
||
3983 | 924 |
browserItemList |
925 |
||
926 |
browserItemList isNil ifTrue:[ |
|
927 |
browserItemList := List new. |
|
928 |
]. |
|
929 |
^ browserItemList |
|
3887 | 930 |
! |
931 |
||
3983 | 932 |
selectionInFileList |
933 |
||
934 |
selectionInFileList isNil ifTrue:[ |
|
935 |
selectionInFileList := ValueHolder new. |
|
936 |
selectionInFileList addDependent:self. |
|
3887 | 937 |
]. |
3983 | 938 |
^ selectionInFileList |
3887 | 939 |
! |
940 |
||
941 |
tableColumns |
|
942 |
"automatically generated by UIPainter ..." |
|
943 |
||
944 |
"*** the code below creates a default model when invoked." |
|
945 |
"*** (which may not be the one you wanted)" |
|
946 |
"*** Please change as required and accept it in the browser." |
|
947 |
"*** (and replace this comment by something more useful ;-)" |
|
948 |
||
949 |
tableColumns isNil ifTrue:[ |
|
950 |
tableColumns := self class tableColumns asValue. |
|
951 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
952 |
"/ tableColumns addDependent:self. |
|
953 |
"/ tableColumns onChangeSend:#tableColumnsChanged to:self. |
|
954 |
]. |
|
955 |
^ tableColumns. |
|
956 |
! ! |
|
957 |
||
958 |
!DirectoryContentsBrowser methodsFor:'change & update'! |
|
959 |
||
3983 | 960 |
currentFileNameHolderChanged |
3887 | 961 |
"filename changed |
962 |
" |
|
3983 | 963 |
| newDir currentDir aColOfFiles| |
964 |
||
965 |
||
966 |
aColOfFiles := self currentFileNameHolder value. |
|
967 |
(aColOfFiles isEmpty or:[self currentFilesAreInSameDirectory not]) ifTrue:[ |
|
3887 | 968 |
self directory:nil. |
969 |
^ self |
|
970 |
]. |
|
3983 | 971 |
newDir := self currentDirectories value first. |
3887 | 972 |
currentDir := self directory. |
973 |
newDir = currentDir ifTrue:[ |
|
3983 | 974 |
self selectFiles:aColOfFiles. |
3887 | 975 |
^ self. |
976 |
] ifFalse:[ |
|
977 |
"/ change of the directory filename |
|
978 |
self directory:newDir. |
|
979 |
]. |
|
980 |
! |
|
981 |
||
3983 | 982 |
selectionChanged |
983 |
||
4004 | 984 |
| selection newCurrentFilename | |
3983 | 985 |
|
986 |
self directory isNil ifTrue:[^ self]. |
|
987 |
selection := self selectedFiles. |
|
988 |
selection isEmpty ifTrue:[ |
|
4004 | 989 |
newCurrentFilename := OrderedCollection with:self directory. |
3983 | 990 |
] ifFalse:[ |
4004 | 991 |
newCurrentFilename := selection. |
3983 | 992 |
]. |
4004 | 993 |
self currentFileNameHolder value ~= newCurrentFilename ifTrue:[ |
994 |
self currentFileNameHolder value:newCurrentFilename withoutNotifying:self |
|
995 |
] |
|
3983 | 996 |
! |
997 |
||
3887 | 998 |
update:something with:aParameter from:aModel |
999 |
"one of my models changed |
|
1000 |
" |
|
3983 | 1001 |
|
1002 |
aModel == self currentFileNameHolder ifTrue:[ |
|
4007 | 1003 |
super update:something with:aParameter from:aModel. |
3983 | 1004 |
self updateContentsSelection doIfUnLocked:[ |
4017 | 1005 |
self currentFileNameHolderChanged. |
3983 | 1006 |
]. |
4007 | 1007 |
^ self. |
3983 | 1008 |
]. |
1009 |
aModel == self selectionInFileList ifTrue:[ |
|
1010 |
self updateToExternFileHolderLock doIfUnLocked:[ |
|
1011 |
self updateContentsSelection doLocked:[ |
|
1012 |
self selectionChanged. |
|
1013 |
] |
|
1014 |
]. |
|
1015 |
^ self. |
|
1016 |
]. |
|
4027 | 1017 |
aModel == self currentSortOrder ifTrue:[ |
1018 |
self currentSortOrderChanged. |
|
1019 |
^ self. |
|
1020 |
]. |
|
4011 | 1021 |
aModel == self filterBlockHolder ifTrue:[ |
4017 | 1022 |
self matchBlock:self filterBlockHolder value. |
3887 | 1023 |
^ self. |
1024 |
]. |
|
1025 |
aModel == self sortBlockHolder ifTrue:[ |
|
4017 | 1026 |
updateContentsTask wakeUpForSortBlockChanged. |
3887 | 1027 |
^ self. |
1028 |
]. |
|
1029 |
aModel == self viewDirectoriesInDirectoryContentsBrowser ifTrue:[ |
|
4017 | 1030 |
updateContentsTask wakeUpForFilterChanged. |
3887 | 1031 |
^ self |
1032 |
]. |
|
1033 |
||
1034 |
super update:something with:aParameter from:aModel |
|
1035 |
! |
|
1036 |
||
1037 |
viewedColumnsChanged |
|
1038 |
||
4027 | 1039 |
| columns buffer currentSortOrder currentSortOrderColumn currentSortOrderReverse| |
3887 | 1040 |
|
1041 |
columns := OrderedCollection new. |
|
1042 |
self class tableColumns do:[:el| |
|
1043 |
columns add:(DataSetColumnSpec new fromLiteralArrayEncoding:el). |
|
1044 |
]. |
|
1045 |
buffer := columns copy. |
|
1046 |
self viewDetails value = false ifTrue:[ |
|
3983 | 1047 |
contentsBrowser showLabels:false. |
3887 | 1048 |
buffer do:[:col | |
1049 |
(col readSelector = #baseName or:[col readSelector = #icon]) ifFalse:[ |
|
1050 |
columns remove:col. |
|
1051 |
] |
|
1052 |
] |
|
1053 |
] ifFalse:[ |
|
3983 | 1054 |
contentsBrowser showLabels:true. |
4027 | 1055 |
currentSortOrder := self currentSortOrder value. |
1056 |
currentSortOrderColumn := currentSortOrder at:#column ifAbsent:nil. |
|
1057 |
currentSortOrderReverse := currentSortOrder at:#reverse ifAbsent:nil. |
|
3887 | 1058 |
buffer do:[:col | |
1059 |
| id | |
|
1060 |
id := col id. |
|
1061 |
id notNil ifTrue:[ |
|
4027 | 1062 |
(col labelActionArgument notNil and:[col labelActionArgument asSymbol == currentSortOrderColumn]) ifTrue:[ |
1063 |
| label icon| |
|
1064 |
label := col label. |
|
1065 |
icon := currentSortOrderReverse ifTrue:[self class detailsMenuIconDown] ifFalse:[self class detailsMenuIconUp]. |
|
1066 |
col label:(LabelAndIcon label:label icon:icon). |
|
1067 |
]. |
|
3887 | 1068 |
(id == #filename) ifTrue:[ |
4027 | 1069 |
self viewType value ifTrue:[ |
1070 |
col readSelector:#baseNameWithOutSuffix |
|
3887 | 1071 |
] ifFalse:[ |
4027 | 1072 |
col readSelector:#baseName |
1073 |
]. |
|
1074 |
] ifFalse:[ |
|
1075 |
(id == #suffix and:[self viewType value not]) ifTrue:[ |
|
1076 |
columns remove:col. |
|
1077 |
] ifFalse:[ |
|
1078 |
(id == #group and:[self viewGroup value not]) ifTrue:[ |
|
1079 |
columns remove:col. |
|
3887 | 1080 |
] ifFalse:[ |
4027 | 1081 |
(id == #owner and:[self viewOwner value not]) ifTrue:[ |
1082 |
columns remove:col. |
|
3887 | 1083 |
] ifFalse:[ |
4027 | 1084 |
(id == #perm and:[self viewPermissions value not]) ifTrue:[ |
3887 | 1085 |
columns remove:col. |
1086 |
] ifFalse:[ |
|
4027 | 1087 |
(id == #preview and:[self viewPreview value not]) ifTrue:[ |
3887 | 1088 |
columns remove:col. |
1089 |
] ifFalse:[ |
|
4027 | 1090 |
(id == #size and:[self viewSize value not]) ifTrue:[ |
3887 | 1091 |
columns remove:col. |
1092 |
] ifFalse:[ |
|
4027 | 1093 |
(id == #time and:[self viewTime value not]) ifTrue:[ |
3887 | 1094 |
columns remove:col. |
1095 |
] ifFalse:[ |
|
4027 | 1096 |
(id == #fileInfo and:[self viewDescription value not]) ifTrue:[ |
3887 | 1097 |
columns remove:col. |
4027 | 1098 |
] |
1099 |
] |
|
3887 | 1100 |
] |
1101 |
] |
|
1102 |
] |
|
1103 |
] |
|
1104 |
] |
|
1105 |
] |
|
1106 |
] |
|
1107 |
] |
|
1108 |
] |
|
1109 |
]. |
|
4039 | 1110 |
self updateToExternFileHolderLock doLocked:[ |
1111 |
self tableColumns value:columns. |
|
1112 |
]. |
|
3887 | 1113 |
self columnDescriptors:(self tableColumns value). |
1114 |
! ! |
|
1115 |
||
1116 |
!DirectoryContentsBrowser methodsFor:'drag & drop'! |
|
1117 |
||
3953 | 1118 |
canDrop:aContext |
3887 | 1119 |
|
3953 | 1120 |
^ canDropItem |
3887 | 1121 |
! |
1122 |
||
3953 | 1123 |
doDrop:aContext |
3887 | 1124 |
|
3953 | 1125 |
|col destinationPath receiver| |
3887 | 1126 |
|
3953 | 1127 |
draggedItem isNil ifTrue:[ |
3887 | 1128 |
destinationPath := self directory. |
1129 |
] ifFalse:[ |
|
3953 | 1130 |
destinationPath := self getDirWithoutFileName:(draggedItem fileName). |
4014 | 1131 |
destinationPath baseName = '..' ifTrue:[ |
3953 | 1132 |
destinationPath := self directory directory. |
1133 |
] |
|
3887 | 1134 |
]. |
3953 | 1135 |
self dropLeave:aContext. |
1136 |
aContext dropSource argument == #archivApplication ifTrue:[ |
|
1137 |
receiver := aContext dropSource receiver. |
|
3887 | 1138 |
receiver extractSelectedFilesTo:destinationPath askForExtractOptions:true. |
1139 |
^ true. |
|
1140 |
]. |
|
1141 |
col := OrderedCollection new. |
|
1142 |
aContext dropObjects do:[:obj| |
|
1143 |
col add:(obj theObject). |
|
1144 |
]. |
|
3953 | 1145 |
self copyOrMoveFiles:col to:destinationPath. |
1146 |
^ true. |
|
3887 | 1147 |
! |
1148 |
||
1149 |
doStartDrag:aDropSource in:aView |
|
1150 |
"set the cursors before starting the drag & drop operation |
|
1151 |
" |
|
3983 | 1152 |
|selectedFiles| |
1153 |
||
1154 |
selectedFiles := self selectedFiles. |
|
4014 | 1155 |
(selectedFiles isEmpty) ifTrue:[ |
3887 | 1156 |
^ self. |
1157 |
]. |
|
3953 | 1158 |
^ super doStartDrag:aDropSource in:aView |
1159 |
! |
|
1160 |
||
1161 |
dropEnter:aContext |
|
1162 |
||
1163 |
|dropedObjects| |
|
1164 |
||
1165 |
self dropTargetItemChangedTo:nil in:aContext. |
|
1166 |
inDropMode := false. |
|
1167 |
||
1168 |
self directory isNil ifTrue:[^ self]. |
|
1169 |
dropedObjects := aContext dropObjects. |
|
1170 |
||
1171 |
dropedObjects do:[:aObject| |
|
1172 |
|checkObject checkObjectString| |
|
1173 |
aObject isFileObject ifFalse:[^ self]. |
|
1174 |
checkObject := aObject theObject. |
|
1175 |
checkObject isFilename not ifTrue:[^ self]. |
|
1176 |
((aContext dropSource argument == #archivApplication) not) ifTrue:[ |
|
1177 |
checkObject isSpecialFile ifTrue:[^ self]. |
|
1178 |
checkObject isReadable ifFalse:[^ self]. |
|
1179 |
]. |
|
1180 |
]. |
|
1181 |
inDropMode := true. |
|
3887 | 1182 |
! |
1183 |
||
1184 |
dropLeave:aDropContext |
|
1185 |
||
3953 | 1186 |
inDropMode ifTrue:[ |
1187 |
self dropTargetItemChangedTo:nil in:aDropContext. |
|
1188 |
inDropMode := false. |
|
1189 |
]. |
|
3887 | 1190 |
! |
1191 |
||
3953 | 1192 |
dropOver:aContext |
1193 |
"send the last time, when leaving the widget |
|
1194 |
" |
|
1195 |
|lineNr newDest destinationFile| |
|
1196 |
||
1197 |
inDropMode ifFalse:[^ self]. |
|
1198 |
||
1199 |
lineNr := self getLineNumberFor:aContext. |
|
1200 |
||
1201 |
lineNr notNil ifTrue:[ |
|
3983 | 1202 |
newDest := browserItemList at:lineNr. |
3953 | 1203 |
(newDest notNil and:[newDest isDirectory]) ifTrue:[ |
1204 |
destinationFile := newDest fileName. |
|
4014 | 1205 |
destinationFile baseName = '..' ifTrue:[ |
3953 | 1206 |
destinationFile := self directory directory. |
1207 |
] |
|
1208 |
]. |
|
1209 |
]. |
|
1210 |
newDest == draggedItem ifTrue:[^ self]. |
|
1211 |
||
1212 |
destinationFile isNil ifTrue:[ |
|
1213 |
destinationFile := self directory. |
|
1214 |
]. |
|
3887 | 1215 |
|
3953 | 1216 |
newDest ~~ draggedItem ifTrue:[ |
1217 |
aContext dropSource argument == #archivApplication ifTrue:[ |
|
1218 |
canDropItem := true. |
|
1219 |
] ifFalse:[ |
|
1220 |
canDropItem := self canDropFiles:(aContext dropObjects) for:destinationFile. |
|
1221 |
]. |
|
1222 |
]. |
|
1223 |
self dropTargetItemChangedTo:newDest in:aContext. |
|
1224 |
! |
|
1225 |
||
1226 |
dropTargetItemChangedTo:anItem in:aDropContext |
|
1227 |
||
1228 |
| current | |
|
1229 |
||
1230 |
||
1231 |
"/ (anItem notNil and:[anItem isDirectory]) ifTrue:[ self halt]. |
|
1232 |
current := draggedItem. |
|
3967 | 1233 |
"/ Transcript showCR:'current:', (current isNil ifTrue:['nil'] ifFalse:[current fileName baseName]). |
1234 |
"/ Transcript showCR:'anItem:', (anItem isNil ifTrue:['nil'] ifFalse:[anItem fileName baseName]). |
|
3953 | 1235 |
current == anItem ifTrue:[^ self]. |
1236 |
draggedItem := anItem. |
|
1237 |
||
1238 |
aDropContext contentsWillChange. |
|
1239 |
||
1240 |
current ifNotNil:[ |
|
1241 |
current isDirectory ifTrue:[ |
|
1242 |
current icon:(self getIconFor:current). |
|
1243 |
]. |
|
1244 |
]. |
|
1245 |
||
1246 |
anItem ifNotNil:[ |
|
1247 |
anItem isDirectory ifTrue:[ |
|
1248 |
anItem icon:(FileBrowser iconForKeyMatching:#directoryOpenGray). |
|
1249 |
]. |
|
1250 |
]. |
|
3983 | 1251 |
contentsBrowser shown ifTrue:[ |
1252 |
contentsBrowser invalidateVisibleRow:current colAt:iconIndex. |
|
1253 |
contentsBrowser invalidateVisibleRow:anItem colAt:iconIndex. |
|
1254 |
contentsBrowser repairDamage. |
|
3953 | 1255 |
]. |
3887 | 1256 |
! |
1257 |
||
1258 |
getDisplayObjects:anArgument |
|
1259 |
||
3983 | 1260 |
| selectedFiles string fnName stream| |
1261 |
selectedFiles := self selectedFiles. |
|
1262 |
selectedFiles isEmpty ifTrue:[ ^ '']. |
|
3887 | 1263 |
stream := WriteStream on:''. |
3983 | 1264 |
|
1265 |
stream nextPutAll:(selectedFiles first baseName). |
|
1266 |
selectedFiles size == 1 ifTrue:[ |
|
3887 | 1267 |
fnName := 'ui_menuitem.xpm'. |
1268 |
] ifFalse:[ |
|
1269 |
fnName := 'ui_submenu_open.xpm'. |
|
1270 |
stream nextPutAll:' ... '. |
|
3983 | 1271 |
stream nextPutAll:(selectedFiles last baseName). |
3887 | 1272 |
]. |
1273 |
string := stream contents. |
|
1274 |
stream close. |
|
1275 |
^ Array with:(LabelAndIcon icon:(Image fromFile:fnName) |
|
1276 |
string:(Text string:string emphasis:#bold) |
|
1277 |
) |
|
1278 |
! |
|
1279 |
||
1280 |
getDropObjects:anArgument |
|
1281 |
||
3983 | 1282 |
^ self selectedFiles collect:[:file| DropObject newFile:file]. |
3887 | 1283 |
! |
1284 |
||
1285 |
getLineNumberFor:aDropContext |
|
1286 |
| yVisible| |
|
1287 |
||
1288 |
yVisible := (aDropContext targetPoint y). |
|
3983 | 1289 |
^ contentsBrowser yVisibleToRowNr:yVisible. |
3887 | 1290 |
! ! |
1291 |
||
1292 |
!DirectoryContentsBrowser methodsFor:'event handling'! |
|
1293 |
||
1294 |
processEvent:anEvent |
|
1295 |
"filter keyboard events. |
|
1296 |
Return true, if I have eaten the event" |
|
1297 |
||
1298 |
|focusView key rawKey| |
|
1299 |
||
1300 |
anEvent isKeyPressEvent ifTrue:[ |
|
1301 |
focusView := anEvent targetView. |
|
1302 |
key := anEvent key. |
|
1303 |
rawKey := anEvent rawKey. |
|
1304 |
||
3983 | 1305 |
(focusView == contentsBrowser) ifTrue:[ |
3887 | 1306 |
"/ (key ~= #'Alt_L') ifTrue:[self halt.]. |
1307 |
key == #Paste ifTrue:[ |
|
1308 |
self pasteFiles. |
|
1309 |
^ true. |
|
1310 |
]. |
|
3983 | 1311 |
(key == #CursorLeft) ifTrue:[ |
1312 |
self doGoDirectoryUp. |
|
1313 |
^ true |
|
1314 |
]. |
|
1315 |
(key == #CursorRight) ifTrue:[ |
|
1316 |
self doBack. |
|
1317 |
^ true |
|
1318 |
]. |
|
1319 |
browserItemList size == 0 ifTrue:[ |
|
3887 | 1320 |
^ false |
1321 |
]. |
|
1322 |
key == #Copy ifTrue:[ |
|
1323 |
self doCopy. |
|
1324 |
^ true. |
|
1325 |
]. |
|
1326 |
(key == #Return) ifTrue:[ |
|
1327 |
self doOpenSelectedFile. |
|
1328 |
^ true. |
|
1329 |
]. |
|
1330 |
key == #Delete ifTrue:[ |
|
1331 |
self doDelete. |
|
1332 |
^ true. |
|
1333 |
]. |
|
1334 |
key == #Cut ifTrue:[ |
|
1335 |
self doCut. |
|
1336 |
^ true. |
|
1337 |
]. |
|
1338 |
] |
|
1339 |
]. |
|
1340 |
^ false |
|
1341 |
! ! |
|
1342 |
||
1343 |
!DirectoryContentsBrowser methodsFor:'file actions'! |
|
1344 |
||
1345 |
doCopy |
|
1346 |
"copy current selected files/directories |
|
1347 |
" |
|
1348 |
||
3983 | 1349 |
self copyFilesToClipBoard:(self selectedFiles). |
3887 | 1350 |
! |
1351 |
||
1352 |
doCut |
|
1353 |
"cut current selected files/directories |
|
1354 |
" |
|
1355 |
||
3983 | 1356 |
self cutFilesToClipBoard:(self selectedFiles). |
3887 | 1357 |
! |
1358 |
||
1359 |
doDelete |
|
1360 |
"delete current selected files/directories |
|
1361 |
" |
|
3983 | 1362 |
self deleteFiles:(self selectedFiles). |
3887 | 1363 |
! ! |
1364 |
||
1365 |
!DirectoryContentsBrowser methodsFor:'menu accessing'! |
|
1366 |
||
1367 |
viewBrowserMenu |
|
1368 |
||
1369 |
<resource: #programMenu > |
|
1370 |
||
1371 |
|menu| |
|
1372 |
||
3961 | 1373 |
viewBrowserMenu isNil ifTrue:[ |
1374 |
viewBrowserMenu := self class viewBrowserMenu. |
|
1375 |
]. |
|
1376 |
viewBrowserMenu ifNil:[ ^ nil ]. |
|
1377 |
menu := viewBrowserMenu. |
|
3887 | 1378 |
menu receiver:self. |
1379 |
^ menu |
|
1380 |
! ! |
|
1381 |
||
1382 |
!DirectoryContentsBrowser methodsFor:'menu actions'! |
|
1383 |
||
1384 |
doOpenSelectedFile |
|
1385 |
||
4017 | 1386 |
| selectedItems| |
1387 |
||
1388 |
selectedItems := self selectedItems. |
|
1389 |
(selectedItems size == 1) ifTrue:[ |
|
1390 |
self enterActionFor:(selectedItems first). |
|
3887 | 1391 |
]. |
1392 |
! |
|
1393 |
||
1394 |
doShowFileContents |
|
1395 |
||
3983 | 1396 |
| selectedFileItems| |
1397 |
||
1398 |
selectedFileItems := self selectedFileItems. |
|
1399 |
(selectedFileItems size == 1) ifTrue:[ |
|
1400 |
self openTextEditorOn:(selectedFileItems first). |
|
3887 | 1401 |
]. |
1402 |
! ! |
|
1403 |
||
1404 |
!DirectoryContentsBrowser methodsFor:'queries'! |
|
1405 |
||
1406 |
allItemsOfCurrentDirectory |
|
1407 |
||
3983 | 1408 |
| list | |
1409 |
list := browserItemList copy. |
|
1410 |
self viewDirectoriesInDirectoryContentsBrowser value ifTrue:[ |
|
1411 |
list removeIdentical:(browserItemList first) ifAbsent:[nil] |
|
1412 |
]. |
|
1413 |
^ list. |
|
3887 | 1414 |
! |
1415 |
||
1416 |
fileListIsEmpty |
|
1417 |
||
3983 | 1418 |
^ browserItemList isEmpty |
3887 | 1419 |
! |
1420 |
||
1421 |
getAllFilesAsStringCollection |
|
1422 |
|files items| |
|
1423 |
||
3983 | 1424 |
items := browserItemList. |
3887 | 1425 |
files := OrderedCollection new. |
1426 |
items isEmpty ifTrue:[ |
|
1427 |
^ files |
|
1428 |
]. |
|
1429 |
items do:[:aItem | |
|
1430 |
aItem isDirectory not ifTrue:[ |
|
1431 |
files add:aItem fileName asString |
|
1432 |
]. |
|
1433 |
]. |
|
1434 |
^ files. |
|
4004 | 1435 |
! |
1436 |
||
1437 |
hasFilesFiltered |
|
4017 | 1438 |
^ allItemsList size ~~ browserItemList size |
3983 | 1439 |
! ! |
1440 |
||
1441 |
!DirectoryContentsBrowser methodsFor:'selection'! |
|
1442 |
||
1443 |
selectAll |
|
1444 |
||
1445 |
| sel| |
|
1446 |
||
1447 |
sel := browserItemList copy. |
|
4013 | 1448 |
self viewDirectoriesInDirectoryContentsBrowser value ifTrue:[ |
1449 |
sel removeIdentical:(browserItemList first) ifAbsent:[nil] |
|
3887 | 1450 |
]. |
3983 | 1451 |
self selectionInFileList value:sel. |
3887 | 1452 |
! |
1453 |
||
4017 | 1454 |
selectCurrentFiles |
1455 |
||
1456 |
|currentSelection| |
|
1457 |
||
1458 |
((currentSelection := self currentFileNameHolder value select:[:file| file isDirectory not]) notEmpty) ifTrue:[ |
|
1459 |
self selectFiles:currentSelection. |
|
1460 |
]. |
|
1461 |
! |
|
1462 |
||
3983 | 1463 |
selectFiles:aColOfFilenames |
1464 |
| curSel newSel| |
|
1465 |
||
1466 |
curSel := self selectedFiles. |
|
1467 |
aColOfFilenames size = curSel size ifTrue:[ |
|
1468 |
| index | |
|
1469 |
index := curSel findFirst:[:file| (aColOfFilenames includes:file) not]. |
|
1470 |
index == 0 ifTrue:[ ^ self]. |
|
3887 | 1471 |
]. |
3983 | 1472 |
newSel := OrderedCollection new. |
1473 |
browserItemList do:[: item| |
|
1474 |
(aColOfFilenames includes:(item fileName)) ifTrue:[ |
|
1475 |
newSel add:item. |
|
1476 |
]. |
|
3887 | 1477 |
]. |
4017 | 1478 |
self updateToExternFileHolderLock doLocked:[ |
1479 |
self selectionInFileList value:newSel. |
|
1480 |
]. |
|
3983 | 1481 |
! |
1482 |
||
1483 |
selectedFileItems |
|
1484 |
||
1485 |
| sel | |
|
1486 |
||
3985 | 1487 |
sel := self selectedItems select:[:item | item isDirectory not]. |
3987 | 1488 |
^ sel |
1489 |
! |
|
1490 |
||
1491 |
selectedFileNames |
|
1492 |
^ self selectedFileItems collect:[:item| item fileName]. |
|
3887 | 1493 |
! |
1494 |
||
3983 | 1495 |
selectedFiles |
1496 |
||
1497 |
^ self selectedItems collect:[: item| item fileName]. |
|
1498 |
! |
|
1499 |
||
1500 |
selectedItems |
|
1501 |
||
1502 |
| sel | |
|
1503 |
sel := self selectionInFileList value copy. |
|
1504 |
sel isNil ifTrue:[ ^ #()]. |
|
4017 | 1505 |
(self viewDirectoriesInDirectoryContentsBrowser value and:[browserItemList notEmpty]) ifTrue:[ |
3983 | 1506 |
sel removeIdentical:(browserItemList first) ifAbsent:[nil] |
3887 | 1507 |
]. |
4013 | 1508 |
^ sel. |
3887 | 1509 |
! ! |
1510 |
||
1511 |
!DirectoryContentsBrowser methodsFor:'startup / release'! |
|
1512 |
||
1513 |
makeDependent |
|
1514 |
||
4007 | 1515 |
super makeDependent. |
3887 | 1516 |
self currentFileNameHolder addDependent:self. |
4027 | 1517 |
self currentSortOrder addDependent:self. |
3887 | 1518 |
self viewDirectoriesInDirectoryContentsBrowser addDependent:self. |
4011 | 1519 |
self filterBlockHolder addDependent:self. |
3887 | 1520 |
self sortBlockHolder addDependent:self. |
1521 |
self viewDescription onChangeSend:#viewedColumnsChanged to:self. |
|
1522 |
self viewDetails onChangeSend:#viewedColumnsChanged to:self. |
|
1523 |
self viewGroup onChangeSend:#viewedColumnsChanged to:self. |
|
1524 |
self viewOwner onChangeSend:#viewedColumnsChanged to:self. |
|
1525 |
self viewPermissions onChangeSend:#viewedColumnsChanged to:self. |
|
1526 |
self viewPreview onChangeSend:#viewedColumnsChanged to:self. |
|
1527 |
self viewSize onChangeSend:#viewedColumnsChanged to:self. |
|
1528 |
self viewTime onChangeSend:#viewedColumnsChanged to:self. |
|
1529 |
self viewType onChangeSend:#viewedColumnsChanged to:self. |
|
1530 |
! |
|
1531 |
||
1532 |
postBuildBrowser:aWidget |
|
1533 |
||
3983 | 1534 |
contentsBrowser := aWidget scrolledView. |
1535 |
contentsBrowser wantsFocusWithPointerEnter. |
|
3887 | 1536 |
"/ dont register icons anymore |
1537 |
"/ FileBrowser icons keysAndValuesDo:[:aKey :anIcon| |
|
1538 |
"/ browser registerImage:anIcon key:aKey. |
|
1539 |
"/ ]. |
|
1540 |
self columnDescriptors:(self class tableColumns). |
|
1541 |
! |
|
1542 |
||
1543 |
postBuildWith:aBuilder |
|
1544 |
||
4017 | 1545 |
updateContentsTask := DirectoryContentsUpdateTask new startWith:self. |
3887 | 1546 |
self viewedColumnsChanged. |
4017 | 1547 |
self filterBlockHolder changed. |
3887 | 1548 |
^ super postBuildWith:aBuilder. |
1549 |
! |
|
1550 |
||
1551 |
postOpenAsSubcanvasWith:aBuilder |
|
1552 |
||
1553 |
self windowGroup addPreEventHook:self. |
|
1554 |
^ super postOpenAsSubcanvasWith:aBuilder. |
|
1555 |
! |
|
1556 |
||
1557 |
postOpenWith:aBuilder |
|
1558 |
||
1559 |
" |
|
1560 |
only invoked if the application not started from a master |
|
1561 |
" |
|
4017 | 1562 |
updateContentsTask := DirectoryContentsUpdateTask new startWith:self. |
4049 | 1563 |
"/ self viewedColumnsChanged. |
1564 |
"/ self filterBlockHolder changed. |
|
4057 | 1565 |
self currentFileNameHolder changed. |
3887 | 1566 |
self windowGroup addPreEventHook:self. |
1567 |
^ super postOpenWith:aBuilder. |
|
1568 |
! |
|
1569 |
||
1570 |
preBuildWith:aBuilder |
|
1571 |
||
1572 |
self masterApplication isNil ifTrue:[ |
|
1573 |
self masterApplication:nil. |
|
1574 |
]. |
|
1575 |
^ super preBuildWith:aBuilder. |
|
1576 |
! |
|
1577 |
||
1578 |
release |
|
1579 |
"release my resources |
|
1580 |
" |
|
1581 |
self updateColumnsTaskStop. |
|
1582 |
self updateDirectoryContentsTaskStop. |
|
4017 | 1583 |
updateContentsTask stop. |
3887 | 1584 |
super release. |
1585 |
! |
|
1586 |
||
1587 |
releaseAsSubCanvas |
|
1588 |
||
1589 |
self updateColumnsTaskStop. |
|
1590 |
self updateDirectoryContentsTaskStop. |
|
1591 |
^ super releaseAsSubCanvas. |
|
1592 |
! ! |
|
1593 |
||
1594 |
!DirectoryContentsBrowser methodsFor:'task update columns'! |
|
1595 |
||
4017 | 1596 |
findNextItemFor:aBlock |
1597 |
||
1598 |
^ allItemsList detect:aBlock ifNone:[nil]. |
|
1599 |
! |
|
1600 |
||
1601 |
findNextVisibleItemFor:aConditionBlock |
|
3983 | 1602 |
|vis idx stillSearching | |
1603 |
||
1604 |
vis := contentsBrowser indexOfFirstRowShown. |
|
3887 | 1605 |
vis = 0 ifTrue:[vis := 1]. |
3983 | 1606 |
|
1607 |
idx := vis. |
|
1608 |
stillSearching := true. |
|
1609 |
[ stillSearching ] whileTrue:[ |
|
1610 |
((idx <= browserItemList size) and:[ (contentsBrowser isRowVisible:idx) ]) ifFalse:[ |
|
1611 |
stillSearching := false. |
|
1612 |
idx := nil. |
|
1613 |
] ifTrue:[ |
|
1614 |
(aConditionBlock value:(browserItemList at:idx)) ifTrue:[ |
|
1615 |
"/ found a one |
|
1616 |
stillSearching := false. |
|
1617 |
] ifFalse:[ |
|
1618 |
idx := idx + 1. |
|
1619 |
] |
|
1620 |
]. |
|
3887 | 1621 |
]. |
3983 | 1622 |
idx isNil ifTrue:[^ nil]. |
1623 |
^ browserItemList at:idx ifAbsent:nil |
|
3887 | 1624 |
! |
1625 |
||
1626 |
getFileInfoFor:aItem |
|
1627 |
||
1628 |
| type| |
|
1629 |
||
1630 |
type := aItem fileName fileType. |
|
1631 |
aItem fileType:type. |
|
1632 |
^ type |
|
1633 |
! |
|
1634 |
||
1635 |
getIconFor:aItem |
|
1636 |
||
1637 |
| key icon| |
|
3906 | 1638 |
|
3887 | 1639 |
key := aItem iconKey. |
1640 |
icon := FileBrowser iconForKeyMatching:key. |
|
3906 | 1641 |
aItem isRemoteDirectory ifTrue:[ |
1642 |
^ icon "/ do not query attributes |
|
1643 |
]. |
|
3887 | 1644 |
^ FileBrowser addOnIconsFor:(aItem fileName) to:icon. |
1645 |
! |
|
1646 |
||
1647 |
getIconForMimeTypeByContents:aItem |
|
1648 |
||
1649 |
| currentIcon newIcon icon| |
|
1650 |
newIcon := FileBrowser iconForKeyMatching:(aItem mimeTypeForContents). |
|
1651 |
currentIcon := aItem icon. |
|
1652 |
(currentIcon class == MultiImage) ifTrue:[ |
|
1653 |
| images | |
|
1654 |
images := currentIcon images. |
|
1655 |
images removeFirst. |
|
1656 |
images addFirst:newIcon. |
|
1657 |
icon := currentIcon. |
|
1658 |
] ifFalse:[ |
|
1659 |
icon := newIcon. |
|
1660 |
]. |
|
1661 |
^ icon |
|
1662 |
! |
|
1663 |
||
1664 |
getPreviewFor:aItem |
|
1665 |
||
1666 |
| column icon| |
|
1667 |
||
3983 | 1668 |
column := contentsBrowser columnAt:previewIndex. |
3887 | 1669 |
column isNil ifTrue:[ |
1670 |
previewIndex := 0. |
|
1671 |
] ifFalse:[ |
|
1672 |
(aItem hasMimeType and:[aItem mimeType isImage]) ifTrue:[ |
|
1673 |
Exception handle:[:ex| |
|
1674 |
icon := nil. |
|
1675 |
] do:[ |scale extent w h | |
|
3983 | 1676 |
icon := Image fromFile:(aItem fileName pathName). |
3887 | 1677 |
icon notNil ifTrue:[ |
1678 |
extent := icon extent. |
|
1679 |
w := column width - 4. |
|
1680 |
h := column height. |
|
1681 |
||
1682 |
(extent x > w or:[extent y > h]) ifTrue:[ |
|
1683 |
scale := extent / (w@h). |
|
1684 |
scale := scale x max:(scale y). |
|
1685 |
icon := icon magnifiedTo:((extent / scale max:8.0) asInteger). |
|
1686 |
]. |
|
3983 | 1687 |
icon := icon onDevice:(contentsBrowser device). |
3887 | 1688 |
icon clearMaskedPixels. |
1689 |
] |
|
1690 |
] |
|
1691 |
] ifFalse:[ icon := nil]. |
|
1692 |
aItem preview:(icon ? ''). |
|
1693 |
]. |
|
1694 |
^ icon |
|
1695 |
! |
|
1696 |
||
1697 |
updateChangesFor:aItem |
|
1698 |
||
3983 | 1699 |
aItem resetItemForChanges. |
3887 | 1700 |
! |
1701 |
||
1702 |
updateColumnsTaskCycle |
|
1703 |
||
1704 |
" update items in the foolowing order |
|
1705 |
- update item if item properties are changed |
|
1706 |
- update icon for visible items by suffix |
|
1707 |
- update icon for visible items by contents |
|
1708 |
- update file info for visible items if file info column is shown |
|
1709 |
- update preview for visible items if preview column is shown |
|
1710 |
||
1711 |
- update icon for invisible items by suffix |
|
1712 |
- update icon for invisible items by contents |
|
1713 |
- update file info for invisible items if file info column is shown |
|
1714 |
- update preview for invisible items if preview column is shown |
|
1715 |
- update file info for invisible items if file info column is not shown |
|
1716 |
" |
|
1717 |
||
1718 |
|desc icon type preview| |
|
1719 |
||
4017 | 1720 |
browserItemList notEmpty ifTrue:[ |
3887 | 1721 |
"/ update item if item properties are changed |
4017 | 1722 |
desc := self findNextVisibleItemFor:[:n| n hasBeenModified ]. |
3887 | 1723 |
|
1724 |
desc notNil ifTrue:[ |
|
3983 | 1725 |
contentsBrowser invalidateVisibleRow:desc. |
3887 | 1726 |
self updateChangesFor:desc. |
1727 |
^ true. |
|
1728 |
]. |
|
1729 |
"/ update icon for visible items by suffix |
|
4017 | 1730 |
desc := self findNextVisibleItemFor:[:n| n icon isNil ]. |
3967 | 1731 |
desc notNil ifTrue:[ |
3887 | 1732 |
icon := self getIconFor:desc. |
1733 |
desc icon:icon. |
|
1734 |
(icon notNil and:[iconIndex ~~ 0]) ifTrue:[ |
|
3983 | 1735 |
contentsBrowser invalidateVisibleRow:desc colAt:iconIndex |
3887 | 1736 |
]. |
1737 |
^ true |
|
1738 |
]. |
|
1739 |
"/ update icon for visible items by contents |
|
4017 | 1740 |
desc := self findNextVisibleItemFor:[:n| |
3967 | 1741 |
(n iconKey == #file |
1742 |
and:[n mimeTypeForContents asSymbol ~= #unknown]) |
|
1743 |
]. |
|
1744 |
desc notNil ifTrue:[ |
|
1745 |
icon := self getIconForMimeTypeByContents:desc. |
|
1746 |
desc icon:icon. |
|
1747 |
(icon notNil and:[iconIndex ~~ 0]) ifTrue:[ |
|
3983 | 1748 |
contentsBrowser invalidateVisibleRow:desc colAt:iconIndex |
3967 | 1749 |
]. |
1750 |
^ true |
|
1751 |
]. |
|
3887 | 1752 |
"/ update file info for visible items if file info column is shown |
1753 |
fileDescriptionIndex ~~ 0 ifTrue:[ |
|
4017 | 1754 |
desc := self findNextVisibleItemFor:[:n| n fileType isNil ]. |
3887 | 1755 |
desc notNil ifTrue:[ |
1756 |
type := self getFileInfoFor:desc. |
|
3983 | 1757 |
type notNil ifTrue:[contentsBrowser invalidateVisibleRow:desc colAt:fileDescriptionIndex]. |
3887 | 1758 |
^ true |
1759 |
] |
|
1760 |
]. |
|
1761 |
"/ update preview for visible items if preview column is shown |
|
1762 |
previewIndex ~~ 0 ifTrue:[ |
|
4017 | 1763 |
desc := self findNextVisibleItemFor:[:n| n preview isNil ]. |
3887 | 1764 |
desc notNil ifTrue:[ |
1765 |
preview := self getPreviewFor:desc. |
|
1766 |
preview notNil ifTrue:[ |
|
3983 | 1767 |
contentsBrowser invalidateVisibleRow:desc colAt:previewIndex |
3887 | 1768 |
]. |
1769 |
^ true |
|
1770 |
] |
|
1771 |
]. |
|
1772 |
]. |
|
1773 |
||
1774 |
"/ may we want to see the other items later make this items to |
|
1775 |
allItemsList notEmpty ifTrue:[ |
|
1776 |
"/ update icon for invisible items by suffix |
|
1777 |
desc := self findNextItemFor:[:n| n icon isNil ]. |
|
1778 |
desc notNil ifTrue:[ |
|
1779 |
icon := self getIconFor:desc. |
|
1780 |
desc icon:icon. |
|
1781 |
^ true |
|
1782 |
]. |
|
1783 |
"/ update icon for invisible items by contents |
|
1784 |
desc := self findNextItemFor:[:n| (n iconKey == #file and:[n mimeTypeForContents ~= #unknown])]. |
|
1785 |
desc notNil ifTrue:[ |
|
1786 |
icon := self getIconForMimeTypeByContents:desc. |
|
1787 |
desc icon:icon. |
|
1788 |
^ true |
|
1789 |
]. |
|
1790 |
"/ update file info for invisible items if file info column is shown |
|
1791 |
fileDescriptionIndex ~~ 0 ifTrue:[ |
|
1792 |
desc := self findNextItemFor:[:n| n fileType isNil ]. |
|
1793 |
desc notNil ifTrue:[ |
|
1794 |
self getFileInfoFor:desc. |
|
1795 |
^ true |
|
1796 |
]. |
|
1797 |
]. |
|
1798 |
"/ update preview for invisible items if preview column is shown |
|
1799 |
previewIndex ~~ 0 ifTrue:[ |
|
1800 |
desc := self findNextItemFor:[:n| n preview isNil ]. |
|
1801 |
desc notNil ifTrue:[ |
|
1802 |
self getPreviewFor:desc. |
|
1803 |
^ true |
|
1804 |
]. |
|
1805 |
]. |
|
1806 |
"/ update file info for invisible items if file info column is not shown |
|
1807 |
desc := self findNextItemFor:[:n| n fileType isNil ]. |
|
1808 |
desc notNil ifTrue:[ |
|
1809 |
self getFileInfoFor:desc. |
|
1810 |
^ true |
|
1811 |
]. |
|
1812 |
]. |
|
1813 |
^ false |
|
1814 |
! |
|
1815 |
||
1816 |
updateColumnsTaskStart |
|
1817 |
||
4017 | 1818 |
| somethigToDo process| |
1819 |
||
3887 | 1820 |
self directory notNil ifTrue:[ |
4017 | 1821 |
process := [ |
3887 | 1822 |
[ |
1823 |
[true] whileTrue:[ |
|
1824 |
somethigToDo := false. |
|
4017 | 1825 |
(self directory notNil) ifTrue:[ |
3887 | 1826 |
somethigToDo := self updateColumnsTaskCycle. |
1827 |
Processor yield. |
|
1828 |
]. |
|
1829 |
somethigToDo ifFalse:[ |
|
1830 |
Delay waitForSeconds:1.0 |
|
4017 | 1831 |
]. |
3887 | 1832 |
] |
1833 |
] valueNowOrOnUnwindDo:[ |
|
1834 |
self updateColumnsTask:nil. |
|
1835 |
] |
|
1836 |
] newProcess. |
|
3983 | 1837 |
"/ p priority:(Processor systemBackgroundPriority). |
4017 | 1838 |
process priorityRange:(Processor userBackgroundPriority to:Processor activePriority). |
1839 |
||
1840 |
self updateColumnsTask: process. |
|
3887 | 1841 |
self updateColumnsTask name:('DirectoryContentsBrowser update columns[', self directory baseName, ']'). |
1842 |
self updateColumnsTask resume. |
|
1843 |
] |
|
1844 |
! |
|
1845 |
||
1846 |
updateColumnsTaskStop |
|
1847 |
|task| |
|
1848 |
||
1849 |
(task := self updateColumnsTask) notNil ifTrue:[ |
|
1850 |
self updateColumnsTask:nil. |
|
1851 |
||
1852 |
Object errorSignal handle:[:ex| |
|
1853 |
Dialog warn:ex description. |
|
1854 |
]do:[ |
|
1855 |
task isDead ifFalse:[ |
|
3919 | 1856 |
task terminateWithAllSubprocessesInGroup. |
3887 | 1857 |
task waitUntilTerminated. |
1858 |
] |
|
1859 |
] |
|
1860 |
]. |
|
1861 |
! ! |
|
1862 |
||
4017 | 1863 |
!DirectoryContentsBrowser methodsFor:'task update contents'! |
3887 | 1864 |
|
1865 |
updateDirectoryContentsTaskCycle |
|
1866 |
||
1867 |
| contents| |
|
1868 |
||
4017 | 1869 |
"/ DIRECTORY CONTENTS HAVE CHANGED |
3887 | 1870 |
(modificationTime ~= self directory modificationTime) ifTrue:[ |
1871 |
modificationTime := self directory modificationTime. |
|
1872 |
contents := self directory directoryContentsAsFilenames. |
|
1873 |
contents size == 0 ifTrue:[ |
|
1874 |
allItemsList removeAll. |
|
1875 |
] ifFalse:[ |
|
1876 |
"/ MERGE WITH CURRENT CONTENTS |
|
1877 |
allItemsList reverseDo:[:aDesc| |
|
1878 |
"/ remove no longer valid files |
|
1879 |
(contents detect:[:f| aDesc fileName = f] ifNone:nil) isNil ifTrue:[ |
|
1880 |
allItemsList removeIdentical:aDesc |
|
1881 |
] |
|
1882 |
]. |
|
1883 |
allItemsList size ~~ contents size ifTrue:[ |
|
1884 |
"/ add new files |
|
1885 |
| addedFiles | |
|
1886 |
addedFiles := OrderedCollection new. |
|
1887 |
contents reverseDo:[:aFile| |
|
3983 | 1888 |
(allItemsList contains:[:item| item fileName = aFile]) ifTrue:[ |
1889 |
addedFiles add:(DirectoryContentsItem fileName:aFile) |
|
3887 | 1890 |
] |
1891 |
]. |
|
1892 |
allItemsList addAll:addedFiles. |
|
1893 |
] |
|
1894 |
]. |
|
4017 | 1895 |
"/ because this can be invoked by a background task, |
1896 |
"/ ensure that we syncronize this operation with the main browsers GUI |
|
1897 |
"/ (i.e. avoid changing the list, while the main process loops over it in |
|
1898 |
"/ a redraw, select etc.) |
|
1899 |
self enqueueMessage:#value for:[self evaluateItems] arguments:nil. |
|
3887 | 1900 |
]. |
1901 |
! |
|
1902 |
||
1903 |
updateDirectoryContentsTaskStart |
|
1904 |
|p| |
|
1905 |
||
1906 |
self directory notNil ifTrue:[ |
|
1907 |
p := [ |
|
1908 |
[ |
|
1909 |
[true] whileTrue:[ |
|
3983 | 1910 |
(contentsBrowser shown and:[self directory notNil]) ifTrue:[ |
3887 | 1911 |
self updateDirectoryContentsTaskCycle. |
1912 |
Processor yield. |
|
1913 |
]. |
|
1914 |
Delay waitForSeconds:1.0 |
|
1915 |
] |
|
1916 |
] valueNowOrOnUnwindDo:[ |
|
1917 |
self updateDirectoryContentsTask:nil. |
|
1918 |
self updateColumnsTaskStop. |
|
1919 |
] |
|
1920 |
] newProcess. |
|
1921 |
||
3983 | 1922 |
"/ p priority:(Processor systemBackgroundPriority). |
1923 |
p priorityRange:(Processor userBackgroundPriority to:Processor activePriority). |
|
3887 | 1924 |
self updateDirectoryContentsTask:p. |
1925 |
||
1926 |
p name:('DirectoryContentsBrowser update contents[', self directory baseName, ']'). |
|
1927 |
p resume. |
|
1928 |
] |
|
1929 |
! |
|
1930 |
||
1931 |
updateDirectoryContentsTaskStop |
|
1932 |
|task| |
|
1933 |
||
1934 |
(task := self updateDirectoryContentsTask) notNil ifTrue:[ |
|
1935 |
self updateDirectoryContentsTask:nil. |
|
1936 |
||
1937 |
Object errorSignal handle:[:ex| |
|
1938 |
Dialog warn:ex description. |
|
1939 |
]do:[ |
|
1940 |
task isDead ifFalse:[ |
|
3919 | 1941 |
task terminateWithAllSubprocessesInGroup. |
3887 | 1942 |
task waitUntilTerminated. |
1943 |
] |
|
1944 |
] |
|
1945 |
]. |
|
1946 |
! ! |
|
1947 |
||
1948 |
!DirectoryContentsBrowser::DirectoryContentsItem class methodsFor:'instance creation'! |
|
1949 |
||
3983 | 1950 |
fileName:aFilename |
1951 |
||
3999
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
1952 |
| instance fileItem| |
3983 | 1953 |
instance := self new. |
1954 |
aFilename asString = '..' ifTrue:[ |
|
1955 |
instance fileName:aFilename. |
|
1956 |
^ instance. |
|
1957 |
]. |
|
3999
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
1958 |
fileItem := DirectoryContents contentsItemForFileName:aFilename. |
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
1959 |
fileItem notNil ifTrue:[^ self forInfoItem:fileItem]. |
3983 | 1960 |
^ nil |
3999
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
1961 |
|
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 |
DirectoryContentsItem fileName:'..' |
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
1964 |
" |
3983 | 1965 |
! |
1966 |
||
1967 |
forInfoItem:anItem |
|
3887 | 1968 |
| instance | |
1969 |
instance := self new. |
|
3983 | 1970 |
instance fileName:anItem fileName. |
1971 |
anItem isRemoteDirectory ifTrue:[ |
|
1972 |
instance beRemoteDirectory. |
|
1973 |
] ifFalse:[ |
|
1974 |
instance fileInfo:anItem info. |
|
1975 |
]. |
|
3906 | 1976 |
^ instance |
3887 | 1977 |
! ! |
1978 |
||
1979 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'accessing'! |
|
1980 |
||
3983 | 1981 |
fileInfo:something |
1982 |
"set the value of the instance variable 'fileInfo' (automatically generated)" |
|
1983 |
||
1984 |
fileInfo := something. |
|
1985 |
! |
|
1986 |
||
3887 | 1987 |
fileName |
1988 |
"returns the fileName |
|
1989 |
" |
|
1990 |
^ fileName |
|
4023 | 1991 |
|
1992 |
||
3887 | 1993 |
! |
1994 |
||
1995 |
fileName:aFilename |
|
1996 |
"set fileName for instance |
|
1997 |
" |
|
1998 |
fileName := aFilename. |
|
1999 |
! |
|
2000 |
||
2001 |
fileType |
|
2002 |
"returns the type of the file |
|
2003 |
" |
|
2004 |
||
2005 |
^ fileType |
|
2006 |
! |
|
2007 |
||
2008 |
fileType:aType |
|
2009 |
"returns the type of the file |
|
2010 |
" |
|
2011 |
||
2012 |
fileType := aType. |
|
2013 |
! |
|
2014 |
||
2015 |
icon |
|
2016 |
"returns the icon assigned to the file |
|
2017 |
" |
|
2018 |
^ icon |
|
2019 |
||
2020 |
||
2021 |
! |
|
2022 |
||
2023 |
icon:anIcon |
|
2024 |
||
2025 |
icon := anIcon. |
|
2026 |
! |
|
2027 |
||
2028 |
iconKey |
|
2029 |
"return the value of the instance variable 'iconKey' (automatically generated)" |
|
2030 |
||
2031 |
iconKey isNil ifTrue:[ |
|
3906 | 2032 |
self isRemoteDirectory ifTrue:[ |
2033 |
iconKey := FileBrowser iconKeyForRemoteDirectory:fileName. |
|
2034 |
] ifFalse:[ |
|
2035 |
iconKey := FileBrowser iconKeyForFile:fileName. |
|
2036 |
] |
|
3887 | 2037 |
]. |
2038 |
^ iconKey |
|
2039 |
! |
|
2040 |
||
2041 |
isDirectory |
|
3967 | 2042 |
self isRemoteDirectory ifTrue:[^ true]. |
2043 |
||
2044 |
self getFileInfo. |
|
2045 |
fileInfo isNil ifTrue:[^ false]. |
|
2046 |
^ fileInfo isDirectory |
|
2047 |
! |
|
3887 | 2048 |
|
3967 | 2049 |
isSymbolicLink |
2050 |
self isRemoteDirectory ifTrue:[^ false]. |
|
2051 |
||
2052 |
self getFileInfo. |
|
2053 |
fileInfo isNil ifTrue:[^ false]. |
|
2054 |
^ fileInfo isSymbolicLink |
|
3887 | 2055 |
! |
2056 |
||
2057 |
lastButOneSuffix |
|
2058 |
"returns the suffix of the file |
|
2059 |
" |
|
2060 |
||
2061 |
^ self suffixes at:2 |
|
2062 |
! |
|
2063 |
||
2064 |
lastSuffix |
|
2065 |
"returns the suffix of the file |
|
2066 |
" |
|
2067 |
||
2068 |
^ self suffixes at:1 |
|
2069 |
! |
|
2070 |
||
2071 |
mimeType |
|
2072 |
"return the value of the instance variable 'mimeType' (automatically generated)" |
|
2073 |
||
2074 |
mimeType isNil ifTrue:[ |
|
2075 |
mimeType := MIMETypes mimeTypeForFilename:(self fileName). |
|
2076 |
mimeType isNil ifTrue:[ |
|
2077 |
mimeType := #unknown |
|
2078 |
] |
|
2079 |
]. |
|
2080 |
^ mimeType |
|
2081 |
! |
|
2082 |
||
2083 |
preview |
|
2084 |
||
2085 |
^ preview |
|
2086 |
! |
|
2087 |
||
2088 |
preview:aLabel |
|
2089 |
||
2090 |
preview := aLabel. |
|
2091 |
! |
|
2092 |
||
2093 |
suffix |
|
2094 |
"returns the suffix of the file |
|
2095 |
" |
|
4017 | 2096 |
self isDirectory ifTrue:[^'']. |
3887 | 2097 |
suffix isNil ifTrue:[ |
2098 |
(OperatingSystem isUNIXlike and:[(self baseName at:1) == $.]) ifTrue:[ |
|
2099 |
suffix := ''. |
|
2100 |
] ifFalse:[ |
|
2101 |
suffix := fileName suffix. |
|
2102 |
] |
|
2103 |
]. |
|
2104 |
^ suffix |
|
2105 |
! |
|
2106 |
||
2107 |
suffixes |
|
2108 |
||
2109 |
| lastSuff lastButOneSuff| |
|
2110 |
||
3967 | 2111 |
(fileName name occurrencesOf:$.) <= 1 ifTrue:[ |
2112 |
^ Array with:(self suffix) with:nil. |
|
2113 |
]. |
|
2114 |
(fileName baseName occurrencesOf:$.) <= 1 ifTrue:[ |
|
2115 |
^ Array with:(self suffix) with:nil. |
|
2116 |
]. |
|
3887 | 2117 |
|
3967 | 2118 |
((lastSuff := self suffix) isEmpty) ifTrue:[ |
2119 |
lastSuff := nil. |
|
2120 |
] ifFalse:[ |
|
2121 |
lastSuff := lastSuff asLowercase. |
|
2122 |
]. |
|
2123 |
||
2124 |
((lastButOneSuff := fileName withoutSuffix suffix) isEmpty) ifTrue:[ |
|
2125 |
lastButOneSuff := nil. |
|
2126 |
] ifFalse:[ |
|
2127 |
lastButOneSuff := lastButOneSuff asLowercase. |
|
2128 |
]. |
|
2129 |
||
2130 |
(lastSuff notNil and:[lastButOneSuff notNil]) ifTrue:[ |
|
2131 |
(lastSuff = 'bak' or:[lastSuff = 'sav']) ifTrue:[ |
|
2132 |
lastSuff := lastButOneSuff. |
|
3887 | 2133 |
lastButOneSuff := nil. |
3967 | 2134 |
] |
3887 | 2135 |
]. |
3967 | 2136 |
^ Array with:lastSuff with:lastButOneSuff |
3887 | 2137 |
! |
2138 |
||
2139 |
type |
|
2140 |
"returns the type of the file |
|
2141 |
" |
|
2142 |
^ self valueAt:#type |
|
2143 |
||
2144 |
! ! |
|
2145 |
||
2146 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'actions'! |
|
2147 |
||
2148 |
resetImageFile |
|
2149 |
||
2150 |
" if the image preview extent is changed the icon will set to nil to force the update task to reload the image " |
|
2151 |
||
2152 |
(mimeType notNil and:[ mimeType isImage]) ifTrue:[ |
|
2153 |
preview := nil |
|
2154 |
] |
|
2155 |
! |
|
2156 |
||
3983 | 2157 |
resetItemForChanges |
3887 | 2158 |
|
2159 |
" dont know what someone else is doing with the file - read all item properties new " |
|
2160 |
fileInfo := nil. |
|
2161 |
icon := nil. |
|
2162 |
fileType := nil. |
|
2163 |
preview := nil. |
|
2164 |
owner := nil. |
|
2165 |
group := nil. |
|
2166 |
! ! |
|
2167 |
||
2168 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'change queries'! |
|
2169 |
||
3967 | 2170 |
hasBeenModified |
3887 | 2171 |
|
2172 |
"check if item modification time is changed |
|
2173 |
" |
|
2174 |
| time info| |
|
2175 |
||
3906 | 2176 |
self isRemoteDirectory ifTrue:[^ false]. |
2177 |
||
3967 | 2178 |
info := fileName info. |
3887 | 2179 |
info isNil ifTrue:[ ^ false]. |
3962
3906b10c42fd
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
3961
diff
changeset
|
2180 |
time := info modificationTime. |
3967 | 2181 |
|
3887 | 2182 |
contentsBrowserChangeModificationTime isNil ifTrue:[ |
2183 |
contentsBrowserChangeModificationTime := time. |
|
3967 | 2184 |
fileInfo := nil. |
3887 | 2185 |
^ false. |
2186 |
]. |
|
2187 |
((contentsBrowserChangeModificationTime = time) not) ifTrue:[ |
|
2188 |
contentsBrowserChangeModificationTime := time. |
|
3967 | 2189 |
fileInfo := nil. |
3887 | 2190 |
^ true |
2191 |
]. |
|
2192 |
^ false |
|
2193 |
! ! |
|
2194 |
||
2195 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'compare'! |
|
2196 |
||
2197 |
= aItem |
|
2198 |
||
2199 |
"/ Transcript showCR:(aItem species == self species). |
|
2200 |
aItem species == self species ifFalse:[ ^ false]. |
|
2201 |
aItem isNil ifTrue:[ ^ false]. |
|
2202 |
^ (self fileName = aItem fileName) |
|
2203 |
! |
|
2204 |
||
2205 |
hash |
|
2206 |
^ fileName hash |
|
2207 |
! ! |
|
2208 |
||
2209 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'presentation'! |
|
2210 |
||
2211 |
baseName |
|
2212 |
"returns the baseName of the file |
|
2213 |
" |
|
3967 | 2214 |
^ fileName baseName. |
3887 | 2215 |
! |
2216 |
||
2217 |
baseNameWithOutSuffix |
|
2218 |
"returns the baseName of the file |
|
2219 |
" |
|
2220 |
| baseNameWithOutSuff | |
|
2221 |
||
4017 | 2222 |
self isDirectory ifTrue:[^ self baseName]. |
3887 | 2223 |
baseNameWithOutSuff := self baseName asFilename withoutSuffix asString. |
4017 | 2224 |
(baseNameWithOutSuff isEmpty or:[baseNameWithOutSuff = '.']) ifTrue:[ |
3887 | 2225 |
^ self baseName |
2226 |
]. |
|
2227 |
^ baseNameWithOutSuff. |
|
2228 |
! |
|
2229 |
||
2230 |
date |
|
3967 | 2231 |
"returns the modTimeString |
3887 | 2232 |
" |
2233 |
| modTime | |
|
2234 |
||
3967 | 2235 |
modTime := self modificationTime. |
2236 |
modTime isNil ifTrue:[ |
|
2237 |
^ '???' |
|
3887 | 2238 |
]. |
3967 | 2239 |
^ modTime asDate printString. |
3887 | 2240 |
! |
2241 |
||
2242 |
fileInfoString |
|
2243 |
"get stat info on selected file - return a string which can be |
|
2244 |
shown in a box" |
|
2245 |
||
2246 |
| afileType | |
|
2247 |
||
2248 |
fileName isNil ifTrue:[^ nil]. |
|
2249 |
afileType := self fileType. |
|
2250 |
afileType isNil ifTrue:[ |
|
2251 |
^ ''. |
|
2252 |
]. |
|
2253 |
^ afileType |
|
2254 |
! |
|
2255 |
||
3967 | 2256 |
fileSize |
2257 |
"returns the fileSize |
|
2258 |
" |
|
2259 |
self getFileInfo. |
|
2260 |
fileInfo isNil ifTrue:[^ nil]. |
|
2261 |
||
2262 |
^ fileInfo fileSize |
|
2263 |
! |
|
2264 |
||
3887 | 2265 |
group |
2266 |
"returns the printable group |
|
2267 |
" |
|
2268 |
|gid| |
|
2269 |
||
2270 |
group isNil ifTrue:[ |
|
3967 | 2271 |
self getFileInfo. |
2272 |
fileInfo isNil ifTrue:[^ '???']. |
|
2273 |
||
2274 |
gid := fileInfo gid. |
|
2275 |
(LastGIDToGroupNameMapping notNil and:[gid == LastGIDToGroupNameMapping key]) ifTrue:[ |
|
2276 |
group := LastGIDToGroupNameMapping value |
|
2277 |
] ifFalse:[ |
|
2278 |
group := OperatingSystem getGroupNameFromID:gid. |
|
2279 |
LastGIDToGroupNameMapping := gid -> group. |
|
2280 |
] |
|
3887 | 2281 |
]. |
2282 |
^ group |
|
2283 |
! |
|
2284 |
||
2285 |
modificationTime |
|
2286 |
"returns the absolute time of modification |
|
2287 |
" |
|
3967 | 2288 |
self getFileInfo. |
2289 |
fileInfo isNil ifTrue:[^ nil]. |
|
2290 |
||
2291 |
^ fileInfo modificationTime |
|
3887 | 2292 |
! |
2293 |
||
2294 |
owner |
|
2295 |
"returns the printable owner |
|
2296 |
" |
|
2297 |
|uid| |
|
2298 |
||
2299 |
owner isNil ifTrue:[ |
|
3967 | 2300 |
self getFileInfo. |
2301 |
fileInfo isNil ifTrue:[^ '???']. |
|
2302 |
||
2303 |
uid := fileInfo uid. |
|
2304 |
(LastUIDToUserNameMapping notNil and:[uid == LastUIDToUserNameMapping key]) ifTrue:[ |
|
2305 |
owner := LastUIDToUserNameMapping value |
|
2306 |
] ifFalse:[ |
|
2307 |
owner := OperatingSystem getUserNameFromID:uid. |
|
2308 |
LastUIDToUserNameMapping := uid -> owner. |
|
2309 |
] |
|
3887 | 2310 |
]. |
2311 |
^ owner |
|
2312 |
! |
|
2313 |
||
2314 |
permissions |
|
2315 |
"returns the permissions as printable string |
|
2316 |
" |
|
3967 | 2317 |
|mode permissionString| |
3887 | 2318 |
|
3967 | 2319 |
self getFileInfo. |
2320 |
fileInfo isNil ifTrue:[^ '???'.]. |
|
3887 | 2321 |
|
3967 | 2322 |
mode := fileInfo mode. |
2323 |
permissionString := String new:9 withAll:$-. |
|
2324 |
||
2325 |
1 to:9 by:3 do:[:i| |
|
2326 |
(mode bitAt:i ) == 1 ifTrue:[permissionString at:10 - i put:$x]. |
|
2327 |
(mode bitAt:i + 1) == 1 ifTrue:[permissionString at:9 - i put:$w]. |
|
2328 |
(mode bitAt:i + 2) == 1 ifTrue:[permissionString at:8 - i put:$r]. |
|
3887 | 2329 |
]. |
3967 | 2330 |
^ permissionString |
3887 | 2331 |
! |
2332 |
||
2333 |
printString |
|
3983 | 2334 |
|
2335 |
^ 'a DirectoryContentsItem [', fileName asString, ']' |
|
3887 | 2336 |
! |
2337 |
||
2338 |
sizeString |
|
2339 |
"returns the size of the file |
|
2340 |
" |
|
2341 |
| unitString n locSize| |
|
2342 |
||
3967 | 2343 |
unitString := ''. |
2344 |
locSize := self fileSize. |
|
2345 |
locSize isNil ifTrue:[^ '???']. |
|
2346 |
||
2347 |
locSize < (500 * 1024) ifTrue:[ |
|
2348 |
locSize < 1024 ifTrue:[ |
|
2349 |
n := locSize |
|
3887 | 2350 |
] ifFalse:[ |
3967 | 2351 |
n := (locSize * 10 // 1024 / 10.0). |
2352 |
unitString := ' Kb' |
|
2353 |
] |
|
2354 |
] ifFalse:[ |
|
2355 |
n := (locSize * 10 // 1024 // 1024 / 10.0). |
|
2356 |
unitString := ' Mb' |
|
3887 | 2357 |
]. |
3967 | 2358 |
^ (n printStringLeftPaddedTo:5) , unitString. |
3887 | 2359 |
! |
2360 |
||
2361 |
timeAndDate |
|
2362 |
"returns the date |
|
2363 |
" |
|
3967 | 2364 |
|modTime| |
3887 | 2365 |
|
3967 | 2366 |
modTime := self modificationTime. |
2367 |
modTime isNil ifTrue:[ |
|
2368 |
^ '???' |
|
3887 | 2369 |
]. |
3967 | 2370 |
Smalltalk languageTerritory == #us ifTrue:[ |
2371 |
^ modTime printStringFormat:'%(ShortMonthName), %(dayPadded) %(yearOrTime)'. |
|
2372 |
]. |
|
2373 |
^ modTime printStringFormat:'%(day)-%(ShortMonthName) %(yearOrTime)'. |
|
2374 |
||
2375 |
"/ ^ modTime printStringFormat:'%(year)-%(mon)-%(day) %h:%m:%s'. |
|
3887 | 2376 |
! ! |
2377 |
||
2378 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'private'! |
|
2379 |
||
3967 | 2380 |
getFileInfo |
3887 | 2381 |
fileInfo isNil ifTrue:[ |
3906 | 2382 |
self isRemoteDirectory ifTrue:[ |
2383 |
"/ do not access, to avoid automount |
|
3887 | 2384 |
] ifFalse:[ |
3967 | 2385 |
fileInfo := fileName linkInfo. |
2386 |
fileInfo isNil ifTrue:[ |
|
2387 |
fileInfo := fileName info. |
|
3906 | 2388 |
]. |
3967 | 2389 |
]. |
2390 |
]. |
|
2391 |
^ fileInfo |
|
3887 | 2392 |
! ! |
2393 |
||
2394 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'queries'! |
|
2395 |
||
3906 | 2396 |
beRemoteDirectory |
2397 |
fileType := #remoteDirectory. |
|
2398 |
! |
|
2399 |
||
3887 | 2400 |
exists |
2401 |
"returns the fileName |
|
2402 |
" |
|
2403 |
^ fileName exists |
|
2404 |
! |
|
2405 |
||
2406 |
hasMimeType |
|
2407 |
||
2408 |
^ (self mimeType ~= #unknown) |
|
2409 |
! |
|
2410 |
||
3906 | 2411 |
isRemoteDirectory |
2412 |
^ fileType == #remoteDirectory |
|
2413 |
! |
|
2414 |
||
3887 | 2415 |
mimeTypeForContents |
2416 |
||
2417 |
mimeTypeForContents isNil ifTrue:[ |
|
2418 |
mimeTypeForContents := MIMETypes mimeTypeOfContents:(self fileName). |
|
2419 |
mimeTypeForContents isNil ifTrue:[ |
|
2420 |
mimeTypeForContents := #unknown |
|
2421 |
] ifFalse:[ |
|
2422 |
" set mimeType to mimeType of contents if a better mimeType is found " |
|
2423 |
mimeType := mimeTypeForContents. |
|
2424 |
iconKey := mimeTypeForContents. |
|
2425 |
] |
|
2426 |
]. |
|
2427 |
^ mimeTypeForContents |
|
2428 |
! ! |
|
2429 |
||
4017 | 2430 |
!DirectoryContentsBrowser::DirectoryContentsUpdateTask class methodsFor:'defaults'! |
2431 |
||
2432 |
debug |
|
2433 |
||
2434 |
^ false |
|
2435 |
! ! |
|
2436 |
||
2437 |
!DirectoryContentsBrowser::DirectoryContentsUpdateTask methodsFor:'accessing'! |
|
2438 |
||
2439 |
changeSema |
|
2440 |
"return the value of the instance variable 'changeSema' (automatically generated)" |
|
2441 |
changeSema isNil ifTrue:[ |
|
2442 |
changeSema := Semaphore new. |
|
2443 |
]. |
|
2444 |
^ changeSema |
|
2445 |
! |
|
2446 |
||
2447 |
directoryChangeFlag |
|
2448 |
"return the value of the instance variable 'directoryChangeFlag' (automatically generated)" |
|
2449 |
||
2450 |
directoryChangeFlag isNil ifTrue:[ |
|
2451 |
directoryChangeFlag := false. |
|
2452 |
]. |
|
2453 |
^ directoryChangeFlag |
|
2454 |
! |
|
2455 |
||
2456 |
directoryChangeFlag:something |
|
2457 |
"set the value of the instance variable 'directoryChangeFlag' (automatically generated)" |
|
2458 |
||
2459 |
directoryChangeFlag := something. |
|
2460 |
! |
|
2461 |
||
2462 |
directoryContentsChangeFlag |
|
2463 |
"return the value of the instance variable 'directoryContentsChangeFlag' (automatically generated)" |
|
2464 |
||
2465 |
directoryContentsChangeFlag isNil ifTrue:[ |
|
2466 |
directoryContentsChangeFlag := false. |
|
2467 |
]. |
|
2468 |
^ directoryContentsChangeFlag |
|
2469 |
! |
|
2470 |
||
2471 |
directoryContentsChangeFlag:something |
|
2472 |
"set the value of the instance variable 'directoryContentsChangeFlag' (automatically generated)" |
|
2473 |
||
2474 |
directoryContentsChangeFlag := something. |
|
2475 |
! |
|
2476 |
||
2477 |
filterChangeFlag |
|
2478 |
"return the value of the instance variable 'filterChangeFlag' (automatically generated)" |
|
2479 |
||
2480 |
filterChangeFlag isNil ifTrue:[ |
|
2481 |
filterChangeFlag := false. |
|
2482 |
]. |
|
2483 |
^ filterChangeFlag |
|
2484 |
! |
|
2485 |
||
2486 |
filterChangeFlag:something |
|
2487 |
"set the value of the instance variable 'filterChangeFlag' (automatically generated)" |
|
2488 |
||
2489 |
filterChangeFlag := something. |
|
2490 |
! |
|
2491 |
||
2492 |
isBusy |
|
2493 |
"return the value of the instance variable 'isBusy' (automatically generated)" |
|
2494 |
||
2495 |
isBusy isNil ifTrue:[ |
|
2496 |
isBusy := false. |
|
2497 |
]. |
|
2498 |
^ isBusy |
|
2499 |
! |
|
2500 |
||
2501 |
isBusy:something |
|
2502 |
"set the value of the instance variable 'isBusy' (automatically generated)" |
|
2503 |
||
2504 |
isBusy := something. |
|
2505 |
! |
|
2506 |
||
2507 |
sortBlockChangeFlag |
|
2508 |
"return the value of the instance variable 'sortBlockChangeFlag' (automatically generated)" |
|
2509 |
||
2510 |
sortBlockChangeFlag isNil ifTrue:[ |
|
2511 |
sortBlockChangeFlag := false. |
|
2512 |
]. |
|
2513 |
^ sortBlockChangeFlag |
|
2514 |
! |
|
2515 |
||
2516 |
sortBlockChangeFlag:something |
|
2517 |
"set the value of the instance variable 'sortBlockChangeFlag' (automatically generated)" |
|
2518 |
||
2519 |
sortBlockChangeFlag := something. |
|
2520 |
! ! |
|
2521 |
||
2522 |
!DirectoryContentsBrowser::DirectoryContentsUpdateTask methodsFor:'actions'! |
|
2523 |
||
2524 |
debugMessage:aString |
|
2525 |
||
2526 |
self class debug ifTrue:[ |
|
2527 |
Transcript showCR:aString |
|
2528 |
]. |
|
2529 |
! |
|
2530 |
||
2531 |
wakeUpForDirectoryChanged:aDirectory |
|
2532 |
||
2533 |
self modificationTaskStop. |
|
2534 |
directory := aDirectory. |
|
2535 |
self isBusy ifTrue:[ |
|
2536 |
updateProcess interruptWith:[AbortSignal raise]. |
|
2537 |
]. |
|
2538 |
self directoryChangeFlag:true. |
|
2539 |
self changeSema signal. |
|
2540 |
! |
|
2541 |
||
2542 |
wakeUpForDirectoryContentsChanged |
|
2543 |
||
2544 |
self directoryContentsChangeFlag:true. |
|
2545 |
self changeSema signal. |
|
4019 | 2546 |
self modificationTaskStop. |
4017 | 2547 |
! |
2548 |
||
2549 |
wakeUpForFilterChanged |
|
2550 |
||
2551 |
self filterChangeFlag:true. |
|
2552 |
self sortBlockChangeFlag ifTrue:[ |
|
2553 |
updateProcess interruptWith:[AbortSignal raise]. |
|
2554 |
]. |
|
2555 |
self changeSema signal. |
|
2556 |
! |
|
2557 |
||
2558 |
wakeUpForSortBlockChanged |
|
2559 |
||
2560 |
self sortBlockChangeFlag:true. |
|
2561 |
self changeSema signal. |
|
2562 |
! ! |
|
2563 |
||
2564 |
!DirectoryContentsBrowser::DirectoryContentsUpdateTask methodsFor:'instance creation'! |
|
2565 |
||
2566 |
startWith:aDirectoryBrowser |
|
2567 |
||
2568 |
| processLoop | |
|
2569 |
||
2570 |
directoryBrowser := aDirectoryBrowser. |
|
2571 |
processLoop := self updateLoop. |
|
2572 |
updateProcess := processLoop newProcess. |
|
2573 |
updateProcess name:'DCB updateTask'. |
|
2574 |
updateProcess priorityRange:(Processor userBackgroundPriority to:Processor activePriority). |
|
2575 |
updateProcess resume. |
|
2576 |
! |
|
2577 |
||
2578 |
stop |
|
2579 |
||
2580 |
updateProcess terminate. |
|
2581 |
self modificationTaskStop. |
|
2582 |
! |
|
2583 |
||
2584 |
updateLoop |
|
2585 |
||
2586 |
^ [ |
|
2587 |
[true] whileTrue:[ |
|
2588 |
AbortSignal handle:[ |
|
2589 |
self debugMessage:'get an abort signal'. |
|
2590 |
] do:[ |
|
2591 |
self debugMessage:'sema wait'. |
|
2592 |
self changeSema wait. |
|
2593 |
self debugMessage:'sema signal'. |
|
2594 |
self isBusy:true. |
|
2595 |
[ |
|
2596 |
self directoryChangeFlag ifTrue:[ |
|
4026 | 2597 |
self directoryChangeFlag:false. |
2598 |
self debugMessage:'directoryChanged'. |
|
2599 |
self directoryChanged. |
|
4017 | 2600 |
]. |
2601 |
self directoryContentsChangeFlag ifTrue:[ |
|
4026 | 2602 |
self directoryContentsChangeFlag:false. |
2603 |
self debugMessage:'directoryContentsChanged'. |
|
2604 |
self directoryContentsChanged. |
|
4017 | 2605 |
]. |
2606 |
self filterChangeFlag ifTrue:[ |
|
4026 | 2607 |
self filterChangeFlag:false. |
2608 |
self debugMessage:'filterChanged'. |
|
2609 |
self filterChanged. |
|
4017 | 2610 |
]. |
2611 |
self sortBlockChangeFlag ifTrue:[ |
|
4026 | 2612 |
self sortBlockChangeFlag:false. |
2613 |
self debugMessage:'sortBlockChanged'. |
|
2614 |
self sortBlockChanged. |
|
4017 | 2615 |
] |
2616 |
] ensure:[ |
|
2617 |
self isBusy:false. |
|
2618 |
] |
|
2619 |
] |
|
2620 |
] |
|
2621 |
] |
|
2622 |
! ! |
|
2623 |
||
2624 |
!DirectoryContentsBrowser::DirectoryContentsUpdateTask methodsFor:'modification task'! |
|
2625 |
||
2626 |
modificationTaskStart |
|
2627 |
||
2628 |
modificationTask := [ |
|
2629 |
[ |
|
2630 |
(directory notNil) ifTrue:[ |
|
2631 |
[directory notNil and:[modificationTime = directory modificationTime]] whileTrue:[ |
|
2632 |
Processor yield. |
|
2633 |
Delay waitForSeconds:1.0 |
|
2634 |
]. |
|
2635 |
]. |
|
2636 |
modificationTime := directory modificationTime. |
|
2637 |
self wakeUpForDirectoryContentsChanged. |
|
2638 |
] valueNowOrOnUnwindDo:[ |
|
2639 |
modificationTask := nil. |
|
2640 |
] |
|
2641 |
] newProcess. |
|
2642 |
||
2643 |
"/ modificationTask priority:(Processor systemBackgroundPriority). |
|
2644 |
modificationTask priorityRange:(Processor userBackgroundPriority to:Processor activePriority). |
|
2645 |
||
2646 |
modificationTask name:('DirectoryContentsBrowser update contents[', directory baseName, ']'). |
|
2647 |
modificationTask resume. |
|
2648 |
! |
|
2649 |
||
2650 |
modificationTaskStop |
|
2651 |
||
2652 |
|task| |
|
2653 |
||
2654 |
(task := modificationTask) notNil ifTrue:[ |
|
2655 |
modificationTask := nil. |
|
2656 |
||
2657 |
Object errorSignal handle:[:ex| |
|
2658 |
Dialog warn:ex description. |
|
2659 |
]do:[ |
|
2660 |
task isDead ifFalse:[ |
|
2661 |
task terminate. |
|
2662 |
task waitUntilTerminated. |
|
2663 |
] |
|
2664 |
] |
|
2665 |
]. |
|
2666 |
! ! |
|
2667 |
||
2668 |
!DirectoryContentsBrowser::DirectoryContentsUpdateTask methodsFor:'private - actions'! |
|
2669 |
||
2670 |
directoryChanged |
|
2671 |
||
2672 |
| allItems | |
|
2673 |
||
2674 |
self modificationTaskStop. |
|
4023 | 2675 |
directory notNil ifTrue:[ |
2676 |
modificationTime := directory modificationTime. |
|
2677 |
allItems := self readDirectoryItems. |
|
2678 |
filteredItems := self evaluateFilter:allItems. |
|
2679 |
filteredItems sort:directoryBrowser sortBlockHolder value. |
|
2680 |
self modificationTaskStart. |
|
2681 |
] ifFalse:[ |
|
2682 |
allItems := OrderedCollection new. |
|
2683 |
filteredItems := OrderedCollection new. |
|
2684 |
]. |
|
4017 | 2685 |
directoryBrowser |
2686 |
enqueueMessage:#value |
|
2687 |
for:[ |
|
2688 |
directoryBrowser setBrowserItemList:filteredItems allItemsList:allItems |
|
2689 |
] |
|
2690 |
arguments:#(). |
|
2691 |
! |
|
2692 |
||
2693 |
directoryContentsChanged |
|
2694 |
||
2695 |
|allItems oldItems addItems remItems newItems| |
|
2696 |
||
2697 |
modificationTime := directory modificationTime. |
|
2698 |
allItems := self readDirectoryItems. |
|
2699 |
oldItems := filteredItems copy. |
|
2700 |
newItems := self evaluateFilter:allItems. |
|
2701 |
addItems := OrderedCollection new. |
|
2702 |
remItems := OrderedCollection new. |
|
2703 |
filteredItems size == 0 ifTrue:[ |
|
2704 |
remItems := oldItems. |
|
2705 |
] ifFalse:[ |
|
2706 |
"/ MERGE WITH CURRENT CONTENTS |
|
2707 |
oldItems reverseDo:[:anOldItem| |
|
2708 |
"/ remove no longer valid files |
|
2709 |
(newItems detectLast:[:aNewItem| aNewItem = anOldItem] ifNone:false) ifFalse:[ |
|
2710 |
remItems add:anOldItem. |
|
2711 |
oldItems removeIdentical:anOldItem |
|
2712 |
] |
|
2713 |
]. |
|
2714 |
"/ add new files |
|
2715 |
newItems do:[:aNewItem| |
|
2716 |
(oldItems detect:[:anOldItem| anOldItem = aNewItem] ifNone:false) ifFalse:[ |
|
2717 |
addItems add:aNewItem. |
|
2718 |
] |
|
2719 |
]. |
|
2720 |
]. |
|
2721 |
directoryBrowser |
|
2722 |
enqueueMessage:#value |
|
2723 |
for:[ |
|
2724 |
directoryBrowser allItems:allItems browserItemListAdd:addItems remove:remItems. |
|
2725 |
] |
|
2726 |
arguments:#(). |
|
2727 |
filteredItems := newItems. |
|
2728 |
self modificationTaskStart. |
|
2729 |
! |
|
2730 |
||
2731 |
evaluateFilter:aItemsList |
|
2732 |
||
2733 |
|showDir filterBlock newItemList noOfAddedFiles noOfFiles| |
|
2734 |
||
2735 |
newItemList := OrderedCollection new. |
|
2736 |
noOfFiles := 0. |
|
2737 |
noOfAddedFiles := 0. |
|
2738 |
showDir := directoryBrowser viewDirectoriesInDirectoryContentsBrowser value. |
|
2739 |
filterBlock := directoryBrowser matchBlock. |
|
2740 |
aItemsList size ~~ 0 ifTrue:[ |
|
2741 |
aItemsList do:[:aItem | |isDir| |
|
2742 |
isDir := aItem isDirectory. |
|
2743 |
isDir not ifTrue:[noOfFiles := noOfFiles + 1]. |
|
2744 |
((isDir and:[showDir]) or:[isDir not and:[filterBlock value:aItem baseName]]) ifTrue:[ |
|
2745 |
isDir not ifTrue:[noOfAddedFiles := noOfAddedFiles + 1]. |
|
2746 |
newItemList add:aItem |
|
2747 |
] |
|
2748 |
]. |
|
2749 |
]. |
|
2750 |
directoryBrowser noOfAddedFiles:noOfAddedFiles noOfFiles:noOfFiles. |
|
2751 |
^ newItemList |
|
2752 |
! |
|
2753 |
||
2754 |
filterChanged |
|
2755 |
||
2756 |
filteredItems := self evaluateFilter:directoryBrowser allItemsList copy. |
|
2757 |
filteredItems sort:directoryBrowser sortBlockHolder value. |
|
2758 |
directoryBrowser |
|
2759 |
enqueueMessage:#value |
|
2760 |
for:[ |
|
2761 |
directoryBrowser setBrowserItemList:filteredItems allItemsList:nil |
|
2762 |
] |
|
2763 |
arguments:nil. |
|
2764 |
! |
|
2765 |
||
2766 |
mergeItems:newItems with:oldItems |
|
2767 |
||
2768 |
| changeDict | |
|
2769 |
||
2770 |
changeDict := Dictionary new. |
|
2771 |
changeDict at:#removeItems put:OrderedCollection new. |
|
2772 |
changeDict at:#addItems put:OrderedCollection new. |
|
2773 |
newItems size == 0 ifTrue:[ |
|
2774 |
changeDict at:#removeItems put:oldItems. |
|
2775 |
] ifFalse:[ |
|
2776 |
"/ MERGE WITH CURRENT CONTENTS |
|
2777 |
oldItems reverseDo:[:anOldItem| |
|
2778 |
"/ remove no longer valid files |
|
2779 |
(newItems detect:[:aNewItem| aNewItem = anOldItem] ifNone:nil) isNil ifTrue:[ |
|
2780 |
(changeDict at:#removeItems) add:anOldItem |
|
2781 |
] |
|
2782 |
]. |
|
2783 |
"/ add new files |
|
2784 |
newItems reverseDo:[:aNewItem| |
|
2785 |
(oldItems contains:[:anOldItem| anOldItem = aNewItem]) not ifTrue:[ |
|
2786 |
(changeDict at:#addItems) add:aNewItem. |
|
2787 |
] |
|
2788 |
]. |
|
2789 |
]. |
|
2790 |
^ changeDict |
|
2791 |
! |
|
2792 |
||
2793 |
readDirectoryItems |
|
2794 |
| list mountPoints contents| |
|
2795 |
||
2796 |
mountPoints := OperatingSystem mountPoints. |
|
2797 |
||
2798 |
list := OrderedCollection new. |
|
2799 |
directory notNil ifTrue:[ |
|
2800 |
contents := DirectoryContents directoryNamed:directory. |
|
2801 |
contents itemsDo:[:aItem| |
|
2802 |
list add:(DirectoryContentsBrowser itemClass forInfoItem:aItem). |
|
2803 |
]. |
|
2804 |
]. |
|
2805 |
^ list |
|
2806 |
! |
|
2807 |
||
2808 |
sortBlockChanged |
|
2809 |
||
2810 |
filteredItems sort:directoryBrowser sortBlockHolder value. |
|
2811 |
directoryBrowser |
|
2812 |
enqueueMessage:#value |
|
2813 |
for:[ |
|
2814 |
directoryBrowser setBrowserItemList:filteredItems allItemsList:nil |
|
2815 |
] |
|
2816 |
arguments:nil. |
|
2817 |
! ! |
|
2818 |
||
3887 | 2819 |
!DirectoryContentsBrowser class methodsFor:'documentation'! |
2820 |
||
2821 |
version |
|
4057 | 2822 |
^ '$Header: /cvs/stx/stx/libtool/DirectoryContentsBrowser.st,v 1.38 2002-10-25 11:11:24 penk Exp $' |
3887 | 2823 |
! ! |