author | tz |
Sat, 07 Feb 1998 16:56:57 +0100 | |
changeset 618 | 2c9efaae88a6 |
parent 614 | 41cd940faa45 |
child 620 | 03e969ddd336 |
permissions | -rw-r--r-- |
424 | 1 |
" |
502 | 2 |
COPYRIGHT (c) 1997 by eXept Software AG |
424 | 3 |
All Rights Reserved |
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
14 |
ApplicationModel subclass:#DirectoryView |
|
15 |
instanceVariableNames:'directory selectedFileFilter readTask monitoring |
|
16 |
monitoringTimeBlock fileDoubleClickAction fileSelectAction |
|
17 |
fileFilterSelectAction fileAttributes' |
|
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-Advanced-Tools' |
|
21 |
! |
|
22 |
||
23 |
Object subclass:#FileRow |
|
24 |
instanceVariableNames:'fileName size modified iconKey group owner permissions baseName' |
|
25 |
classVariableNames:'' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:DirectoryView |
|
28 |
! |
|
29 |
||
30 |
!DirectoryView class methodsFor:'documentation'! |
|
31 |
||
32 |
copyright |
|
33 |
" |
|
502 | 34 |
COPYRIGHT (c) 1997 by eXept Software AG |
424 | 35 |
All Rights Reserved |
36 |
||
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
44 |
||
45 |
! |
|
46 |
||
47 |
documentation |
|
48 |
" |
|
49 |
documentation to be added. |
|
502 | 50 |
|
51 |
[author:] |
|
52 |
Thomas Zwick |
|
424 | 53 |
" |
54 |
! ! |
|
55 |
||
56 |
!DirectoryView class methodsFor:'instance creation'! |
|
57 |
||
516
d336effde882
Fix #openOnDirectory: and copyright.
Stefan Vogel <sv@exept.de>
parents:
502
diff
changeset
|
58 |
openOnDirectory: aDirectoryString |
d336effde882
Fix #openOnDirectory: and copyright.
Stefan Vogel <sv@exept.de>
parents:
502
diff
changeset
|
59 |
"open a DirectoryView for a aDirectoryString" |
d336effde882
Fix #openOnDirectory: and copyright.
Stefan Vogel <sv@exept.de>
parents:
502
diff
changeset
|
60 |
|
d336effde882
Fix #openOnDirectory: and copyright.
Stefan Vogel <sv@exept.de>
parents:
502
diff
changeset
|
61 |
^ (self new directory: aDirectoryString) open |
424 | 62 |
|
516
d336effde882
Fix #openOnDirectory: and copyright.
Stefan Vogel <sv@exept.de>
parents:
502
diff
changeset
|
63 |
" |
d336effde882
Fix #openOnDirectory: and copyright.
Stefan Vogel <sv@exept.de>
parents:
502
diff
changeset
|
64 |
self openOnDirectory: '/etc' |
d336effde882
Fix #openOnDirectory: and copyright.
Stefan Vogel <sv@exept.de>
parents:
502
diff
changeset
|
65 |
" |
424 | 66 |
|
516
d336effde882
Fix #openOnDirectory: and copyright.
Stefan Vogel <sv@exept.de>
parents:
502
diff
changeset
|
67 |
"Modified: / 28.1.1998 / 15:44:53 / stefan" |
424 | 68 |
! ! |
69 |
||
70 |
!DirectoryView class methodsFor:'interface specs'! |
|
71 |
||
72 |
windowSpec |
|
73 |
"this window spec was automatically generated by the ST/X UIPainter" |
|
74 |
||
75 |
"do not manually edit this - the painter/builder may not be able to |
|
76 |
handle the specification if its corrupted." |
|
77 |
||
78 |
" |
|
79 |
UIPainter new openOnClass:DirectoryView andSelector:#windowSpec |
|
80 |
DirectoryView new openInterface:#windowSpec |
|
81 |
" |
|
82 |
"DirectoryView open" |
|
83 |
||
84 |
<resource: #canvas> |
|
85 |
||
86 |
^ |
|
87 |
||
88 |
#(#FullSpec |
|
89 |
#'window:' |
|
90 |
#(#WindowSpec |
|
91 |
#'name:' 'Directory View' |
|
607 | 92 |
#'layout:' #(#LayoutFrame 64 0 703 0 463 0 1002 0) |
424 | 93 |
#'label:' 'Directory View' |
94 |
#'min:' #(#Point 10 10) |
|
95 |
#'max:' #(#Point 1152 900) |
|
607 | 96 |
#'bounds:' #(#Rectangle 64 703 464 1003) |
424 | 97 |
#'usePreferredExtent:' false |
98 |
) |
|
99 |
#'component:' |
|
100 |
#(#SpecCollection |
|
101 |
#'collection:' |
|
102 |
#( |
|
103 |
#(#DataSetSpec |
|
104 |
#'name:' 'filesDataSetView' |
|
607 | 105 |
#'layout:' #(#LayoutFrame 0 0.0 24 0.0 -2 1.0 0 1.0) |
424 | 106 |
#'model:' #selectionOfFile |
107 |
#'hasHorizontalScrollBar:' true |
|
108 |
#'hasVerticalScrollBar:' true |
|
109 |
#'miniScrollerHorizontal:' true |
|
110 |
#'dataList:' #listOfFiles |
|
111 |
#'useIndex:' false |
|
112 |
#'doubleClickSelector:' #fileDoubleClicked |
|
113 |
#'columnHolder:' #fileAttributeColumns |
|
114 |
#'valueChangeSelector:' #fileSelected |
|
115 |
#'verticalSpacing:' 1 |
|
116 |
) |
|
117 |
#(#ComboBoxSpec |
|
118 |
#'name:' 'formatComboBox' |
|
119 |
#'layout:' #(#LayoutFrame 0 0.0 0 0 0 1.0 22 0) |
|
120 |
#'model:' #selectionOfFileFilter |
|
121 |
#'immediateAccept:' false |
|
122 |
#'acceptOnTab:' false |
|
123 |
#'comboList:' #listOfFileFilters |
|
124 |
) |
|
125 |
) |
|
126 |
) |
|
127 |
) |
|
607 | 128 |
|
129 |
"Modified: / 6.2.1998 / 03:42:15 / cg" |
|
424 | 130 |
! |
131 |
||
132 |
windowSpecOfFileAttributeColumns |
|
133 |
||
134 |
^ |
|
135 |
#( |
|
136 |
#(#DataSetColumnSpec |
|
137 |
#'label:' '' |
|
138 |
#'width:' 30 |
|
139 |
#'height:' 22 |
|
140 |
#'printSelector:' #'iconOn:' |
|
141 |
#'canSelect:' false |
|
142 |
) |
|
143 |
#(#DataSetColumnSpec |
|
144 |
#'label:' 'File name' |
|
590 | 145 |
#'labelAlignment:' #left |
607 | 146 |
#'minWidth:' 150 |
424 | 147 |
#'model:' #baseName |
148 |
#'canSelect:' false |
|
149 |
) |
|
150 |
#(#DataSetColumnSpec |
|
151 |
#'label:' 'Size' |
|
590 | 152 |
#'labelAlignment:' #left |
607 | 153 |
#'width:' 70 |
424 | 154 |
#'model:' #size |
155 |
#'canSelect:' false |
|
156 |
) |
|
157 |
#(#DataSetColumnSpec |
|
593 | 158 |
#'label:' 'Modified' |
590 | 159 |
#'labelAlignment:' #left |
424 | 160 |
#'model:' #modified |
161 |
#'canSelect:' false |
|
162 |
) |
|
163 |
#(#DataSetColumnSpec |
|
164 |
#'label:' 'Permissions' |
|
590 | 165 |
#'labelAlignment:' #left |
424 | 166 |
#'width:' 85 |
167 |
#'model:' #permissions |
|
168 |
#'canSelect:' false |
|
169 |
) |
|
170 |
#(#DataSetColumnSpec |
|
171 |
#'label:' 'Owner' |
|
590 | 172 |
#'labelAlignment:' #left |
424 | 173 |
#'width:' 50 |
174 |
#'model:' #owner |
|
175 |
#'canSelect:' false |
|
176 |
) |
|
177 |
#(#DataSetColumnSpec |
|
178 |
#'label:' 'Group' |
|
590 | 179 |
#'labelAlignment:' #left |
424 | 180 |
#'width:' 50 |
181 |
#'model:' #group |
|
182 |
#'canSelect:' false |
|
183 |
) |
|
184 |
) |
|
185 |
||
607 | 186 |
"Modified: / 6.2.1998 / 03:40:16 / cg" |
424 | 187 |
! ! |
188 |
||
189 |
!DirectoryView methodsFor:'accessing'! |
|
190 |
||
191 |
directory: aDirectory |
|
192 |
||
193 |
directory := aDirectory asFilename asAbsoluteFilename name |
|
194 |
! |
|
195 |
||
196 |
fileAttributes: anArray |
|
197 |
||
198 |
fileAttributes := anArray |
|
199 |
! |
|
200 |
||
201 |
fileDoubleClickAction: anActionBlock |
|
202 |
||
203 |
fileDoubleClickAction := anActionBlock |
|
204 |
! |
|
205 |
||
206 |
fileFilterSelectAction: anActionBlock |
|
207 |
||
208 |
fileFilterSelectAction := anActionBlock |
|
209 |
! |
|
210 |
||
211 |
fileSelectAction: anActionBlock |
|
212 |
||
213 |
fileSelectAction := anActionBlock |
|
214 |
! |
|
215 |
||
216 |
listOfFileFilters: aCollection |
|
217 |
||
218 |
self listOfFileFilters contents: aCollection. |
|
219 |
self selectionOfFileFilter value: (self listOfFileFilters at: 1 ifAbsent: [nil]). |
|
220 |
! |
|
221 |
||
222 |
monitoring: aBoolean |
|
223 |
||
224 |
aBoolean |
|
225 |
ifTrue: |
|
226 |
[ |
|
227 |
monitoringTimeBlock := [self readDirectory]. |
|
228 |
self readDirectory. |
|
229 |
] |
|
230 |
ifFalse: |
|
231 |
[ |
|
232 |
monitoring ifTrue: |
|
233 |
[ |
|
234 |
Processor removeTimedBlock:monitoringTimeBlock. |
|
235 |
monitoringTimeBlock := nil |
|
236 |
] |
|
237 |
]. |
|
238 |
||
239 |
monitoring := aBoolean. |
|
240 |
||
241 |
! ! |
|
242 |
||
243 |
!DirectoryView methodsFor:'aspects'! |
|
244 |
||
245 |
fileAttributeColumns |
|
246 |
||
247 |
|holder| |
|
248 |
(holder := builder bindingAt:#fileAttributeColumns) isNil ifTrue:[ |
|
249 |
|fileAttributeColumns| |
|
250 |
builder aspectAt:#fileAttributeColumns put:(holder := List new). |
|
251 |
fileAttributeColumns := self class windowSpecOfFileAttributeColumns collect: [:i| i decodeAsLiteralArray]. |
|
252 |
holder add: fileAttributeColumns first. |
|
253 |
fileAttributeColumns do: |
|
254 |
[:col| |
|
255 |
(fileAttributes includes: col label) ifTrue: [holder add: col] |
|
256 |
]. |
|
591 | 257 |
holder do: [:col| col label: ' ', col label] |
424 | 258 |
]. |
259 |
^ holder |
|
260 |
! |
|
261 |
||
262 |
listOfFileFilters |
|
263 |
||
264 |
|holder| |
|
265 |
(holder := builder bindingAt:#listOfFileFilters) isNil ifTrue:[ |
|
266 |
builder aspectAt:#listOfFileFilters put:(holder := List with: '*'). |
|
267 |
]. |
|
268 |
^ holder |
|
269 |
! |
|
270 |
||
271 |
listOfFiles |
|
272 |
||
273 |
|holder| |
|
274 |
(holder := builder bindingAt:#listOfFiles) isNil ifTrue:[ |
|
275 |
builder aspectAt:#listOfFiles put:(holder := List new). |
|
276 |
]. |
|
277 |
^ holder |
|
278 |
! |
|
279 |
||
280 |
selectionOfFile |
|
281 |
||
282 |
|holder| |
|
283 |
(holder := builder bindingAt:#selectionOfFile) isNil ifTrue:[ |
|
284 |
builder aspectAt:#selectionOfFile put:(holder := ValueHolder new). |
|
285 |
]. |
|
286 |
^ holder |
|
287 |
||
288 |
! |
|
289 |
||
290 |
selectionOfFileFilter |
|
291 |
||
292 |
|holder| |
|
293 |
(holder := builder bindingAt:#selectionOfFileFilter) isNil ifTrue:[ |
|
294 |
builder aspectAt:#selectionOfFileFilter put: |
|
295 |
(holder := AspectAdaptor new subject:self; forAspect:#selectedFileFilter). |
|
296 |
selectedFileFilter := '*'. |
|
297 |
]. |
|
298 |
^ holder |
|
299 |
! ! |
|
300 |
||
301 |
!DirectoryView methodsFor:'callbacks'! |
|
302 |
||
303 |
fileDoubleClicked |
|
304 |
||
473 | 305 |
(fileDoubleClickAction notNil and: [self selectionOfFile value notNil]) |
424 | 306 |
ifTrue: |
307 |
[ |
|
308 |
fileDoubleClickAction numArgs = 0 |
|
309 |
ifTrue: |
|
310 |
[ |
|
311 |
fileDoubleClickAction value |
|
312 |
]. |
|
313 |
fileDoubleClickAction numArgs = 1 |
|
314 |
ifTrue: |
|
451 | 315 |
[ |
316 |
fileDoubleClickAction value: (directory asFilename construct: self selectionOfFile value baseName) name |
|
424 | 317 |
] |
318 |
] |
|
319 |
! |
|
320 |
||
321 |
fileSelected |
|
322 |
||
473 | 323 |
(fileSelectAction notNil and: [self selectionOfFile value notNil]) |
424 | 324 |
ifTrue: |
325 |
[ |
|
326 |
fileSelectAction numArgs = 0 |
|
327 |
ifTrue: |
|
328 |
[ |
|
329 |
fileSelectAction value |
|
330 |
]. |
|
331 |
fileSelectAction numArgs = 1 |
|
332 |
ifTrue: |
|
333 |
[ |
|
451 | 334 |
fileSelectAction value: (directory asFilename construct: self selectionOfFile value baseName) name |
424 | 335 |
] |
336 |
] |
|
337 |
! ! |
|
338 |
||
339 |
!DirectoryView methodsFor:'initialization'! |
|
340 |
||
341 |
initialize |
|
342 |
||
343 |
super initialize. |
|
344 |
||
345 |
directory := directory ? '.' asFilename asAbsoluteFilename directoryName. |
|
346 |
monitoring := false. |
|
593 | 347 |
fileAttributes := #('File name' 'Size' 'Modified'). |
424 | 348 |
self selectionOfFileFilter value: (self listOfFileFilters at: 1 ifAbsent: [nil]). |
349 |
||
350 |
! ! |
|
351 |
||
352 |
!DirectoryView methodsFor:'private'! |
|
353 |
||
354 |
readDirectory |
|
355 |
||
614 | 356 |
|foundFiles list| |
590 | 357 |
foundFiles := OrderedCollection new. |
614 | 358 |
list := self listOfFileFilters value. |
359 |
||
590 | 360 |
Cursor wait showWhile: |
361 |
[ |
|
614 | 362 |
(DirectoryContents directoryNamed: directory) filesAndBasenamesDo: |
363 |
[:file :name| |
|
364 |
list do: |
|
590 | 365 |
[:filter| |
614 | 366 |
(filter match: name) |
590 | 367 |
ifTrue: |
368 |
[ |
|
369 |
foundFiles add: (FileRow new fileName: file) |
|
370 |
]. |
|
371 |
]. |
|
372 |
]. |
|
373 |
self listOfFiles contents: foundFiles |
|
374 |
] |
|
614 | 375 |
|
590 | 376 |
! |
377 |
||
378 |
readMonitoringDirectory |
|
379 |
||
424 | 380 |
|readBlock| |
381 |
readTask notNil ifTrue: [readTask terminate]. |
|
382 |
readBlock := |
|
383 |
[ |
|
384 |
|dir currentFilenames oldListOfFiles| |
|
385 |
dir := directory asFilename. |
|
386 |
currentFilenames := OrderedCollection new. |
|
387 |
(dir isReadable and:[dir isExecutable]) ifTrue: |
|
388 |
[ |
|
389 |
self listOfFileFilters value do: |
|
390 |
[:filter| |
|
391 |
(dir filesMatchingWithoutDotDirs: filter) do: |
|
392 |
[:aFileName| |
|
393 |
|file| |
|
394 |
(file := dir construct: aFileName) isDirectory |
|
395 |
ifFalse: |
|
396 |
[ |
|
397 |
currentFilenames add: file |
|
398 |
] |
|
399 |
]. |
|
400 |
]. |
|
401 |
]. |
|
402 |
oldListOfFiles := self listOfFiles copy. |
|
403 |
(currentFilenames asSortedCollection: [:f1 :f2| f1 baseName < f2 baseName]) asSet do: |
|
404 |
[:fileName| |
|
405 |
(oldListOfFiles detect: [:fileRow| fileRow fileName = fileName] ifNone: nil) isNil |
|
406 |
ifTrue: |
|
407 |
[ |
|
408 |
|nearestFileRow r| |
|
409 |
nearestFileRow := self listOfFiles indexOf: (self listOfFiles detect: [:fileRow| fileRow baseName > fileName baseName] ifNone: nil). |
|
410 |
nearestFileRow = 0 |
|
411 |
ifTrue: [self listOfFiles add: (r := FileRow new fileName: fileName asFilename)] |
|
412 |
ifFalse: [self listOfFiles add: (r := FileRow new fileName: fileName asFilename) beforeIndex: nearestFileRow]. |
|
413 |
monitoring ifTrue: [self selectionOfFile value: r]. |
|
414 |
] |
|
415 |
]. |
|
416 |
self listOfFiles reverseDo: |
|
417 |
[:fileRow| |
|
418 |
(currentFilenames includes: fileRow fileName) |
|
419 |
ifFalse: [self listOfFiles remove: fileRow] |
|
420 |
] |
|
421 |
]. |
|
422 |
||
423 |
monitoring |
|
424 |
ifTrue: |
|
425 |
[ |
|
426 |
readTask := readBlock forkAt: Processor userBackgroundPriority. |
|
427 |
Processor addTimedBlock: monitoringTimeBlock afterSeconds: 1 |
|
428 |
] |
|
429 |
ifFalse: |
|
430 |
[ |
|
431 |
Cursor wait showWhile: [readBlock value] |
|
432 |
] |
|
433 |
! ! |
|
434 |
||
435 |
!DirectoryView methodsFor:'selection'! |
|
436 |
||
437 |
selectedFileFilter |
|
438 |
||
439 |
^selectedFileFilter |
|
440 |
||
441 |
! |
|
442 |
||
443 |
selectedFileFilter: aString |
|
444 |
||
445 |
aString size = 0 ifTrue: [self listOfFileFilters remove: selectedFileFilter ifAbsent: nil]. |
|
446 |
selectedFileFilter := aString. |
|
447 |
(self listOfFileFilters includes: selectedFileFilter) not & |
|
448 |
selectedFileFilter notEmpty |
|
449 |
ifTrue: |
|
450 |
[ |
|
451 |
self listOfFileFilters addFirst: selectedFileFilter |
|
452 |
]. |
|
453 |
(self listOfFileFilters includes: selectedFileFilter) & |
|
454 |
fileFilterSelectAction notNil |
|
455 |
ifTrue: |
|
456 |
[ |
|
457 |
fileFilterSelectAction numArgs = 0 |
|
458 |
ifTrue: |
|
459 |
[ |
|
460 |
fileFilterSelectAction value |
|
461 |
]. |
|
462 |
fileFilterSelectAction numArgs = 1 |
|
463 |
ifTrue: |
|
464 |
[ |
|
465 |
fileFilterSelectAction value: selectedFileFilter |
|
466 |
] |
|
467 |
]. |
|
468 |
self readDirectory. |
|
469 |
! ! |
|
470 |
||
471 |
!DirectoryView methodsFor:'startup / release'! |
|
472 |
||
473 |
closeRequest |
|
474 |
||
475 |
self release. |
|
476 |
||
477 |
super closeRequest |
|
478 |
||
479 |
! |
|
480 |
||
481 |
release |
|
482 |
||
483 |
monitoring ifTrue: |
|
484 |
[ |
|
485 |
Processor removeTimedBlock:monitoringTimeBlock. |
|
486 |
monitoringTimeBlock := nil |
|
487 |
]. |
|
488 |
||
489 |
super release |
|
490 |
||
491 |
! ! |
|
492 |
||
493 |
!DirectoryView::FileRow class methodsFor:'resources'! |
|
494 |
||
495 |
HFileIcon |
|
496 |
||
497 |
^self hFileIcon |
|
498 |
! |
|
499 |
||
500 |
MakefileIcon |
|
590 | 501 |
"Generated by the Image Editor" |
502 |
" |
|
503 |
ImageEditor openOnClass:self andSelector:#MakefileIcon |
|
504 |
" |
|
424 | 505 |
|
506 |
<resource: #image> |
|
590 | 507 |
|
508 |
^Icon |
|
509 |
constantNamed:#'DirectoryView::FileRow MakefileIcon' |
|
510 |
ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8 @@0 @@0 @@0)IV0/U$0)]&0)UT;)UV4 @@0 @@0???0???0'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]! |
|
424 | 511 |
|
512 |
binaryFileIcon |
|
590 | 513 |
"Generated by the Image Editor" |
514 |
" |
|
515 |
ImageEditor openOnClass:self andSelector:#binaryFileIcon |
|
516 |
" |
|
424 | 517 |
|
518 |
<resource: #image> |
|
590 | 519 |
|
520 |
^Icon |
|
521 |
constantNamed:#'DirectoryView::FileRow binaryFileIcon' |
|
522 |
ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???3 @_7 @W4#&S0&6Q0&6_3&6O5&6@0#&@9 @@0&\@2&6@0&6@0&6@1&6@8&\@0 @@0???0???1'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]! |
|
424 | 523 |
|
524 |
cFileIcon |
|
590 | 525 |
"Generated by the Image Editor" |
526 |
" |
|
527 |
ImageEditor openOnClass:self andSelector:#cFileIcon |
|
528 |
" |
|
424 | 529 |
|
530 |
<resource: #image> |
|
590 | 531 |
|
532 |
^Icon |
|
533 |
constantNamed:#'DirectoryView::FileRow cFileIcon' |
|
534 |
ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8 @@0 @@0 \@0 "@0 @0 @0&"@;&\@4 @@0 @@0???0???0'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]! |
|
424 | 535 |
|
536 |
exeFileIcon |
|
590 | 537 |
"Generated by the Image Editor" |
538 |
" |
|
539 |
ImageEditor openOnClass:self andSelector:#exeFileIcon |
|
540 |
" |
|
424 | 541 |
|
542 |
<resource: #image> |
|
590 | 543 |
|
544 |
^Icon |
|
545 |
constantNamed:#'DirectoryView::FileRow exeFileIcon' |
|
546 |
ifAbsentPut:[(Depth2Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUUUU@@@@UUT@@@AEUP@@@DEU@@@@PETEUUUUUPZ**)UUAUUUUATG???4EP_???PUA???=ATG???4EP_???PUA???=ATEUUUTEP@@@@@U@@@@@AUUUUUUUUUUUUUTb'); colorMap:(((Array new:4) at:1 put:((Color white)); at:2 put:((Color black)); at:3 put:((Color red:0.0 green:49.9977 blue:49.9977)); at:4 put:((Color grey:66.9978)); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]! |
|
424 | 547 |
|
548 |
fileIcon |
|
590 | 549 |
"Generated by the Image Editor" |
550 |
" |
|
551 |
ImageEditor openOnClass:self andSelector:#fileIcon |
|
552 |
" |
|
424 | 553 |
|
554 |
<resource: #image> |
|
590 | 555 |
|
556 |
^Icon |
|
557 |
constantNamed:#'DirectoryView::FileRow fileIcon' |
|
558 |
ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8 @@0 @@0 @@0 @@0 @@0 @@0 @@; @@4 @@0 @@0???0???0'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]! |
|
424 | 559 |
|
560 |
hFileIcon |
|
590 | 561 |
"Generated by the Image Editor" |
562 |
" |
|
563 |
ImageEditor openOnClass:self andSelector:#hFileIcon |
|
564 |
" |
|
424 | 565 |
|
566 |
<resource: #image> |
|
590 | 567 |
|
568 |
^Icon |
|
569 |
constantNamed:#'DirectoryView::FileRow hFileIcon' |
|
570 |
ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8 @0 @0 ,@0 2@0 "@0 "@0&"@;&"@4 @@0 @@0???0???0'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]! |
|
424 | 571 |
|
572 |
imageFileIcon |
|
573 |
"ImageEditor openOnClass:self andSelector:#imageFileIcon" |
|
574 |
||
575 |
<resource: #image> |
|
576 |
^(Depth4Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(#[0 0 0 0 0 0 0 0 0 0 1 17 17 17 17 17 16 0 0 0 1 17 17 17 17 17 16 16 0 0 1 17 17 17 17 17 16 17 0 0 1 17 17 17 17 17 16 17 16 0 1 17 17 17 17 17 16 0 0 0 1 68 71 119 74 71 215 0 0 0 1 68 71 119 164 173 125 17 17 0 1 68 71 119 74 71 215 17 17 0 1 51 54 102 57 54 198 17 17 0 1 51 54 102 147 156 108 17 17 0 1 51 54 102 57 54 198 17 17 0 1 34 37 85 40 37 181 17 17 0 1 34 37 85 130 139 91 17 17 0 1 34 37 85 40 37 181 17 17 0 1 17 17 17 17 17 17 17 17 0 1 17 17 17 17 17 17 17 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]) ; colorMap:((OrderedCollection new add:(Color black); add:(Color white); add:(Color red:100.0 green:0.0 blue:0.0); add:(Color red:0.0 green:100.0 blue:0.0); add:(Color red:0.0 green:0.0 blue:100.0); add:(Color red:0.0 green:100.0 blue:100.0); add:(Color red:100.0 green:100.0 blue:0.0); add:(Color red:100.0 green:0.0 blue:100.0); add:(Color red:49.9992 green:0.0 blue:0.0); add:(Color red:0.0 green:49.9992 blue:0.0); add:(Color red:0.0 green:0.0 blue:49.9992); add:(Color red:0.0 green:49.9992 blue:49.9992); add:(Color red:49.9992 green:49.9992 blue:0.0); add:(Color red:49.9992 green:0.0 blue:49.9992); add:(Color grey:49.9992); add:(Color grey:66.9993); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself! |
|
577 |
||
578 |
imgFileIcon |
|
590 | 579 |
"Generated by the Image Editor" |
580 |
" |
|
581 |
ImageEditor openOnClass:self andSelector:#imgFileIcon |
|
582 |
" |
|
424 | 583 |
|
584 |
<resource: #image> |
|
590 | 585 |
|
586 |
^Icon |
|
587 |
constantNamed:#'DirectoryView::FileRow imgFileIcon' |
|
588 |
ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8 @0 @@0!!-F0 **0 **0 **0&**;&*&4 @B0 @N0???0???0'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]! |
|
424 | 589 |
|
590 |
linkedFileIcon |
|
591 |
"ImageEditor openOnClass:self andSelector:#linkedFileIcon" |
|
592 |
||
593 |
<resource: #image> |
|
594 |
^(Depth2Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(#[85 85 85 85 85 64 0 0 21 85 64 0 0 17 85 64 0 0 16 85 64 0 0 16 21 64 0 0 21 85 64 0 0 5 85 64 0 0 0 5 64 0 0 8 5 64 0 0 10 5 64 0 10 170 133 64 0 42 170 133 64 0 160 10 5 66 170 128 8 5 66 170 0 0 5 64 0 0 0 5 64 0 0 0 5 85 85 85 85 85 85 85 85 85 85]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:0.0 green:0.0 blue:100.0); add:(Color red:100.0 green:0.0 blue:0.0); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself! |
|
595 |
||
596 |
lockedFileIcon |
|
597 |
"ImageEditor openOnClass:self andSelector:#lockedFileIcon" |
|
598 |
||
599 |
<resource: #image> |
|
600 |
^(Depth2Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(#[85 85 85 85 85 104 0 0 21 85 74 0 0 17 85 66 128 0 16 85 64 160 0 16 21 64 40 0 149 85 64 10 2 133 85 64 2 138 0 5 64 0 168 0 5 64 0 168 0 5 64 2 138 0 5 64 10 2 128 5 64 40 0 160 5 64 160 0 40 5 66 128 0 10 5 74 0 0 2 133 104 0 0 0 165 85 85 85 85 85 85 85 85 85 85]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:100.0 green:0.0 blue:0.0); add:(Color red:0.0 green:100.0 blue:0.0); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself! |
|
601 |
||
602 |
protoFileIcon |
|
603 |
||
604 |
^self MakefileIcon |
|
605 |
! |
|
606 |
||
607 |
rcFileIcon |
|
608 |
"ImageEditor openOnClass:self andSelector:#rcFileIcon" |
|
609 |
||
610 |
<resource: #image> |
|
611 |
^(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 255 249 128 7 240 128 5 242 128 4 240 128 4 112 128 7 240 128 3 248 128 0 48 128 0 48 130 152 48 131 36 48 130 32 48 130 32 48 154 36 59 154 24 52 128 0 48 128 0 48 255 255 240 255 255 240]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself! |
|
612 |
||
613 |
sFileIcon |
|
614 |
"ImageEditor openOnClass:self andSelector:#sFileIcon" |
|
615 |
||
616 |
<resource: #image> |
|
617 |
^(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 255 249 128 7 240 128 5 242 128 4 240 128 4 112 128 7 240 128 3 248 128 0 48 128 0 48 129 128 48 130 0 48 131 0 48 129 128 48 152 128 59 155 0 52 128 0 48 128 0 48 255 255 240 255 255 240]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself! |
|
618 |
||
619 |
stFileIcon |
|
590 | 620 |
"Generated by the Image Editor" |
621 |
" |
|
622 |
ImageEditor openOnClass:self andSelector:#stFileIcon |
|
623 |
" |
|
424 | 624 |
|
625 |
<resource: #image> |
|
590 | 626 |
|
627 |
^Icon |
|
628 |
constantNamed:#'DirectoryView::FileRow stFileIcon' |
|
629 |
ifAbsentPut:[(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???9 @_0 @W2 @S0 @Q0 @_0 @O8 A@0 A@0 [00 !!@0 1@0 Y@0&I@;&004 @@0 @@0???0???0'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??0@??8@??<@??>@???@??? ???0???0???0???0???0???0???0???0???0???0???0???0_??0'); yourself); yourself]! |
|
424 | 630 |
|
631 |
stcFileIcon |
|
632 |
"ImageEditor openOnClass:self andSelector:#stcFileIcon" |
|
633 |
||
634 |
<resource: #image> |
|
635 |
^(Depth1Image new) width: 20; height: 19; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 255 249 128 7 240 128 5 242 128 4 240 128 4 112 128 7 240 128 3 248 128 32 48 128 32 48 129 243 48 130 36 176 131 36 48 129 164 48 152 164 187 155 51 52 128 0 48 128 0 48 255 255 240 255 255 240]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color black); yourself)); mask:((ImageMask new) width: 20; height: 19; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[255 252 0 255 254 0 255 255 0 255 255 128 255 255 192 255 255 224 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 255 255 240 127 255 240]) ; yourself); yourself! ! |
|
636 |
||
637 |
!DirectoryView::FileRow methodsFor:'accessing'! |
|
638 |
||
639 |
baseName |
|
640 |
||
641 |
^baseName ? (baseName := fileName baseName) |
|
642 |
||
643 |
||
644 |
||
645 |
||
646 |
||
647 |
||
648 |
||
649 |
! |
|
650 |
||
651 |
fileName |
|
652 |
||
653 |
^fileName |
|
654 |
! |
|
655 |
||
656 |
fileName: aFileName |
|
657 |
||
614 | 658 |
fileName := aFileName |
424 | 659 |
! |
660 |
||
661 |
group |
|
662 |
||
663 |
^group |
|
664 |
! |
|
665 |
||
666 |
iconOn:aGC |
|
667 |
||
668 |
(aGC registeredImageAt:iconKey) isNil |
|
669 |
ifTrue: |
|
670 |
[ |
|
614 | 671 |
self validateAttributes. |
474 | 672 |
((iconKey == #imageFileIcon) and: [size < 5000]) |
424 | 673 |
ifTrue: |
674 |
[ |
|
675 |
Object errorSignal handle: [:ex|] |
|
676 |
do: |
|
677 |
[ |
|
678 |
|image| |
|
679 |
(image := Image fromFile: fileName name) notNil |
|
680 |
ifTrue: |
|
681 |
[ |
|
682 |
image extent y > 22 |
|
683 |
ifTrue: |
|
684 |
[ |
|
685 |
image := image magnifiedBy: 22/image extent y |
|
686 |
]. |
|
687 |
(aGC registeredImageAt: (iconKey := fileName name asSymbol)) isNil |
|
688 |
ifTrue: |
|
689 |
[ |
|
690 |
aGC registerImage: image key: iconKey |
|
691 |
] |
|
692 |
] |
|
693 |
] |
|
694 |
] |
|
695 |
ifFalse: |
|
696 |
[ |
|
697 |
aGC registerImage: (self class perform: iconKey) key: iconKey |
|
698 |
] |
|
699 |
]. |
|
700 |
^aGC registeredImageAt: iconKey |
|
701 |
||
702 |
||
703 |
||
704 |
||
705 |
! |
|
706 |
||
707 |
modified |
|
708 |
||
709 |
^modified |
|
710 |
! |
|
711 |
||
712 |
owner |
|
713 |
||
714 |
^owner |
|
715 |
! |
|
716 |
||
717 |
permissions |
|
718 |
||
719 |
^permissions |
|
720 |
! |
|
721 |
||
722 |
size |
|
607 | 723 |
size isNumber ifFalse:[^ size]. |
724 |
size < 1000 ifTrue: [^ size printString]. |
|
725 |
size < (100*1024) ifTrue: [^(((size/1024) * 10) asInteger/10) asFloat printString, ' Kb']. |
|
726 |
size < (1000*1024) ifTrue: [^(((size/1024)) asInteger) printString, ' Kb']. |
|
727 |
^(((size/1048576) * 10) asInteger/10) asFloat printString, ' Mb' |
|
424 | 728 |
|
607 | 729 |
"Modified: / 6.2.1998 / 03:38:45 / cg" |
424 | 730 |
! ! |
731 |
||
732 |
!DirectoryView::FileRow methodsFor:'private'! |
|
733 |
||
734 |
validateAttributes |
|
735 |
||
736 |
|info mode| |
|
737 |
permissions := String new:9 withAll:$-. |
|
738 |
||
739 |
(info := fileName info) isNil |
|
740 |
ifTrue: |
|
741 |
[ |
|
742 |
iconKey := #lockedFileIcon. |
|
743 |
size := owner := group := '?'. |
|
744 |
^ self |
|
745 |
]. |
|
746 |
size := info size. |
|
747 |
modified := info modified printString. |
|
748 |
owner := OperatingSystem getUserNameFromID: info uid. |
|
749 |
group := OperatingSystem getGroupNameFromID: info gid. |
|
750 |
mode := info mode. |
|
751 |
||
752 |
1 to:9 by:3 do:[:i| |
|
753 |
#((0 $x) (1 $w) (2 $r)) do: |
|
754 |
[:m| |
|
755 |
(mode bitAt:i + m first) == 1 ifTrue:[permissions at: 10 - m first - i put: m last] |
|
756 |
] |
|
757 |
]. |
|
758 |
||
759 |
fileName isReadable |
|
760 |
ifTrue: |
|
761 |
[ |
|
762 |
info type == #symbolicLink |
|
763 |
ifTrue: |
|
764 |
[ |
|
765 |
^iconKey := #linkedFileIcon |
|
766 |
] |
|
767 |
ifFalse: |
|
768 |
[ |
|
769 |
((DirectoryView::FileRow class implements: (iconKey := (fileName suffix, 'FileIcon') asSymbol)) |
|
770 |
or: |
|
771 |
[DirectoryView::FileRow class implements: (iconKey := (fileName baseName, 'Icon') asSymbol)]) |
|
772 |
ifFalse: |
|
773 |
[ |
|
774 |
iconKey := #fileIcon. |
|
775 |
(Image isImageFileSuffix:fileName suffix) |
|
776 |
ifTrue: |
|
777 |
[ |
|
778 |
^iconKey := #imageFileIcon |
|
779 |
]. |
|
780 |
(fileName suffix = 'o') | (fileName suffix = 'so') |
|
781 |
ifTrue: |
|
782 |
[ |
|
783 |
^iconKey := #binaryFileIcon |
|
784 |
]. |
|
785 |
||
786 |
fileName isExecutableProgram |
|
787 |
ifTrue: |
|
788 |
[ |
|
789 |
^iconKey := #exeFileIcon |
|
790 |
] |
|
791 |
] |
|
792 |
] |
|
793 |
] |
|
794 |
ifFalse: |
|
795 |
[ |
|
796 |
^iconKey := #lockedFileIcon |
|
797 |
]. |
|
798 |
||
799 |
||
800 |
! ! |
|
801 |
||
802 |
!DirectoryView class methodsFor:'documentation'! |
|
803 |
||
804 |
version |
|
805 |
^ '$Header$' |
|
806 |
! ! |