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