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