author | penk |
Wed, 16 Oct 2002 17:07:50 +0200 | |
changeset 4011 | 73fa35b1963b |
parent 4007 | 8f54ab1dbaa0 |
child 4012 | fa4418738475 |
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 |
6 |
fileDescriptionIndex iconExtent tableColumns currentSortOrder |
|
7 |
previewIndex allItemsList currentItemList wantSelectFiles |
|
8 |
updateToExternFileHolderLock updateTaskSema inDropMode |
|
9 |
draggedItem canDropItem viewBrowserMenu updateContentsSelection |
|
10 |
selectionInFileList 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:[ |
3984 | 901 |
self enterActionFor:(self selectedItems first). "/ anItemIndex. |
3906 | 902 |
] |
3887 | 903 |
! |
904 |
||
905 |
enterActionFor:anItem |
|
906 |
| filename| |
|
907 |
||
908 |
filename := anItem fileName. |
|
3906 | 909 |
|
3887 | 910 |
filename = '..' asFilename ifTrue:[ |
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:[ |
|
3983 | 940 |
directoryUpItem := DirectoryContentsItem fileName:('..' asFilename). |
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. |
|
954 |
wantSelectFiles notNil ifTrue:[ |
|
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 |
]. |
|
3983 | 1005 |
wantSelectFiles := aColOfFiles. "/ set the file to the current filename to change selection if update process have added the list |
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. |
|
3989 | 1028 |
selection remove:('..' asFilename) ifAbsent:[nil]. |
3983 | 1029 |
selection isEmpty ifTrue:[ |
4004 | 1030 |
newCurrentFilename := OrderedCollection with:self directory. |
3983 | 1031 |
] ifFalse:[ |
1032 |
wantSelectFiles := selection. |
|
4004 | 1033 |
newCurrentFilename := selection. |
3983 | 1034 |
]. |
4004 | 1035 |
self currentFileNameHolder value ~= newCurrentFilename ifTrue:[ |
1036 |
self currentFileNameHolder value:newCurrentFilename withoutNotifying:self |
|
1037 |
] |
|
3983 | 1038 |
! |
1039 |
||
3887 | 1040 |
update:something with:aParameter from:aModel |
1041 |
"one of my models changed |
|
1042 |
" |
|
3983 | 1043 |
|
1044 |
aModel == self currentFileNameHolder ifTrue:[ |
|
4007 | 1045 |
super update:something with:aParameter from:aModel. |
3983 | 1046 |
self updateContentsSelection doIfUnLocked:[ |
1047 |
self updateToExternFileHolderLock doLocked:[ |
|
1048 |
self currentFileNameHolderChanged. |
|
1049 |
]. |
|
1050 |
]. |
|
4007 | 1051 |
^ self. |
3983 | 1052 |
]. |
1053 |
aModel == self selectionInFileList ifTrue:[ |
|
1054 |
self updateToExternFileHolderLock doIfUnLocked:[ |
|
1055 |
self updateContentsSelection doLocked:[ |
|
1056 |
self selectionChanged. |
|
1057 |
] |
|
1058 |
]. |
|
1059 |
^ self. |
|
1060 |
]. |
|
4011 | 1061 |
aModel == self filterBlockHolder ifTrue:[ |
3983 | 1062 |
self updateToExternFileHolderLock doLocked:[ |
1063 |
self filterChanged. |
|
1064 |
]. |
|
3887 | 1065 |
^ self. |
1066 |
]. |
|
1067 |
aModel == self sortBlockHolder ifTrue:[ |
|
3989 | 1068 |
self evaluateSortBlock. |
3887 | 1069 |
^ self. |
1070 |
]. |
|
1071 |
aModel == self viewDirectoriesInDirectoryContentsBrowser ifTrue:[ |
|
1072 |
self evaluateFilter. |
|
1073 |
^ self |
|
1074 |
]. |
|
1075 |
||
1076 |
super update:something with:aParameter from:aModel |
|
1077 |
! |
|
1078 |
||
1079 |
viewedColumnsChanged |
|
1080 |
||
1081 |
| columns buffer | |
|
1082 |
||
1083 |
columns := OrderedCollection new. |
|
1084 |
self class tableColumns do:[:el| |
|
1085 |
columns add:(DataSetColumnSpec new fromLiteralArrayEncoding:el). |
|
1086 |
]. |
|
1087 |
buffer := columns copy. |
|
1088 |
self viewDetails value = false ifTrue:[ |
|
3983 | 1089 |
contentsBrowser showLabels:false. |
3887 | 1090 |
buffer do:[:col | |
1091 |
(col readSelector = #baseName or:[col readSelector = #icon]) ifFalse:[ |
|
1092 |
columns remove:col. |
|
1093 |
] |
|
1094 |
] |
|
1095 |
] ifFalse:[ |
|
3983 | 1096 |
contentsBrowser showLabels:true. |
3887 | 1097 |
buffer do:[:col | |
1098 |
| id | |
|
1099 |
id := col id. |
|
1100 |
id notNil ifTrue:[ |
|
1101 |
||
1102 |
(id == #filename) ifTrue:[ |
|
1103 |
self viewType value ifTrue:[ |
|
1104 |
col readSelector:#baseNameWithOutSuffix |
|
1105 |
] ifFalse:[ |
|
1106 |
col readSelector:#baseName |
|
1107 |
]. |
|
1108 |
] ifFalse:[ |
|
1109 |
(id == #suffix and:[self viewType value not]) ifTrue:[ |
|
1110 |
columns remove:col. |
|
1111 |
] ifFalse:[ |
|
1112 |
(id == #group and:[self viewGroup value not]) ifTrue:[ |
|
1113 |
columns remove:col. |
|
1114 |
] ifFalse:[ |
|
1115 |
(id == #owner and:[self viewOwner value not]) ifTrue:[ |
|
1116 |
columns remove:col. |
|
1117 |
] ifFalse:[ |
|
1118 |
(id == #perm and:[self viewPermissions value not]) ifTrue:[ |
|
1119 |
columns remove:col. |
|
1120 |
] ifFalse:[ |
|
1121 |
(id == #preview and:[self viewPreview value not]) ifTrue:[ |
|
1122 |
columns remove:col. |
|
1123 |
] ifFalse:[ |
|
1124 |
(id == #size and:[self viewSize value not]) ifTrue:[ |
|
1125 |
columns remove:col. |
|
1126 |
] ifFalse:[ |
|
3964 | 1127 |
(id == #time and:[self viewTime value not]) ifTrue:[ |
3887 | 1128 |
columns remove:col. |
1129 |
] ifFalse:[ |
|
1130 |
(id == #fileInfo and:[self viewDescription value not]) ifTrue:[ |
|
1131 |
columns remove:col. |
|
1132 |
] |
|
1133 |
] |
|
1134 |
] |
|
1135 |
] |
|
1136 |
] |
|
1137 |
] |
|
1138 |
] |
|
1139 |
] |
|
1140 |
] |
|
1141 |
] |
|
1142 |
] |
|
1143 |
]. |
|
1144 |
self tableColumns value:columns. |
|
1145 |
self columnDescriptors:(self tableColumns value). |
|
1146 |
! ! |
|
1147 |
||
1148 |
!DirectoryContentsBrowser methodsFor:'directory contents'! |
|
1149 |
||
1150 |
evaluateFilter |
|
4011 | 1151 |
|filterBlock | |
1152 |
||
3887 | 1153 |
|
1154 |
currentItemList := OrderedCollection new. |
|
1155 |
allItemsList size ~~ 0 ifTrue:[ |
|
4011 | 1156 |
filterBlock := self filterBlockHolder value. |
3925 | 1157 |
allItemsList do:[:aItem | |
4011 | 1158 |
(aItem isDirectory or:[filterBlock value:aItem baseName]) ifTrue:[ |
1159 |
currentItemList add:aItem |
|
3887 | 1160 |
] |
1161 |
]. |
|
1162 |
]. |
|
1163 |
self evaluateSortBlock. |
|
1164 |
! |
|
1165 |
||
1166 |
evaluateSortBlock |
|
1167 |
||
1168 |
| newList| |
|
1169 |
||
3983 | 1170 |
newList := currentItemList. |
3989 | 1171 |
newList sort:self sortBlockHolder value. |
3983 | 1172 |
self descriptions:newList asList. |
3887 | 1173 |
! |
1174 |
||
1175 |
readDirectoryItems |
|
3983 | 1176 |
|dir list mountPoints contents| |
3887 | 1177 |
|
3906 | 1178 |
mountPoints := OperatingSystem mountPoints. |
3887 | 1179 |
|
1180 |
dir := self directory. |
|
1181 |
list := OrderedCollection new. |
|
1182 |
dir notNil ifTrue:[ |
|
3906 | 1183 |
modificationTime := dir modificationTime. |
3983 | 1184 |
contents := DirectoryContents directoryNamed:dir. |
1185 |
contents itemsDo:[:aItem| |
|
1186 |
list add:(DirectoryContentsItem forInfoItem:aItem). |
|
3887 | 1187 |
]. |
1188 |
]. |
|
1189 |
^ list |
|
1190 |
! ! |
|
1191 |
||
1192 |
!DirectoryContentsBrowser methodsFor:'drag & drop'! |
|
1193 |
||
3953 | 1194 |
canDrop:aContext |
3887 | 1195 |
|
3953 | 1196 |
^ canDropItem |
3887 | 1197 |
! |
1198 |
||
3953 | 1199 |
doDrop:aContext |
3887 | 1200 |
|
3953 | 1201 |
|col destinationPath receiver| |
3887 | 1202 |
|
3953 | 1203 |
draggedItem isNil ifTrue:[ |
3887 | 1204 |
destinationPath := self directory. |
1205 |
] ifFalse:[ |
|
3953 | 1206 |
destinationPath := self getDirWithoutFileName:(draggedItem fileName). |
1207 |
destinationPath = '..' asFilename ifTrue:[ |
|
1208 |
destinationPath := self directory directory. |
|
1209 |
] |
|
3887 | 1210 |
]. |
3953 | 1211 |
self dropLeave:aContext. |
1212 |
aContext dropSource argument == #archivApplication ifTrue:[ |
|
1213 |
receiver := aContext dropSource receiver. |
|
3887 | 1214 |
receiver extractSelectedFilesTo:destinationPath askForExtractOptions:true. |
1215 |
^ true. |
|
1216 |
]. |
|
1217 |
col := OrderedCollection new. |
|
1218 |
aContext dropObjects do:[:obj| |
|
1219 |
col add:(obj theObject). |
|
1220 |
]. |
|
3953 | 1221 |
self copyOrMoveFiles:col to:destinationPath. |
1222 |
^ true. |
|
3887 | 1223 |
! |
1224 |
||
1225 |
doStartDrag:aDropSource in:aView |
|
1226 |
"set the cursors before starting the drag & drop operation |
|
1227 |
" |
|
3983 | 1228 |
|selectedFiles| |
1229 |
||
1230 |
selectedFiles := self selectedFiles. |
|
1231 |
(selectedFiles size == 1 and:[selectedFiles first baseName = '..']) ifTrue:[ |
|
3887 | 1232 |
^ self. |
1233 |
]. |
|
3953 | 1234 |
^ super doStartDrag:aDropSource in:aView |
1235 |
! |
|
1236 |
||
1237 |
dropEnter:aContext |
|
1238 |
||
1239 |
|dropedObjects| |
|
1240 |
||
1241 |
self dropTargetItemChangedTo:nil in:aContext. |
|
1242 |
inDropMode := false. |
|
1243 |
||
1244 |
self directory isNil ifTrue:[^ self]. |
|
1245 |
dropedObjects := aContext dropObjects. |
|
1246 |
||
1247 |
dropedObjects do:[:aObject| |
|
1248 |
|checkObject checkObjectString| |
|
1249 |
aObject isFileObject ifFalse:[^ self]. |
|
1250 |
checkObject := aObject theObject. |
|
1251 |
checkObject isFilename not ifTrue:[^ self]. |
|
1252 |
((aContext dropSource argument == #archivApplication) not) ifTrue:[ |
|
1253 |
checkObject isSpecialFile ifTrue:[^ self]. |
|
1254 |
checkObject isReadable ifFalse:[^ self]. |
|
1255 |
]. |
|
1256 |
]. |
|
1257 |
inDropMode := true. |
|
3887 | 1258 |
! |
1259 |
||
1260 |
dropLeave:aDropContext |
|
1261 |
||
3953 | 1262 |
inDropMode ifTrue:[ |
1263 |
self dropTargetItemChangedTo:nil in:aDropContext. |
|
1264 |
inDropMode := false. |
|
1265 |
]. |
|
3887 | 1266 |
! |
1267 |
||
3953 | 1268 |
dropOver:aContext |
1269 |
"send the last time, when leaving the widget |
|
1270 |
" |
|
1271 |
|lineNr newDest destinationFile| |
|
1272 |
||
1273 |
inDropMode ifFalse:[^ self]. |
|
1274 |
||
1275 |
lineNr := self getLineNumberFor:aContext. |
|
1276 |
||
1277 |
lineNr notNil ifTrue:[ |
|
3983 | 1278 |
newDest := browserItemList at:lineNr. |
3953 | 1279 |
(newDest notNil and:[newDest isDirectory]) ifTrue:[ |
1280 |
destinationFile := newDest fileName. |
|
1281 |
destinationFile = '..' asFilename ifTrue:[ |
|
1282 |
destinationFile := self directory directory. |
|
1283 |
] |
|
1284 |
]. |
|
1285 |
]. |
|
1286 |
newDest == draggedItem ifTrue:[^ self]. |
|
1287 |
||
1288 |
destinationFile isNil ifTrue:[ |
|
1289 |
destinationFile := self directory. |
|
1290 |
]. |
|
3887 | 1291 |
|
3953 | 1292 |
newDest ~~ draggedItem ifTrue:[ |
1293 |
aContext dropSource argument == #archivApplication ifTrue:[ |
|
1294 |
canDropItem := true. |
|
1295 |
] ifFalse:[ |
|
1296 |
canDropItem := self canDropFiles:(aContext dropObjects) for:destinationFile. |
|
1297 |
]. |
|
1298 |
]. |
|
1299 |
self dropTargetItemChangedTo:newDest in:aContext. |
|
1300 |
! |
|
1301 |
||
1302 |
dropTargetItemChangedTo:anItem in:aDropContext |
|
1303 |
||
1304 |
| current | |
|
1305 |
||
1306 |
||
1307 |
"/ (anItem notNil and:[anItem isDirectory]) ifTrue:[ self halt]. |
|
1308 |
current := draggedItem. |
|
3967 | 1309 |
"/ Transcript showCR:'current:', (current isNil ifTrue:['nil'] ifFalse:[current fileName baseName]). |
1310 |
"/ Transcript showCR:'anItem:', (anItem isNil ifTrue:['nil'] ifFalse:[anItem fileName baseName]). |
|
3953 | 1311 |
current == anItem ifTrue:[^ self]. |
1312 |
draggedItem := anItem. |
|
1313 |
||
1314 |
aDropContext contentsWillChange. |
|
1315 |
||
1316 |
current ifNotNil:[ |
|
1317 |
current isDirectory ifTrue:[ |
|
1318 |
current icon:(self getIconFor:current). |
|
1319 |
]. |
|
1320 |
]. |
|
1321 |
||
1322 |
anItem ifNotNil:[ |
|
1323 |
anItem isDirectory ifTrue:[ |
|
1324 |
anItem icon:(FileBrowser iconForKeyMatching:#directoryOpenGray). |
|
1325 |
]. |
|
1326 |
]. |
|
3983 | 1327 |
contentsBrowser shown ifTrue:[ |
1328 |
contentsBrowser invalidateVisibleRow:current colAt:iconIndex. |
|
1329 |
contentsBrowser invalidateVisibleRow:anItem colAt:iconIndex. |
|
1330 |
contentsBrowser repairDamage. |
|
3953 | 1331 |
]. |
3887 | 1332 |
! |
1333 |
||
1334 |
getDisplayObjects:anArgument |
|
1335 |
||
3983 | 1336 |
| selectedFiles string fnName stream| |
1337 |
selectedFiles := self selectedFiles. |
|
1338 |
selectedFiles isEmpty ifTrue:[ ^ '']. |
|
1339 |
selectedFiles remove:('..' asFilename) ifAbsent:[nil]. |
|
3887 | 1340 |
stream := WriteStream on:''. |
3983 | 1341 |
|
1342 |
stream nextPutAll:(selectedFiles first baseName). |
|
1343 |
selectedFiles size == 1 ifTrue:[ |
|
3887 | 1344 |
fnName := 'ui_menuitem.xpm'. |
1345 |
] ifFalse:[ |
|
1346 |
fnName := 'ui_submenu_open.xpm'. |
|
1347 |
stream nextPutAll:' ... '. |
|
3983 | 1348 |
stream nextPutAll:(selectedFiles last baseName). |
3887 | 1349 |
]. |
1350 |
string := stream contents. |
|
1351 |
stream close. |
|
1352 |
^ Array with:(LabelAndIcon icon:(Image fromFile:fnName) |
|
1353 |
string:(Text string:string emphasis:#bold) |
|
1354 |
) |
|
1355 |
! |
|
1356 |
||
1357 |
getDropObjects:anArgument |
|
1358 |
||
3983 | 1359 |
^ self selectedFiles collect:[:file| DropObject newFile:file]. |
3887 | 1360 |
! |
1361 |
||
1362 |
getLineNumberFor:aDropContext |
|
1363 |
| yVisible| |
|
1364 |
||
1365 |
yVisible := (aDropContext targetPoint y). |
|
3983 | 1366 |
^ contentsBrowser yVisibleToRowNr:yVisible. |
3887 | 1367 |
! ! |
1368 |
||
1369 |
!DirectoryContentsBrowser methodsFor:'event handling'! |
|
1370 |
||
1371 |
processEvent:anEvent |
|
1372 |
"filter keyboard events. |
|
1373 |
Return true, if I have eaten the event" |
|
1374 |
||
1375 |
|focusView key rawKey| |
|
1376 |
||
1377 |
anEvent isKeyPressEvent ifTrue:[ |
|
1378 |
focusView := anEvent targetView. |
|
1379 |
key := anEvent key. |
|
1380 |
rawKey := anEvent rawKey. |
|
1381 |
||
3983 | 1382 |
(focusView == contentsBrowser) ifTrue:[ |
3887 | 1383 |
"/ (key ~= #'Alt_L') ifTrue:[self halt.]. |
1384 |
key == #Paste ifTrue:[ |
|
1385 |
self pasteFiles. |
|
1386 |
^ true. |
|
1387 |
]. |
|
3983 | 1388 |
(key == #CursorLeft) ifTrue:[ |
1389 |
self doGoDirectoryUp. |
|
1390 |
^ true |
|
1391 |
]. |
|
1392 |
(key == #CursorRight) ifTrue:[ |
|
1393 |
self doBack. |
|
1394 |
^ true |
|
1395 |
]. |
|
1396 |
browserItemList size == 0 ifTrue:[ |
|
3887 | 1397 |
^ false |
1398 |
]. |
|
1399 |
key == #Copy ifTrue:[ |
|
1400 |
self doCopy. |
|
1401 |
^ true. |
|
1402 |
]. |
|
1403 |
(key == #Return) ifTrue:[ |
|
1404 |
self doOpenSelectedFile. |
|
1405 |
^ true. |
|
1406 |
]. |
|
1407 |
key == #Delete ifTrue:[ |
|
1408 |
self doDelete. |
|
1409 |
^ true. |
|
1410 |
]. |
|
1411 |
key == #Cut ifTrue:[ |
|
1412 |
self doCut. |
|
1413 |
^ true. |
|
1414 |
]. |
|
1415 |
] |
|
1416 |
]. |
|
1417 |
^ false |
|
1418 |
! ! |
|
1419 |
||
1420 |
!DirectoryContentsBrowser methodsFor:'file actions'! |
|
1421 |
||
1422 |
doCopy |
|
1423 |
"copy current selected files/directories |
|
1424 |
" |
|
1425 |
||
3983 | 1426 |
self copyFilesToClipBoard:(self selectedFiles). |
3887 | 1427 |
! |
1428 |
||
1429 |
doCut |
|
1430 |
"cut current selected files/directories |
|
1431 |
" |
|
1432 |
||
3983 | 1433 |
self cutFilesToClipBoard:(self selectedFiles). |
3887 | 1434 |
! |
1435 |
||
1436 |
doDelete |
|
1437 |
"delete current selected files/directories |
|
1438 |
" |
|
3983 | 1439 |
self deleteFiles:(self selectedFiles). |
3887 | 1440 |
! ! |
1441 |
||
1442 |
!DirectoryContentsBrowser methodsFor:'menu accessing'! |
|
1443 |
||
1444 |
viewBrowserMenu |
|
1445 |
||
1446 |
<resource: #programMenu > |
|
1447 |
||
1448 |
|menu| |
|
1449 |
||
3961 | 1450 |
viewBrowserMenu isNil ifTrue:[ |
1451 |
viewBrowserMenu := self class viewBrowserMenu. |
|
1452 |
]. |
|
1453 |
viewBrowserMenu ifNil:[ ^ nil ]. |
|
1454 |
menu := viewBrowserMenu. |
|
3887 | 1455 |
menu receiver:self. |
1456 |
^ menu |
|
3980 | 1457 |
! |
1458 |
||
1459 |
viewDetailsMenuSpec |
|
1460 |
^self class viewDetailsMenuSpec |
|
3887 | 1461 |
! ! |
1462 |
||
1463 |
!DirectoryContentsBrowser methodsFor:'menu actions'! |
|
1464 |
||
1465 |
doOpenSelectedFile |
|
1466 |
||
3983 | 1467 |
| selectedFileItems| |
1468 |
||
1469 |
selectedFileItems := self selectedFileItems. |
|
1470 |
(selectedFileItems size == 1) ifTrue:[ |
|
1471 |
self enterActionFor:(selectedFileItems first). |
|
3887 | 1472 |
]. |
1473 |
! |
|
1474 |
||
1475 |
doShowFileContents |
|
1476 |
||
3983 | 1477 |
| selectedFileItems| |
1478 |
||
1479 |
selectedFileItems := self selectedFileItems. |
|
1480 |
(selectedFileItems size == 1) ifTrue:[ |
|
1481 |
self openTextEditorOn:(selectedFileItems first). |
|
3887 | 1482 |
]. |
1483 |
! ! |
|
1484 |
||
1485 |
!DirectoryContentsBrowser methodsFor:'queries'! |
|
1486 |
||
1487 |
allItemsOfCurrentDirectory |
|
1488 |
||
3983 | 1489 |
| list | |
1490 |
list := browserItemList copy. |
|
1491 |
self viewDirectoriesInDirectoryContentsBrowser value ifTrue:[ |
|
1492 |
list removeIdentical:(browserItemList first) ifAbsent:[nil] |
|
1493 |
]. |
|
1494 |
^ list. |
|
3887 | 1495 |
! |
1496 |
||
1497 |
fileListIsEmpty |
|
1498 |
||
3983 | 1499 |
^ browserItemList isEmpty |
3887 | 1500 |
! |
1501 |
||
1502 |
getAllFilesAsStringCollection |
|
1503 |
|files items| |
|
1504 |
||
3983 | 1505 |
items := browserItemList. |
3887 | 1506 |
files := OrderedCollection new. |
1507 |
items isEmpty ifTrue:[ |
|
1508 |
^ files |
|
1509 |
]. |
|
1510 |
items do:[:aItem | |
|
1511 |
aItem isDirectory not ifTrue:[ |
|
1512 |
files add:aItem fileName asString |
|
1513 |
]. |
|
1514 |
]. |
|
1515 |
^ files. |
|
4004 | 1516 |
! |
1517 |
||
1518 |
hasFilesFiltered |
|
1519 |
^ allItemsList size ~~ currentItemList size |
|
3983 | 1520 |
! ! |
1521 |
||
1522 |
!DirectoryContentsBrowser methodsFor:'selection'! |
|
1523 |
||
1524 |
firstSelectedItem |
|
1525 |
||
1526 |
^ self selectedItems first. |
|
3887 | 1527 |
! |
1528 |
||
3983 | 1529 |
selectAll |
1530 |
||
1531 |
| sel| |
|
1532 |
||
1533 |
sel := browserItemList copy. |
|
1534 |
sel notEmpty ifTrue:[ |
|
1535 |
sel first fileName baseName = '..' ifTrue:[ |
|
1536 |
sel removeFirst. |
|
3887 | 1537 |
] |
1538 |
]. |
|
3983 | 1539 |
self selectionInFileList value:sel. |
3887 | 1540 |
! |
1541 |
||
3983 | 1542 |
selectFiles:aColOfFilenames |
1543 |
| curSel newSel| |
|
1544 |
||
1545 |
curSel := self selectedFiles. |
|
1546 |
aColOfFilenames size = curSel size ifTrue:[ |
|
1547 |
| index | |
|
1548 |
index := curSel findFirst:[:file| (aColOfFilenames includes:file) not]. |
|
1549 |
index == 0 ifTrue:[ ^ self]. |
|
3887 | 1550 |
]. |
3983 | 1551 |
newSel := OrderedCollection new. |
1552 |
browserItemList do:[: item| |
|
1553 |
(aColOfFilenames includes:(item fileName)) ifTrue:[ |
|
1554 |
newSel add:item. |
|
1555 |
]. |
|
3887 | 1556 |
]. |
3983 | 1557 |
self selectionInFileList value:newSel. |
1558 |
! |
|
1559 |
||
1560 |
selectedFileItems |
|
1561 |
||
1562 |
| sel | |
|
1563 |
||
3985 | 1564 |
sel := self selectedItems select:[:item | item isDirectory not]. |
3987 | 1565 |
^ sel |
1566 |
! |
|
1567 |
||
1568 |
selectedFileNames |
|
1569 |
^ self selectedFileItems collect:[:item| item fileName]. |
|
3887 | 1570 |
! |
1571 |
||
3983 | 1572 |
selectedFiles |
1573 |
||
1574 |
^ self selectedItems collect:[: item| item fileName]. |
|
1575 |
! |
|
1576 |
||
1577 |
selectedItems |
|
1578 |
||
1579 |
| sel | |
|
1580 |
sel := self selectionInFileList value copy. |
|
1581 |
sel isNil ifTrue:[ ^ #()]. |
|
1582 |
self viewDirectoriesInDirectoryContentsBrowser value ifTrue:[ |
|
1583 |
sel removeIdentical:(browserItemList first) ifAbsent:[nil] |
|
3887 | 1584 |
]. |
3983 | 1585 |
^ self selectionInFileList value. |
3887 | 1586 |
! ! |
1587 |
||
1588 |
!DirectoryContentsBrowser methodsFor:'startup / release'! |
|
1589 |
||
1590 |
makeDependent |
|
1591 |
||
4007 | 1592 |
super makeDependent. |
3887 | 1593 |
self currentFileNameHolder addDependent:self. |
1594 |
self viewDirectoriesInDirectoryContentsBrowser addDependent:self. |
|
4011 | 1595 |
self filterBlockHolder addDependent:self. |
3887 | 1596 |
self sortBlockHolder addDependent:self. |
1597 |
self viewDescription onChangeSend:#viewedColumnsChanged to:self. |
|
1598 |
self viewDetails onChangeSend:#viewedColumnsChanged to:self. |
|
1599 |
self viewGroup onChangeSend:#viewedColumnsChanged to:self. |
|
1600 |
self viewOwner onChangeSend:#viewedColumnsChanged to:self. |
|
1601 |
self viewPermissions onChangeSend:#viewedColumnsChanged to:self. |
|
1602 |
self viewPreview onChangeSend:#viewedColumnsChanged to:self. |
|
1603 |
self viewSize onChangeSend:#viewedColumnsChanged to:self. |
|
1604 |
self viewTime onChangeSend:#viewedColumnsChanged to:self. |
|
1605 |
self viewType onChangeSend:#viewedColumnsChanged to:self. |
|
1606 |
! |
|
1607 |
||
1608 |
postBuildBrowser:aWidget |
|
1609 |
||
3983 | 1610 |
contentsBrowser := aWidget scrolledView. |
1611 |
contentsBrowser wantsFocusWithPointerEnter. |
|
3887 | 1612 |
"/ dont register icons anymore |
1613 |
"/ FileBrowser icons keysAndValuesDo:[:aKey :anIcon| |
|
1614 |
"/ browser registerImage:anIcon key:aKey. |
|
1615 |
"/ ]. |
|
1616 |
self columnDescriptors:(self class tableColumns). |
|
1617 |
! |
|
1618 |
||
1619 |
postBuildWith:aBuilder |
|
1620 |
||
1621 |
self viewedColumnsChanged. |
|
4011 | 1622 |
self filterChanged. "/ filterChanged. |
3887 | 1623 |
^ super postBuildWith:aBuilder. |
1624 |
! |
|
1625 |
||
1626 |
postOpenAsSubcanvasWith:aBuilder |
|
1627 |
||
1628 |
self windowGroup addPreEventHook:self. |
|
1629 |
^ super postOpenAsSubcanvasWith:aBuilder. |
|
1630 |
! |
|
1631 |
||
1632 |
postOpenWith:aBuilder |
|
1633 |
||
1634 |
" |
|
1635 |
only invoked if the application not started from a master |
|
1636 |
" |
|
1637 |
self currentFileNameHolder changed. |
|
1638 |
self windowGroup addPreEventHook:self. |
|
1639 |
^ super postOpenWith:aBuilder. |
|
1640 |
! |
|
1641 |
||
1642 |
preBuildWith:aBuilder |
|
1643 |
||
1644 |
self masterApplication isNil ifTrue:[ |
|
1645 |
self masterApplication:nil. |
|
1646 |
]. |
|
1647 |
^ super preBuildWith:aBuilder. |
|
1648 |
! |
|
1649 |
||
1650 |
release |
|
1651 |
"release my resources |
|
1652 |
" |
|
1653 |
self updateColumnsTaskStop. |
|
1654 |
self updateDirectoryContentsTaskStop. |
|
1655 |
super release. |
|
1656 |
! |
|
1657 |
||
1658 |
releaseAsSubCanvas |
|
1659 |
||
1660 |
self updateColumnsTaskStop. |
|
1661 |
self updateDirectoryContentsTaskStop. |
|
1662 |
^ super releaseAsSubCanvas. |
|
1663 |
! ! |
|
1664 |
||
1665 |
!DirectoryContentsBrowser methodsFor:'task update columns'! |
|
1666 |
||
3983 | 1667 |
findNextBuildInDescFor:aConditionBlock |
1668 |
|vis idx stillSearching | |
|
1669 |
||
1670 |
vis := contentsBrowser indexOfFirstRowShown. |
|
3887 | 1671 |
vis = 0 ifTrue:[vis := 1]. |
3983 | 1672 |
|
1673 |
idx := vis. |
|
1674 |
stillSearching := true. |
|
1675 |
[ stillSearching ] whileTrue:[ |
|
1676 |
((idx <= browserItemList size) and:[ (contentsBrowser isRowVisible:idx) ]) ifFalse:[ |
|
1677 |
stillSearching := false. |
|
1678 |
idx := nil. |
|
1679 |
] ifTrue:[ |
|
1680 |
(aConditionBlock value:(browserItemList at:idx)) ifTrue:[ |
|
1681 |
"/ found a one |
|
1682 |
stillSearching := false. |
|
1683 |
] ifFalse:[ |
|
1684 |
idx := idx + 1. |
|
1685 |
] |
|
1686 |
]. |
|
3887 | 1687 |
]. |
3983 | 1688 |
idx isNil ifTrue:[^ nil]. |
1689 |
^ browserItemList at:idx ifAbsent:nil |
|
3887 | 1690 |
! |
1691 |
||
1692 |
findNextItemFor:aBlock |
|
1693 |
||
1694 |
^ allItemsList detect:aBlock ifNone:[nil]. |
|
1695 |
! |
|
1696 |
||
1697 |
getFileInfoFor:aItem |
|
1698 |
||
1699 |
| type| |
|
1700 |
||
1701 |
type := aItem fileName fileType. |
|
1702 |
aItem fileType:type. |
|
1703 |
^ type |
|
1704 |
! |
|
1705 |
||
1706 |
getIconFor:aItem |
|
1707 |
||
1708 |
| key icon| |
|
3906 | 1709 |
|
3887 | 1710 |
key := aItem iconKey. |
1711 |
icon := FileBrowser iconForKeyMatching:key. |
|
3906 | 1712 |
aItem isRemoteDirectory ifTrue:[ |
1713 |
^ icon "/ do not query attributes |
|
1714 |
]. |
|
3887 | 1715 |
^ FileBrowser addOnIconsFor:(aItem fileName) to:icon. |
1716 |
! |
|
1717 |
||
1718 |
getIconForMimeTypeByContents:aItem |
|
1719 |
||
1720 |
| currentIcon newIcon icon| |
|
1721 |
newIcon := FileBrowser iconForKeyMatching:(aItem mimeTypeForContents). |
|
1722 |
currentIcon := aItem icon. |
|
1723 |
(currentIcon class == MultiImage) ifTrue:[ |
|
1724 |
| images | |
|
1725 |
images := currentIcon images. |
|
1726 |
images removeFirst. |
|
1727 |
images addFirst:newIcon. |
|
1728 |
icon := currentIcon. |
|
1729 |
] ifFalse:[ |
|
1730 |
icon := newIcon. |
|
1731 |
]. |
|
1732 |
^ icon |
|
1733 |
! |
|
1734 |
||
1735 |
getPreviewFor:aItem |
|
1736 |
||
1737 |
| column icon| |
|
1738 |
||
3983 | 1739 |
column := contentsBrowser columnAt:previewIndex. |
3887 | 1740 |
column isNil ifTrue:[ |
1741 |
previewIndex := 0. |
|
1742 |
] ifFalse:[ |
|
1743 |
(aItem hasMimeType and:[aItem mimeType isImage]) ifTrue:[ |
|
1744 |
Exception handle:[:ex| |
|
1745 |
icon := nil. |
|
1746 |
] do:[ |scale extent w h | |
|
3983 | 1747 |
icon := Image fromFile:(aItem fileName pathName). |
3887 | 1748 |
icon notNil ifTrue:[ |
1749 |
extent := icon extent. |
|
1750 |
w := column width - 4. |
|
1751 |
h := column height. |
|
1752 |
||
1753 |
(extent x > w or:[extent y > h]) ifTrue:[ |
|
1754 |
scale := extent / (w@h). |
|
1755 |
scale := scale x max:(scale y). |
|
1756 |
icon := icon magnifiedTo:((extent / scale max:8.0) asInteger). |
|
1757 |
]. |
|
3983 | 1758 |
icon := icon onDevice:(contentsBrowser device). |
3887 | 1759 |
icon clearMaskedPixels. |
1760 |
] |
|
1761 |
] |
|
1762 |
] ifFalse:[ icon := nil]. |
|
1763 |
aItem preview:(icon ? ''). |
|
1764 |
]. |
|
1765 |
^ icon |
|
1766 |
! |
|
1767 |
||
1768 |
updateChangesFor:aItem |
|
1769 |
||
3983 | 1770 |
aItem resetItemForChanges. |
3887 | 1771 |
! |
1772 |
||
1773 |
updateColumnsTaskCycle |
|
1774 |
||
1775 |
" update items in the foolowing order |
|
1776 |
- update item if item properties are changed |
|
1777 |
- update icon for visible items by suffix |
|
1778 |
- update icon for visible items by contents |
|
1779 |
- update file info for visible items if file info column is shown |
|
1780 |
- update preview for visible items if preview column is shown |
|
1781 |
||
1782 |
- update icon for invisible items by suffix |
|
1783 |
- update icon for invisible items by contents |
|
1784 |
- update file info for invisible items if file info column is shown |
|
1785 |
- update preview for invisible items if preview column is shown |
|
1786 |
- update file info for invisible items if file info column is not shown |
|
1787 |
" |
|
1788 |
||
1789 |
|desc icon type preview| |
|
1790 |
||
1791 |
currentItemList notEmpty ifTrue:[ |
|
1792 |
"/ update item if item properties are changed |
|
3967 | 1793 |
desc := self findNextBuildInDescFor:[:n| n hasBeenModified ]. |
3887 | 1794 |
|
1795 |
desc notNil ifTrue:[ |
|
3983 | 1796 |
contentsBrowser invalidateVisibleRow:desc. |
3887 | 1797 |
self updateChangesFor:desc. |
1798 |
^ true. |
|
1799 |
]. |
|
1800 |
"/ update icon for visible items by suffix |
|
1801 |
desc := self findNextBuildInDescFor:[:n| n icon isNil ]. |
|
3967 | 1802 |
desc notNil ifTrue:[ |
3887 | 1803 |
icon := self getIconFor:desc. |
1804 |
desc icon:icon. |
|
1805 |
(icon notNil and:[iconIndex ~~ 0]) ifTrue:[ |
|
3983 | 1806 |
contentsBrowser invalidateVisibleRow:desc colAt:iconIndex |
3887 | 1807 |
]. |
1808 |
^ true |
|
1809 |
]. |
|
1810 |
"/ update icon for visible items by contents |
|
3967 | 1811 |
desc := self findNextBuildInDescFor:[:n| |
1812 |
(n iconKey == #file |
|
1813 |
and:[n mimeTypeForContents asSymbol ~= #unknown]) |
|
1814 |
]. |
|
1815 |
desc notNil ifTrue:[ |
|
1816 |
icon := self getIconForMimeTypeByContents:desc. |
|
1817 |
desc icon:icon. |
|
1818 |
(icon notNil and:[iconIndex ~~ 0]) ifTrue:[ |
|
3983 | 1819 |
contentsBrowser invalidateVisibleRow:desc colAt:iconIndex |
3967 | 1820 |
]. |
1821 |
^ true |
|
1822 |
]. |
|
3887 | 1823 |
"/ update file info for visible items if file info column is shown |
1824 |
fileDescriptionIndex ~~ 0 ifTrue:[ |
|
1825 |
desc := self findNextBuildInDescFor:[:n| n fileType isNil ]. |
|
1826 |
desc notNil ifTrue:[ |
|
1827 |
type := self getFileInfoFor:desc. |
|
3983 | 1828 |
type notNil ifTrue:[contentsBrowser invalidateVisibleRow:desc colAt:fileDescriptionIndex]. |
3887 | 1829 |
^ true |
1830 |
] |
|
1831 |
]. |
|
1832 |
"/ update preview for visible items if preview column is shown |
|
1833 |
previewIndex ~~ 0 ifTrue:[ |
|
1834 |
desc := self findNextBuildInDescFor:[:n| n preview isNil ]. |
|
1835 |
desc notNil ifTrue:[ |
|
1836 |
preview := self getPreviewFor:desc. |
|
1837 |
preview notNil ifTrue:[ |
|
3983 | 1838 |
contentsBrowser invalidateVisibleRow:desc colAt:previewIndex |
3887 | 1839 |
]. |
1840 |
^ true |
|
1841 |
] |
|
1842 |
]. |
|
1843 |
]. |
|
1844 |
||
1845 |
"/ may we want to see the other items later make this items to |
|
1846 |
allItemsList notEmpty ifTrue:[ |
|
1847 |
"/ update icon for invisible items by suffix |
|
1848 |
desc := self findNextItemFor:[:n| n icon isNil ]. |
|
1849 |
desc notNil ifTrue:[ |
|
1850 |
icon := self getIconFor:desc. |
|
1851 |
desc icon:icon. |
|
1852 |
^ true |
|
1853 |
]. |
|
1854 |
"/ update icon for invisible items by contents |
|
1855 |
desc := self findNextItemFor:[:n| (n iconKey == #file and:[n mimeTypeForContents ~= #unknown])]. |
|
1856 |
desc notNil ifTrue:[ |
|
1857 |
icon := self getIconForMimeTypeByContents:desc. |
|
1858 |
desc icon:icon. |
|
1859 |
^ true |
|
1860 |
]. |
|
1861 |
"/ update file info for invisible items if file info column is shown |
|
1862 |
fileDescriptionIndex ~~ 0 ifTrue:[ |
|
1863 |
desc := self findNextItemFor:[:n| n fileType isNil ]. |
|
1864 |
desc notNil ifTrue:[ |
|
1865 |
self getFileInfoFor:desc. |
|
1866 |
^ true |
|
1867 |
]. |
|
1868 |
]. |
|
1869 |
"/ update preview for invisible items if preview column is shown |
|
1870 |
previewIndex ~~ 0 ifTrue:[ |
|
1871 |
desc := self findNextItemFor:[:n| n preview isNil ]. |
|
1872 |
desc notNil ifTrue:[ |
|
1873 |
self getPreviewFor:desc. |
|
1874 |
^ true |
|
1875 |
]. |
|
1876 |
]. |
|
1877 |
"/ update file info for invisible items if file info column is not shown |
|
1878 |
desc := self findNextItemFor:[:n| n fileType isNil ]. |
|
1879 |
desc notNil ifTrue:[ |
|
1880 |
self getFileInfoFor:desc. |
|
1881 |
^ true |
|
1882 |
]. |
|
1883 |
]. |
|
1884 |
^ false |
|
1885 |
! |
|
1886 |
||
1887 |
updateColumnsTaskRestart |
|
1888 |
||
3990 | 1889 |
"/Processor activeProcess ~~ self windowGroup process ifTrue:[self halt]. |
3887 | 1890 |
self updateColumnsTaskStop. |
1891 |
self updateColumnsTaskStart. |
|
1892 |
! |
|
1893 |
||
1894 |
updateColumnsTaskStart |
|
1895 |
||
1896 |
| somethigToDo p | |
|
1897 |
||
1898 |
somethigToDo := true. |
|
1899 |
self directory notNil ifTrue:[ |
|
1900 |
p := [ |
|
1901 |
[ |
|
1902 |
[true] whileTrue:[ |
|
1903 |
somethigToDo := false. |
|
3983 | 1904 |
(contentsBrowser shown and:[self directory notNil]) ifTrue:[ |
3887 | 1905 |
somethigToDo := self updateColumnsTaskCycle. |
1906 |
Processor yield. |
|
1907 |
]. |
|
1908 |
somethigToDo ifFalse:[ |
|
1909 |
Delay waitForSeconds:1.0 |
|
1910 |
] |
|
1911 |
] |
|
1912 |
] valueNowOrOnUnwindDo:[ |
|
1913 |
self updateColumnsTask:nil. |
|
1914 |
] |
|
1915 |
] newProcess. |
|
3983 | 1916 |
"/ p priority:(Processor systemBackgroundPriority). |
1917 |
p priorityRange:(Processor userBackgroundPriority to:Processor activePriority). |
|
3887 | 1918 |
|
1919 |
self updateColumnsTask: p. |
|
1920 |
self updateColumnsTask name:('DirectoryContentsBrowser update columns[', self directory baseName, ']'). |
|
1921 |
self updateColumnsTask resume. |
|
1922 |
] |
|
1923 |
! |
|
1924 |
||
1925 |
updateColumnsTaskStop |
|
1926 |
|task| |
|
1927 |
||
1928 |
(task := self updateColumnsTask) notNil ifTrue:[ |
|
1929 |
self updateColumnsTask:nil. |
|
1930 |
||
1931 |
Object errorSignal handle:[:ex| |
|
1932 |
Dialog warn:ex description. |
|
1933 |
]do:[ |
|
1934 |
task isDead ifFalse:[ |
|
3919 | 1935 |
task terminateWithAllSubprocessesInGroup. |
3887 | 1936 |
task waitUntilTerminated. |
1937 |
] |
|
1938 |
] |
|
1939 |
]. |
|
1940 |
! ! |
|
1941 |
||
1942 |
!DirectoryContentsBrowser methodsFor:'task update dir contents'! |
|
1943 |
||
3983 | 1944 |
readDirectoryTaskStart |
1945 |
|p| |
|
1946 |
||
1947 |
p := [ |
|
1948 |
allItemsList := self readDirectoryItems. |
|
1949 |
self evaluateFilter. "/ filter makes a sort anyway |
|
1950 |
self updateDirectoryContentsTaskStart. |
|
1951 |
] newProcess. |
|
1952 |
||
1953 |
"/ p priorityRange:(Processor userBackgroundPriority to:Processor activePriority). |
|
1954 |
readDirectoryTask := p. |
|
1955 |
||
1956 |
p name:('DirectoryContentsBrowser readDir'). |
|
1957 |
p resume. |
|
1958 |
! |
|
1959 |
||
1960 |
readDirectoryTaskStop |
|
1961 |
|task| |
|
1962 |
||
1963 |
(task := readDirectoryTask) notNil ifTrue:[ |
|
1964 |
readDirectoryTask := nil. |
|
1965 |
||
1966 |
Object errorSignal handle:[:ex| |
|
1967 |
Dialog warn:ex description. |
|
1968 |
] do:[ |
|
1969 |
task isDead ifFalse:[ |
|
1970 |
task terminateWithAllSubprocessesInGroup. |
|
1971 |
task waitUntilTerminated. |
|
1972 |
] |
|
1973 |
] |
|
1974 |
]. |
|
1975 |
! |
|
1976 |
||
3887 | 1977 |
updateDirectoryContentsTaskCycle |
1978 |
||
1979 |
| contents| |
|
1980 |
||
1981 |
"/ DIRECTORY CONTNETS HAVE CHANGED |
|
1982 |
(modificationTime ~= self directory modificationTime) ifTrue:[ |
|
1983 |
modificationTime := self directory modificationTime. |
|
1984 |
contents := self directory directoryContentsAsFilenames. |
|
1985 |
contents size == 0 ifTrue:[ |
|
1986 |
allItemsList removeAll. |
|
1987 |
] ifFalse:[ |
|
1988 |
"/ MERGE WITH CURRENT CONTENTS |
|
1989 |
allItemsList reverseDo:[:aDesc| |
|
1990 |
"/ remove no longer valid files |
|
1991 |
(contents detect:[:f| aDesc fileName = f] ifNone:nil) isNil ifTrue:[ |
|
1992 |
allItemsList removeIdentical:aDesc |
|
1993 |
] |
|
1994 |
]. |
|
1995 |
allItemsList size ~~ contents size ifTrue:[ |
|
1996 |
"/ add new files |
|
1997 |
| addedFiles | |
|
1998 |
addedFiles := OrderedCollection new. |
|
1999 |
contents reverseDo:[:aFile| |
|
3983 | 2000 |
(allItemsList contains:[:item| item fileName = aFile]) ifTrue:[ |
2001 |
addedFiles add:(DirectoryContentsItem fileName:aFile) |
|
3887 | 2002 |
] |
2003 |
]. |
|
2004 |
allItemsList addAll:addedFiles. |
|
2005 |
] |
|
2006 |
]. |
|
2007 |
self evaluateFilter. |
|
2008 |
]. |
|
2009 |
! |
|
2010 |
||
2011 |
updateDirectoryContentsTaskRestart |
|
2012 |
||
2013 |
self updateDirectoryContentsTaskStop. |
|
2014 |
self updateDirectoryContentsTaskStart. |
|
2015 |
! |
|
2016 |
||
2017 |
updateDirectoryContentsTaskStart |
|
2018 |
|p| |
|
2019 |
||
2020 |
self directory notNil ifTrue:[ |
|
2021 |
p := [ |
|
2022 |
[ |
|
2023 |
[true] whileTrue:[ |
|
3983 | 2024 |
(contentsBrowser shown and:[self directory notNil]) ifTrue:[ |
3887 | 2025 |
self updateDirectoryContentsTaskCycle. |
2026 |
Processor yield. |
|
2027 |
]. |
|
2028 |
Delay waitForSeconds:1.0 |
|
2029 |
] |
|
2030 |
] valueNowOrOnUnwindDo:[ |
|
2031 |
self updateDirectoryContentsTask:nil. |
|
2032 |
self updateColumnsTaskStop. |
|
2033 |
] |
|
2034 |
] newProcess. |
|
2035 |
||
3983 | 2036 |
"/ p priority:(Processor systemBackgroundPriority). |
2037 |
p priorityRange:(Processor userBackgroundPriority to:Processor activePriority). |
|
3887 | 2038 |
self updateDirectoryContentsTask:p. |
2039 |
||
2040 |
p name:('DirectoryContentsBrowser update contents[', self directory baseName, ']'). |
|
2041 |
p resume. |
|
2042 |
] |
|
2043 |
! |
|
2044 |
||
2045 |
updateDirectoryContentsTaskStop |
|
2046 |
|task| |
|
2047 |
||
2048 |
(task := self updateDirectoryContentsTask) notNil ifTrue:[ |
|
2049 |
self updateDirectoryContentsTask:nil. |
|
2050 |
||
2051 |
Object errorSignal handle:[:ex| |
|
2052 |
Dialog warn:ex description. |
|
2053 |
]do:[ |
|
2054 |
task isDead ifFalse:[ |
|
3919 | 2055 |
task terminateWithAllSubprocessesInGroup. |
3887 | 2056 |
task waitUntilTerminated. |
2057 |
] |
|
2058 |
] |
|
2059 |
]. |
|
2060 |
! ! |
|
2061 |
||
2062 |
!DirectoryContentsBrowser::DirectoryContentsItem class methodsFor:'instance creation'! |
|
2063 |
||
3983 | 2064 |
fileName:aFilename |
2065 |
||
3999
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
2066 |
| instance fileItem| |
3983 | 2067 |
instance := self new. |
2068 |
aFilename asString = '..' ifTrue:[ |
|
2069 |
instance fileName:aFilename. |
|
2070 |
^ instance. |
|
2071 |
]. |
|
3999
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
2072 |
fileItem := DirectoryContents contentsItemForFileName:aFilename. |
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
2073 |
fileItem notNil ifTrue:[^ self forInfoItem:fileItem]. |
3983 | 2074 |
^ nil |
3999
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
2075 |
|
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
2076 |
" |
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
2077 |
DirectoryContentsItem fileName:'..' |
10b79980664c
get an item from dirContents
Claus Gittinger <cg@exept.de>
parents:
3996
diff
changeset
|
2078 |
" |
3983 | 2079 |
! |
2080 |
||
2081 |
forInfoItem:anItem |
|
3887 | 2082 |
| instance | |
2083 |
instance := self new. |
|
3983 | 2084 |
instance fileName:anItem fileName. |
2085 |
anItem isRemoteDirectory ifTrue:[ |
|
2086 |
instance beRemoteDirectory. |
|
2087 |
] ifFalse:[ |
|
2088 |
instance fileInfo:anItem info. |
|
2089 |
]. |
|
3906 | 2090 |
^ instance |
3887 | 2091 |
! ! |
2092 |
||
2093 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'accessing'! |
|
2094 |
||
3983 | 2095 |
fileInfo:something |
2096 |
"set the value of the instance variable 'fileInfo' (automatically generated)" |
|
2097 |
||
2098 |
fileInfo := something. |
|
2099 |
! |
|
2100 |
||
3887 | 2101 |
fileName |
2102 |
"returns the fileName |
|
2103 |
" |
|
2104 |
^ fileName |
|
2105 |
||
2106 |
||
2107 |
! |
|
2108 |
||
2109 |
fileName:aFilename |
|
2110 |
"set fileName for instance |
|
2111 |
" |
|
2112 |
fileName := aFilename. |
|
2113 |
! |
|
2114 |
||
2115 |
fileType |
|
2116 |
"returns the type of the file |
|
2117 |
" |
|
2118 |
||
2119 |
^ fileType |
|
2120 |
! |
|
2121 |
||
2122 |
fileType:aType |
|
2123 |
"returns the type of the file |
|
2124 |
" |
|
2125 |
||
2126 |
fileType := aType. |
|
2127 |
! |
|
2128 |
||
2129 |
icon |
|
2130 |
"returns the icon assigned to the file |
|
2131 |
" |
|
2132 |
^ icon |
|
2133 |
||
2134 |
||
2135 |
! |
|
2136 |
||
2137 |
icon:anIcon |
|
2138 |
||
2139 |
icon := anIcon. |
|
2140 |
! |
|
2141 |
||
2142 |
iconKey |
|
2143 |
"return the value of the instance variable 'iconKey' (automatically generated)" |
|
2144 |
||
2145 |
iconKey isNil ifTrue:[ |
|
3906 | 2146 |
self isRemoteDirectory ifTrue:[ |
2147 |
iconKey := FileBrowser iconKeyForRemoteDirectory:fileName. |
|
2148 |
] ifFalse:[ |
|
2149 |
iconKey := FileBrowser iconKeyForFile:fileName. |
|
2150 |
] |
|
3887 | 2151 |
]. |
2152 |
^ iconKey |
|
2153 |
! |
|
2154 |
||
2155 |
isDirectory |
|
3967 | 2156 |
self isRemoteDirectory ifTrue:[^ true]. |
2157 |
||
2158 |
self getFileInfo. |
|
2159 |
fileInfo isNil ifTrue:[^ false]. |
|
2160 |
^ fileInfo isDirectory |
|
2161 |
! |
|
3887 | 2162 |
|
3967 | 2163 |
isSymbolicLink |
2164 |
self isRemoteDirectory ifTrue:[^ false]. |
|
2165 |
||
2166 |
self getFileInfo. |
|
2167 |
fileInfo isNil ifTrue:[^ false]. |
|
2168 |
^ fileInfo isSymbolicLink |
|
3887 | 2169 |
! |
2170 |
||
2171 |
lastButOneSuffix |
|
2172 |
"returns the suffix of the file |
|
2173 |
" |
|
2174 |
||
2175 |
^ self suffixes at:2 |
|
2176 |
! |
|
2177 |
||
2178 |
lastSuffix |
|
2179 |
"returns the suffix of the file |
|
2180 |
" |
|
2181 |
||
2182 |
^ self suffixes at:1 |
|
2183 |
! |
|
2184 |
||
2185 |
mimeType |
|
2186 |
"return the value of the instance variable 'mimeType' (automatically generated)" |
|
2187 |
||
2188 |
mimeType isNil ifTrue:[ |
|
2189 |
mimeType := MIMETypes mimeTypeForFilename:(self fileName). |
|
2190 |
mimeType isNil ifTrue:[ |
|
2191 |
mimeType := #unknown |
|
2192 |
] |
|
2193 |
]. |
|
2194 |
^ mimeType |
|
2195 |
! |
|
2196 |
||
2197 |
preview |
|
2198 |
||
2199 |
^ preview |
|
2200 |
! |
|
2201 |
||
2202 |
preview:aLabel |
|
2203 |
||
2204 |
preview := aLabel. |
|
2205 |
! |
|
2206 |
||
2207 |
suffix |
|
2208 |
"returns the suffix of the file |
|
2209 |
" |
|
2210 |
suffix isNil ifTrue:[ |
|
2211 |
(OperatingSystem isUNIXlike and:[(self baseName at:1) == $.]) ifTrue:[ |
|
2212 |
suffix := ''. |
|
2213 |
] ifFalse:[ |
|
2214 |
suffix := fileName suffix. |
|
2215 |
] |
|
2216 |
]. |
|
2217 |
^ suffix |
|
2218 |
! |
|
2219 |
||
2220 |
suffixes |
|
2221 |
||
2222 |
| lastSuff lastButOneSuff| |
|
2223 |
||
3967 | 2224 |
(fileName name occurrencesOf:$.) <= 1 ifTrue:[ |
2225 |
^ Array with:(self suffix) with:nil. |
|
2226 |
]. |
|
2227 |
(fileName baseName occurrencesOf:$.) <= 1 ifTrue:[ |
|
2228 |
^ Array with:(self suffix) with:nil. |
|
2229 |
]. |
|
3887 | 2230 |
|
3967 | 2231 |
((lastSuff := self suffix) isEmpty) ifTrue:[ |
2232 |
lastSuff := nil. |
|
2233 |
] ifFalse:[ |
|
2234 |
lastSuff := lastSuff asLowercase. |
|
2235 |
]. |
|
2236 |
||
2237 |
((lastButOneSuff := fileName withoutSuffix suffix) isEmpty) ifTrue:[ |
|
2238 |
lastButOneSuff := nil. |
|
2239 |
] ifFalse:[ |
|
2240 |
lastButOneSuff := lastButOneSuff asLowercase. |
|
2241 |
]. |
|
2242 |
||
2243 |
(lastSuff notNil and:[lastButOneSuff notNil]) ifTrue:[ |
|
2244 |
(lastSuff = 'bak' or:[lastSuff = 'sav']) ifTrue:[ |
|
2245 |
lastSuff := lastButOneSuff. |
|
3887 | 2246 |
lastButOneSuff := nil. |
3967 | 2247 |
] |
3887 | 2248 |
]. |
3967 | 2249 |
^ Array with:lastSuff with:lastButOneSuff |
3887 | 2250 |
! |
2251 |
||
2252 |
type |
|
2253 |
"returns the type of the file |
|
2254 |
" |
|
2255 |
^ self valueAt:#type |
|
2256 |
||
2257 |
! ! |
|
2258 |
||
2259 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'actions'! |
|
2260 |
||
2261 |
resetImageFile |
|
2262 |
||
2263 |
" if the image preview extent is changed the icon will set to nil to force the update task to reload the image " |
|
2264 |
||
2265 |
(mimeType notNil and:[ mimeType isImage]) ifTrue:[ |
|
2266 |
preview := nil |
|
2267 |
] |
|
2268 |
! |
|
2269 |
||
3983 | 2270 |
resetItemForChanges |
3887 | 2271 |
|
2272 |
" dont know what someone else is doing with the file - read all item properties new " |
|
2273 |
fileInfo := nil. |
|
2274 |
icon := nil. |
|
2275 |
fileType := nil. |
|
2276 |
preview := nil. |
|
2277 |
owner := nil. |
|
2278 |
group := nil. |
|
2279 |
! ! |
|
2280 |
||
2281 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'change queries'! |
|
2282 |
||
3967 | 2283 |
hasBeenModified |
3887 | 2284 |
|
2285 |
"check if item modification time is changed |
|
2286 |
" |
|
2287 |
| time info| |
|
2288 |
||
3906 | 2289 |
self isRemoteDirectory ifTrue:[^ false]. |
2290 |
||
3967 | 2291 |
info := fileName info. |
3887 | 2292 |
info isNil ifTrue:[ ^ false]. |
3962
3906b10c42fd
modified -> modificationTime
Claus Gittinger <cg@exept.de>
parents:
3961
diff
changeset
|
2293 |
time := info modificationTime. |
3967 | 2294 |
|
3887 | 2295 |
contentsBrowserChangeModificationTime isNil ifTrue:[ |
2296 |
contentsBrowserChangeModificationTime := time. |
|
3967 | 2297 |
fileInfo := nil. |
3887 | 2298 |
^ false. |
2299 |
]. |
|
2300 |
((contentsBrowserChangeModificationTime = time) not) ifTrue:[ |
|
2301 |
contentsBrowserChangeModificationTime := time. |
|
3967 | 2302 |
fileInfo := nil. |
3887 | 2303 |
^ true |
2304 |
]. |
|
2305 |
^ false |
|
2306 |
! ! |
|
2307 |
||
2308 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'compare'! |
|
2309 |
||
2310 |
= aItem |
|
2311 |
||
2312 |
"/ Transcript showCR:(aItem species == self species). |
|
2313 |
aItem species == self species ifFalse:[ ^ false]. |
|
2314 |
aItem isNil ifTrue:[ ^ false]. |
|
2315 |
^ (self fileName = aItem fileName) |
|
2316 |
! |
|
2317 |
||
2318 |
hash |
|
2319 |
^ fileName hash |
|
2320 |
! ! |
|
2321 |
||
2322 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'presentation'! |
|
2323 |
||
2324 |
baseName |
|
2325 |
"returns the baseName of the file |
|
2326 |
" |
|
3967 | 2327 |
^ fileName baseName. |
3887 | 2328 |
! |
2329 |
||
2330 |
baseName:aName |
|
2331 |
"rename the file |
|
2332 |
" |
|
2333 |
^ self |
|
2334 |
! |
|
2335 |
||
2336 |
baseNameWithOutSuffix |
|
2337 |
"returns the baseName of the file |
|
2338 |
" |
|
2339 |
| baseNameWithOutSuff | |
|
2340 |
||
2341 |
baseNameWithOutSuff := self baseName asFilename withoutSuffix asString. |
|
2342 |
baseNameWithOutSuff isEmpty ifTrue:[ |
|
2343 |
^ self baseName |
|
2344 |
]. |
|
2345 |
^ baseNameWithOutSuff. |
|
2346 |
! |
|
2347 |
||
2348 |
date |
|
3967 | 2349 |
"returns the modTimeString |
3887 | 2350 |
" |
2351 |
| modTime | |
|
2352 |
||
3967 | 2353 |
modTime := self modificationTime. |
2354 |
modTime isNil ifTrue:[ |
|
2355 |
^ '???' |
|
3887 | 2356 |
]. |
3967 | 2357 |
^ modTime asDate printString. |
3887 | 2358 |
! |
2359 |
||
2360 |
fileInfoString |
|
2361 |
"get stat info on selected file - return a string which can be |
|
2362 |
shown in a box" |
|
2363 |
||
2364 |
| afileType | |
|
2365 |
||
2366 |
fileName isNil ifTrue:[^ nil]. |
|
2367 |
afileType := self fileType. |
|
2368 |
afileType isNil ifTrue:[ |
|
2369 |
^ ''. |
|
2370 |
]. |
|
2371 |
^ afileType |
|
2372 |
! |
|
2373 |
||
3967 | 2374 |
fileSize |
2375 |
"returns the fileSize |
|
2376 |
" |
|
2377 |
self getFileInfo. |
|
2378 |
fileInfo isNil ifTrue:[^ nil]. |
|
2379 |
||
2380 |
^ fileInfo fileSize |
|
2381 |
! |
|
2382 |
||
3887 | 2383 |
group |
2384 |
"returns the printable group |
|
2385 |
" |
|
2386 |
|gid| |
|
2387 |
||
2388 |
group isNil ifTrue:[ |
|
3967 | 2389 |
self getFileInfo. |
2390 |
fileInfo isNil ifTrue:[^ '???']. |
|
2391 |
||
2392 |
gid := fileInfo gid. |
|
2393 |
(LastGIDToGroupNameMapping notNil and:[gid == LastGIDToGroupNameMapping key]) ifTrue:[ |
|
2394 |
group := LastGIDToGroupNameMapping value |
|
2395 |
] ifFalse:[ |
|
2396 |
group := OperatingSystem getGroupNameFromID:gid. |
|
2397 |
LastGIDToGroupNameMapping := gid -> group. |
|
2398 |
] |
|
3887 | 2399 |
]. |
2400 |
^ group |
|
2401 |
! |
|
2402 |
||
2403 |
modificationTime |
|
2404 |
"returns the absolute time of modification |
|
2405 |
" |
|
3967 | 2406 |
self getFileInfo. |
2407 |
fileInfo isNil ifTrue:[^ nil]. |
|
2408 |
||
2409 |
^ fileInfo modificationTime |
|
3887 | 2410 |
! |
2411 |
||
2412 |
owner |
|
2413 |
"returns the printable owner |
|
2414 |
" |
|
2415 |
|uid| |
|
2416 |
||
2417 |
owner isNil ifTrue:[ |
|
3967 | 2418 |
self getFileInfo. |
2419 |
fileInfo isNil ifTrue:[^ '???']. |
|
2420 |
||
2421 |
uid := fileInfo uid. |
|
2422 |
(LastUIDToUserNameMapping notNil and:[uid == LastUIDToUserNameMapping key]) ifTrue:[ |
|
2423 |
owner := LastUIDToUserNameMapping value |
|
2424 |
] ifFalse:[ |
|
2425 |
owner := OperatingSystem getUserNameFromID:uid. |
|
2426 |
LastUIDToUserNameMapping := uid -> owner. |
|
2427 |
] |
|
3887 | 2428 |
]. |
2429 |
^ owner |
|
2430 |
! |
|
2431 |
||
2432 |
permissions |
|
2433 |
"returns the permissions as printable string |
|
2434 |
" |
|
3967 | 2435 |
|mode permissionString| |
3887 | 2436 |
|
3967 | 2437 |
self getFileInfo. |
2438 |
fileInfo isNil ifTrue:[^ '???'.]. |
|
3887 | 2439 |
|
3967 | 2440 |
mode := fileInfo mode. |
2441 |
permissionString := String new:9 withAll:$-. |
|
2442 |
||
2443 |
1 to:9 by:3 do:[:i| |
|
2444 |
(mode bitAt:i ) == 1 ifTrue:[permissionString at:10 - i put:$x]. |
|
2445 |
(mode bitAt:i + 1) == 1 ifTrue:[permissionString at:9 - i put:$w]. |
|
2446 |
(mode bitAt:i + 2) == 1 ifTrue:[permissionString at:8 - i put:$r]. |
|
3887 | 2447 |
]. |
3967 | 2448 |
^ permissionString |
3887 | 2449 |
! |
2450 |
||
2451 |
printString |
|
3983 | 2452 |
|
2453 |
^ 'a DirectoryContentsItem [', fileName asString, ']' |
|
3887 | 2454 |
! |
2455 |
||
2456 |
sizeString |
|
2457 |
"returns the size of the file |
|
2458 |
" |
|
2459 |
| unitString n locSize| |
|
2460 |
||
3967 | 2461 |
unitString := ''. |
2462 |
locSize := self fileSize. |
|
2463 |
locSize isNil ifTrue:[^ '???']. |
|
2464 |
||
2465 |
locSize < (500 * 1024) ifTrue:[ |
|
2466 |
locSize < 1024 ifTrue:[ |
|
2467 |
n := locSize |
|
3887 | 2468 |
] ifFalse:[ |
3967 | 2469 |
n := (locSize * 10 // 1024 / 10.0). |
2470 |
unitString := ' Kb' |
|
2471 |
] |
|
2472 |
] ifFalse:[ |
|
2473 |
n := (locSize * 10 // 1024 // 1024 / 10.0). |
|
2474 |
unitString := ' Mb' |
|
3887 | 2475 |
]. |
3967 | 2476 |
^ (n printStringLeftPaddedTo:5) , unitString. |
3887 | 2477 |
! |
2478 |
||
2479 |
timeAndDate |
|
2480 |
"returns the date |
|
2481 |
" |
|
3967 | 2482 |
|modTime| |
3887 | 2483 |
|
3967 | 2484 |
modTime := self modificationTime. |
2485 |
modTime isNil ifTrue:[ |
|
2486 |
^ '???' |
|
3887 | 2487 |
]. |
3967 | 2488 |
Smalltalk languageTerritory == #us ifTrue:[ |
2489 |
^ modTime printStringFormat:'%(ShortMonthName), %(dayPadded) %(yearOrTime)'. |
|
2490 |
]. |
|
2491 |
^ modTime printStringFormat:'%(day)-%(ShortMonthName) %(yearOrTime)'. |
|
2492 |
||
2493 |
"/ ^ modTime printStringFormat:'%(year)-%(mon)-%(day) %h:%m:%s'. |
|
3887 | 2494 |
! ! |
2495 |
||
2496 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'private'! |
|
2497 |
||
3967 | 2498 |
getFileInfo |
3887 | 2499 |
fileInfo isNil ifTrue:[ |
3906 | 2500 |
self isRemoteDirectory ifTrue:[ |
2501 |
"/ do not access, to avoid automount |
|
3887 | 2502 |
] ifFalse:[ |
3967 | 2503 |
fileInfo := fileName linkInfo. |
2504 |
fileInfo isNil ifTrue:[ |
|
2505 |
fileInfo := fileName info. |
|
3906 | 2506 |
]. |
3967 | 2507 |
]. |
2508 |
]. |
|
2509 |
^ fileInfo |
|
3887 | 2510 |
! ! |
2511 |
||
2512 |
!DirectoryContentsBrowser::DirectoryContentsItem methodsFor:'queries'! |
|
2513 |
||
3906 | 2514 |
beRemoteDirectory |
2515 |
fileType := #remoteDirectory. |
|
2516 |
! |
|
2517 |
||
3887 | 2518 |
exists |
2519 |
"returns the fileName |
|
2520 |
" |
|
2521 |
^ fileName exists |
|
2522 |
! |
|
2523 |
||
2524 |
hasMimeType |
|
2525 |
||
2526 |
^ (self mimeType ~= #unknown) |
|
2527 |
! |
|
2528 |
||
3906 | 2529 |
isRemoteDirectory |
2530 |
^ fileType == #remoteDirectory |
|
2531 |
! |
|
2532 |
||
3887 | 2533 |
mimeTypeForContents |
2534 |
||
2535 |
mimeTypeForContents isNil ifTrue:[ |
|
2536 |
mimeTypeForContents := MIMETypes mimeTypeOfContents:(self fileName). |
|
2537 |
mimeTypeForContents isNil ifTrue:[ |
|
2538 |
mimeTypeForContents := #unknown |
|
2539 |
] ifFalse:[ |
|
2540 |
" set mimeType to mimeType of contents if a better mimeType is found " |
|
2541 |
mimeType := mimeTypeForContents. |
|
2542 |
iconKey := mimeTypeForContents. |
|
2543 |
] |
|
2544 |
]. |
|
2545 |
^ mimeTypeForContents |
|
2546 |
! ! |
|
2547 |
||
2548 |
!DirectoryContentsBrowser class methodsFor:'documentation'! |
|
2549 |
||
2550 |
version |
|
4011 | 2551 |
^ '$Header: /cvs/stx/stx/libtool/DirectoryContentsBrowser.st,v 1.26 2002-10-16 15:07:06 penk Exp $' |
3887 | 2552 |
! ! |