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