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